diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 30aa5c96d..e123eab74 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,5 +1,5 @@ name: Bug report -description: Create a report to help us understand and diagnose your issue. Your contribution is welcomed and valued! +description: Create a report to help us understand and diagnose your issue. Your contribution is welcomed and valued! It is highly recommended that you are using the latest version before submitting a bug report. title: "[ bug Report ]" labels: Awaiting Triage @@ -8,17 +8,19 @@ body: - type: markdown attributes: value: | - Please follow this document in order to report a bug + Please follow this document in order to report a bug. It is highly recommended that you are using the latest version before submitting a bug report. - type: dropdown attributes: label: TombEngine version description: | - Please select the TombEngine Version from the dropdown list. + Please select the TombEngine Version from the dropdown list. options: - Development Build - - v1.5.0.2 (Latest Release) - - v1.4 + - v1.8.0 (latest version) + - v1.7.1 + - v1.7.0 + - v1.5 validations: required: true @@ -29,6 +31,7 @@ body: Please select the Tomb Editor version used from the dropdown list. options: - Development Build + - v1.8.0 (latest version) - v1.7.2 - v1.7.1 - v1.7.0 diff --git a/AUTHORS.md b/AUTHORS.md index 096d4944c..d25ba84fa 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -17,6 +17,7 @@ This is the credit list of **all** the people who contributed to TombEngine in a - Sezz (player state refactoring, general coding, code cleanups, bug fixing, assets) - Squidshire (Hispidence) (Lua implementation, bug fixing) - Stranger1992 (sound asset refactoring and organisation, assets) +- TrainWreck (asset coding and Lua enhancements) - TokyoSU (entity and vehicle decompilation) - Tomo (general coding, special FX coding, bug fixing) - Troye (general coding, refactoring) @@ -49,5 +50,4 @@ This is the credit list of **all** the people who contributed to TombEngine in a - JoeyQuint (Standing 180° turn, monkey swing 180° turn) ### TombEngine Marketing -- Kubsy (Twitter and forum posts) -- Stranger1992 (This website, Facebook, Instagram, Youtube and Twitch. +- Stranger1992 (Tomb Engine website, Discord, Facebook, Instagram, Youtube, X, and Twitch) diff --git a/CHANGELOG.md b/CHANGELOG.md index 663db9c1e..70d6aa069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,57 @@ The dates are in European standard format where date is presented as **YYYY-MM-DD**. TombEngine releases are located in this repository (alongside with Tomb Editor): https://github.com/TombEngine/TombEditorReleases -## [Version 1.8](link to release) - yyyy-mm-dd +## [Version 1.8.2] + +## New features +* Added video playback support. +* Added muzzle glow effect for firearms. ### Bug fixes +* Fixed crashes when shooting, if gunflash or gunshell objects are not present in a level. +* Fixed Teleporter object. +* Fixed Wraith objects not working correctly in flipped rooms. +* Fixed lensflare enabled status not saved in a savegame. +* Fixed HK sound effects. +* Fixed HK shots not being registered in statistics. +* Fixed distorted knee and elbow joint vertices. +* Fixed caustics not rendered correctly if texture compression was enabled. +* Fixed exclusion blend mode not working correctly. +* Fixed SSAO incorrectly applied through alpha blended textures. +* Removed legacy TR5 search object code which caused issues with meshswaps. + +### Lua API changes +* Added `View.PlayVideo`, `View.StopVideo`, and other helper functions for the video playback. +* Added `Flow.SetIntroVideoPath` function to specify intro video. +* Added `Lara:Interact` function to allow alignment with moveables. +* Added `muzzleGlow` and `muzzleOffset` parameters to weapon settings. +* Added ability to use gunflash parameters for all weapons in weapon settings. +* Fixed `Moveable.GetJointPosition` not returning correct results if moveable is invisible or not rendered. + +## [Version 1.8.1](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.8.1) - 2025-03-29 + +### Bug fixes +* Fixed pathfinding for friendly NPCs such as monkeys. +* Fixed particles remaining in the level after reloading from the savegame. +* Fixed particles being canceled by fog bulbs. +* Fixed crash in case hair object is the last object in a level. +* Fixed crash with incorrectly applied animated textures on static meshes. +* Fixed console window not hiding in non-debug mode on Windows 11. +* Fixed key binding settings saving for the current play session after hitting Esc to cancel. +* Fixed lensflare blending formula to avoid screen overbright. + +### New features +* Added Firefly Emitter object (ID 1099) with corresponding sprite slot (ID 1379). +* Added live console input to perform Lua commands in realtime. + +### Lua API changes +* Added missing constructor for `Collision.Probe` without room number. +* Added optional looping argument for `View.GetFlybyPosition` and `View.GetFlybyRotation` functions. + +## [Version 1.8](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.8) - 2025-03-16 + +### Bug fixes +* Improved engine performance up to 20%. * Fixed bridges moving the player when the player is underwater. * Fixed trigger triggerer not working. * Fixed display pickup numeric string not being interpolated in high framerate mode. @@ -13,32 +61,49 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed incorrect handling of dynamic light shadows. * Fixed ricochet flashes after using explosive weapons. * Fixed incorrect flare draw in crawl state. -* Fixed starfield remaining active in the next level if next level does not have a starfield specified. +* Fixed starfield remaining active in the next level if it does not have a starfield specified. +* Fixed underwater dust particles overflowing when camera is underwater. * Fixed wetness player attribute not being preserved in savegames. * Fixed invisible HK ammo in the inventory. * Fixed flickering rat emitter. +* Fixed camera glitch when going into quicksand rooms with weapons drawn. * Fixed player model submerging into the floor while swimming underwater. * Fixed custom shatter sounds with custom sound IDs not playing correctly. * Fixed crashes with sound samples larger than 2 megabytes. -### New Features +### New features * Added multithreading and an option for it to flow system settings. -* Added ability to use keys and puzzle items underwater. +* Added ability to use floor trapdoors, keys and puzzle items underwater. - You must update your Lara object: https://github.com/TombEngine/Resources/raw/main/Wad2%20Objects/Lara/TEN_Lara.wad2 * Added a particle based waterfall emitter object and associated sprite slots. - You must use this version: https://github.com/TombEngine/Resources/raw/refs/heads/main/Wad2%20Objects/Interactables/TEN_Waterfall_Emitter.wad2 +* Added TR1 Hammer. + - You must use this version: +* Added TR3 Moving Laser. +* Added TR4 Statue Plinth. ### Lua API changes -* Added Collision.Probe class for basic collision detection. * Added diary module. -* Added View.GetFlyByPosition() and View.GetFlyByRotation() functions to get flyby sequence parameters at a specified time point. -* Added Effects.EmitAirBubble() function to spawn air bubbles. -* Added Moveable:GetScale() and Movebale:SetScale() methods to set visible scale of moveables. -* Added Rotation:Lerp() function to allow linear interpolation between rotations. -* Added various Translate() methods to Vec2 and Vec3 script objects. -* Added alpha transparency functionality for statics and moveables by using SetColor() method. -* Added extra arguments for sprite object slots and starting rotation value for EmitParticle function. - +* Added custom bar module. +* Added `Collision.Probe` class for basic room collision detection. +* Added `Flow.Horizon` class and two layers of horizons in a `Flow.Level` class. +* Added `Effects.EmitAdvancedParticle` function, allowing animations and other effects. +* Added `Effects.EmitAirBubble` function to spawn air bubbles. +* Added `Effects.EmitStreamer` function to emit streamers. +* Added `Flow.GetTotalSecretCount` function to get total amount of secrets in the game. +* Added `View.GetFlyByPosition` and `View.GetFlyByRotation` functions to get flyby sequence parameters at a specified time point. +* Added `Moveable:GetScale` and `Movebale:SetScale` methods to get or set visible scale of moveables. +* Added `Static:GetCollidable` and `Static:SetCollidable` methods to get or set collision status of static meshes. +* Added `Rotation:Lerp` function to allow linear interpolation between rotations. +* Added ability to perform additive and subtractive operations on `Rotation` class and compare one `Rotation` to another. +* Added various `Translate` methods to `Vec2` and `Vec3` script objects. +* Added alpha transparency functionality for statics and moveables to be used with `SetColor` method. +* Added extra arguments for sprite object slots and starting rotation value for `EmitParticle` function. +* Added ability to dynamically change `Flow.Level` weather and environment parameters and save them to a savegame. +* Added pickup count to `Flow.Statistics` class. +* Changed `Flow.Starfield` and `Flow.LensFlare` primitive types to use parameters instead of getters and setters. +* Fixed medipack level count in `Flow.Statistics` class. + ## [Version 1.7.1](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.4) - 2025-04-01 ### Bug fixes @@ -55,7 +120,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed gravity being applied underwater when exiting the fly cheat. * Fixed gravity being applied when vaulting on the same frame as the player lands. -### New Features +### New features * Added realtime shader reloading in debug mode by pressing F9 key. * Added load, save, stopwatch and compass as a functional pick-up items with ability to add or remove them from inventory. * Increased particle limit from 1024 to 4096. @@ -105,7 +170,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed spotlight shadows. * Fixed Skeleton and Mummy not reacting to shotgun hits. -### New Features +### New features * Added classic mirror effect with ability to reflect moveables and static meshes. * Added ability to customize many hardcoded parameters, such as flare, weapon, and hair settings. * Added dynamic shadow casting on objects and static meshes. @@ -181,7 +246,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed display sprites and display strings rendering in the inventory background. * Fixed young Lara hair drawing. https://tombengine.com/docs/level-settings/#young_lara -### New Features +### New features * Added high framerate mode (also known as 60 FPS mode). * Added a customisable global lensflare effect. https://tombengine.com/docs/level-settings/#lensflare * Added a customisable starry sky and meteor effect. https://tombengine.com/docs/level-settings/#stars @@ -241,7 +306,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed bottom collision for solid static meshes. * Fixed T-Rex's head rotation. -### New Features +### New features * Auto-switch to a crawl state if player start position is in a crawlspace. * Allow directional flame emitter (negative OCBs) to be rotated at any angle. * Revise wall spikes: @@ -288,7 +353,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed incorrect light collection in some cases. * Fixed normal mapping for rooms, items, and statics.' -### New Features +### New features * Added ambient occlusion (SSAO). * Added new post-process workflow (monochrome, negative, exclusion) with tinting. * Added SMAA antialiasing instead of MSAA. @@ -347,7 +412,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix camera snap when disengaging the look-around mode. * Fix TR4 mapper not being visible. -### New Features +### New features * Improve head-on wall collision. * Overhaul pushables: - Separate climbable and non-climbable pushable object slots. @@ -430,7 +495,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix incorrect culling for scaled static meshes. * Fix normal mapping. -### New Features +### New features * Add ability to save screenshot in the "Screenshots" subfolder by pressing the "Print screen" key. * Implement separate audio track channel for playing voiceovers with subtitles in .srt format. * Don't stop ambience when Lara dies. @@ -478,7 +543,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix rendering for static meshes with custom blending modes and alpha transparency. * Fix inconsistent multiline string spacing on different display modes. -### New Features +### New features * Remove search object 4 hardcoded meshswap activated with a flipmap. * Add TR1 cowboy. * Add TR3 wall mounted blade. @@ -536,7 +601,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): - Please note you must use the patched version found here: https://github.com/TombEngine/Resources/blob/main/Wad2%20Objects/tr5_Imp.wad2 * Fix and improve wraith tails. -### New Features/Amedments +### New features/Amedments * Add dedicated WRAITH_TRAP object with enhanced effects. - OCB 0: Effect disabled. - OCB 1: Effect enabled. @@ -585,7 +650,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix TR3 big gun spawning rocket with 0 life which caused an immediate explosion. * Fix TR3 Tony and add boss effect for him. -### New Features +### New features * Add TR3 civvy. * Add TR3 electric cleaner. * Add TR3 Sophia Leigh with following OCBs: @@ -637,7 +702,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix grenade and rocket launcher lighting. * Fix ceiling trapdoor and floor trapdoor that Lara couldn't open manually. -### New Features +### New features * Make enemies drop pickups at first available bounding box corner point, not centerpoint. * Restore original volumetric explosion effects. * Add TR3 lizard and Puna. @@ -689,7 +754,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fix bone rotations of some entities. * Fix Lara's animation for cog switch release. -### New Features +### New features * Added new OCB to cog switch object: - Use OCB 0 to have the traditional behaviour. - Use any other OCB to can use the Cog Switch without need of any door linked. @@ -703,7 +768,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ## [Version 1.0.4](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.6.2) - 2022-12-16 -### New Features +### New features * Add generic assignable effects for moveables - fire, sparks, smoke and laser / electric ignite. * Add ability to burn enemies with FLAME_EMITTER_1 and death blocks. * Add wireframe mode and other visual debug information (switch by F10/F11 debug page scroll hotkeys). @@ -775,7 +840,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ## [Version 1.0.3](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.6.1) - 2022-11-18 -### New Features +### New features * Add ledge jumps (Lara object must be updated with new animations to make it work). * Allow any object slot to be used as a meshswap. * Add OCB 1 for rollingball to make it silent. @@ -843,7 +908,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ## [Version 1.0.2](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.6) - 2022-09-16 -### New Features +### New features * Fix removing Pistols with TakeItem and SetItemCount. * Allow saving and loading of Vec3s in LevelVars and GameVars. * Support volume triggers made with node editor. @@ -898,7 +963,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ## [Version 1.0.1](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.5.2) - 2022-08-16 -### New Features +### New features * Added antialiasing support. * Added static mesh scaling support. * Added free rotation for teeth spikes instead of using OCB codes. diff --git a/Documentation/compiler/ldoc/ldoc/doc.lua b/Documentation/compiler/ldoc/ldoc/doc.lua index 30f8eafc5..e0325f4dc 100644 --- a/Documentation/compiler/ldoc/ldoc/doc.lua +++ b/Documentation/compiler/ldoc/ldoc/doc.lua @@ -846,7 +846,7 @@ end function build_arg_list (names,pmods) -- build up the string representation of the argument list, -- using any opt and optchain modifiers if present. - -- For instance, '(a [, b])' if b is marked as optional + -- For instance, '(a, [b])' if b is marked as optional -- with @param[opt] b local buffer, npending = { }, 0 local function acc(x) table.insert(buffer, x) end @@ -868,20 +868,17 @@ function build_arg_list (names,pmods) local opt if m then if not m.optchain then - acc ((']'):rep(npending)) npending=0 end opt = m.optchain or m.opt - if opt then - acc('[') - npending=npending+1 - end end if i>1 then acc (', ') end - acc(names[i]) - if opt and opt ~= true then acc('='..opt) end + if opt then + acc('[' .. names[i] .. ']') + else + acc(names[i]) + end end - acc ((']'):rep(npending)) return '('..table.concat(buffer)..')' end diff --git a/Documentation/compiler/ldoc/ldoc/html/ldoc_ltp.lua b/Documentation/compiler/ldoc/ldoc/html/ldoc_ltp.lua index 31b09d72c..2efb79a43 100644 --- a/Documentation/compiler/ldoc/ldoc/html/ldoc_ltp.lua +++ b/Documentation/compiler/ldoc/ldoc/html/ldoc_ltp.lua @@ -215,12 +215,12 @@ return [==[ # end $(M(item.params.map[p],item)) # if def == true then - (optional) + (Optional.) # elseif def then - (default $(def)) + (Default. $(def)) # end # if item:readonly(p) then - readonly + Read-only. # end # end diff --git a/Documentation/config.ld b/Documentation/config.ld index bae3388cd..c16aa6c57 100644 --- a/Documentation/config.ld +++ b/Documentation/config.ld @@ -12,27 +12,27 @@ new_type("luautil", "5 Lua utility modules", true) not_luadoc = true -local version = "1.7.2 (Developer)" +local version = "1.8.2" project = " TombEngine" title = "TombEngine " .. version .. " Lua API" description = "TombEngine " .. version .. " scripting interface" -full_description = [[Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. +full_description = [[Welcome to the TombEngine scripting API. +Note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website. -####Module Hierarchy (boring but important) -Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN. + +####Module Hierarchy +Other than the "special tables" (`GameVars`, `LevelVars` and `LevelFuncs`), every module described herein is held in a master table called TEN. For convenience, these modules and classes are automatically put in the global table. For example, you can call GetMoveableByName either of these two ways: local door = TEN.Objects.GetMoveableByName("door_type4_14") local door = GetMoveableByName("door_type4_14") ####Always check logs/TENLog.txt -If you are scripting levels, TombEngine will often kick you back to the title screen, even if `errorMode` (see Flow.Settings) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`. +If you are scripting levels, TombEngine will often kick you back to the title screen, even if `errorMode` (see @{Flow.Settings}) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`. -This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing `end` at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless. +This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing `end` at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless. If this happens, check __logs/TENLog.txt__ and look for an error message with the word "unrecoverable". -If this happens, check __logs/TENLog.txt__ and look for an error message with the word "unrecoverable". - -Enjoy. +Happy building! \- _squidshire and the TombEngine development team._ ]] diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html index 668142f9b..bafc35aa1 100644 --- a/Documentation/doc/1 modules/Effects.html +++ b/Documentation/doc/1 modules/Effects.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

3 Primitive Classes

5 Lua utility modules

@@ -309,28 +349,83 @@

Usage:

+ + +
+ + EmitAdvancedParticle(particleData) +
+
+ Emit a particle with extensive configuration options, including sprite sequence animation, lights, sounds, and damage effects. + + + +

Parameters:

+ + + + + +

Usage:

+
- EmitShockwave(pos, innerRadius, outerRadius, color, lifetime, speed, angle, hurtsLara) + EmitShockwave(pos, [innerRadius], [outerRadius], [color], [lifetime], [speed], [angle], [hurtsLara])
Emit a shockwave, similar to that seen when a harpy projectile hits something. @@ -341,35 +436,42 @@ @@ -380,7 +482,7 @@
- EmitLight(pos[, color][, radius][, shadows][, name]) + EmitLight(pos, [color], [radius], [shadows], [name])
Emit dynamic light that lasts for a single frame. @@ -396,23 +498,23 @@
  • color Color - light color (default Color(255, 255, 255)) - (optional) + light color. + Default: Color(255, 255, 255).
  • radius int - measured in "clicks" or 256 world units (default 20) - (optional) + Measured in "clicks" or 256 world units. + Default: 20.
  • shadows bool - determines whether light should generate dynamic shadows for applicable moveables (default is false) - (optional) + Determines whether light should generate dynamic shadows for applicable moveables. + Default: false.
  • name string - if provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights) - (optional) + If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). + Optional.
  • @@ -423,7 +525,7 @@
    - EmitSpotLight(pos, dir[, color][, radius][, falloff][, distance][, shadows][, name]) + EmitSpotLight(pos, dir, [color], [radius], [falloff], [distance], [shadows], [name])
    Emit dynamic directional spotlight that lasts for a single frame. @@ -443,33 +545,33 @@
  • color Color - (default Color(255, 255, 255)) - (optional) + Color. + Default: Color(255, 255, 255).
  • radius int - overall radius at the endpoint of a light cone, measured in "clicks" or 256 world units (default 10) - (optional) + Overall radius at the endpoint of a light cone, measured in "clicks" or 256 world units. + Default: 10.
  • falloff int - radius, at which light starts to fade out, measured in "clicks" (default 5) - (optional) + Radius, at which light starts to fade out, measured in "clicks". + Default: 5.
  • distance int - distance, at which light cone fades out, measured in "clicks" (default 20) - (optional) + Distance, at which light cone fades out, measured in "clicks". + Default: 20.
  • shadows bool - determines whether light should generate dynamic shadows for applicable moveables (default is false) - (optional) + Determines whether light should generate dynamic shadows for applicable moveables. + Default: false.
  • name string - if provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights) - (optional) + If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). + Optional.
  • @@ -480,7 +582,7 @@
    - EmitBlood(pos, count) + EmitBlood(pos, [count])
    Emit blood. @@ -497,7 +599,8 @@
  • count int - (default 1) "amount" of blood. Higher numbers won't add more blood but will make it more "flickery", with higher numbers turning it into a kind of red orb. + Sprite count. + Default: 1.
  • @@ -508,10 +611,10 @@
    - EmitAirBubble(pos[, size][, amp]) + EmitAirBubble(pos, [size], [amp])
    - Emit air bubble in a water room. + Emit an air bubble in a water room. @@ -523,13 +626,13 @@
  • size float - Sprite size. Default: 32 - (optional) + Sprite size. + Default: 32.
  • amp float - Oscillation amplitude. Default: 32 - (optional) + Oscillation amplitude. + Default: 32.
  • @@ -540,7 +643,7 @@
    - EmitFire(pos, size) + EmitFire(pos, [size])
    Emit fire for one frame. Will not hurt player. Call this each frame if you want a continuous fire. @@ -551,13 +654,12 @@ @@ -568,7 +670,7 @@
    - MakeExplosion(pos, size, shockwave) + MakeExplosion(pos, [size], [shockwave])
    Make an explosion. Does not hurt Lara @@ -585,11 +687,13 @@
  • size float - (default 512.0) this will not be the size of the sprites, but rather the distance between the origin and any additional sprites + This will not be the size of the sprites, but rather the distance between the origin and any additional sprites. + Default: 512.
  • shockwave bool - (default false) if true, create a very faint white shockwave which will not hurt Lara + If true, create a very faint white shockwave which will not hurt Lara. + Default: false.
  • @@ -600,7 +704,7 @@
    - MakeEarthquake(strength) + MakeEarthquake([strength])
    Make an earthquake @@ -611,7 +715,8 @@ @@ -641,6 +746,250 @@ +
    +
    + + EmitStreamer(mov, tag, pos, dir, [rot], [startColor], [endColor], [width], [life], [vel], [expRate], [rotRate], [edgeFeatherMode], [lengthFeatherMode], [blendID]) +
    +
    + Emit an extending streamer effect. + + + +

    Parameters:

    + + + + + + +
    + +

    Tables

    + +
    +
    + + ParticleData +
    +
    + Structure for EmitAdvancedParticle table. + + + +

    Fields:

    +
      +
    • pos + Vec3 + World position. +
    • +
    • vel + Vec3 + Directional velocity in world units per second. +
    • +
    • spriteSeqID + SpriteConstants + Sprite sequence slot ID. + Default: Objects.ObjID.DEFAULT_SPRITES. +
    • +
    • spriteID + int + Sprite ID in the sprite sequence slot. + Default: 0. +
    • +
    • life + float + Lifespan in seconds. + Default: 2. +
    • +
    • maxYVel + float + Maximum vertical velocity in world units per second. + Default: 0. +
    • +
    • gravity + float + Effect of gravity in world units per second. Positive value ascend, negative value descend. + Default: 0. +
    • +
    • friction + float + Friction affecting velocity over time in world units per second. + Default: 0. +
    • +
    • startRot + float + Rotation at start of life. + Default: random. +
    • +
    • rotVel + float + Rotational velocity in degrees per second. + Default: 0. +
    • +
    • startSize + float + Size at start of life. + Default: 10. +
    • +
    • endSize + float + Size at end of life. + Default: 0. +
    • +
    • startColor + Color + Color at start of life. + Default: Color(255, 255, 255). +
    • +
    • endColor + Color + Color at end of life. Note that this will finish long before the end of life due to internal math. + Default: Color(255, 255, 255). +
    • +
    • blendMode + BlendID + Render blend mode. + Default: TEN.Effects.BlendID.ALPHA_BLEND. +
    • +
    • damage + bool + Harm the player on collision. + Default: false. +
    • +
    • poison + bool + Poison the player on collision. + Default: false. +
    • +
    • burn + bool + Burn the player on collision. + Default: false. +
    • +
    • wind + bool + Affect position by wind in outside rooms. + Default: false. +
    • +
    • damageHit + int + Player damage amount on collision. + Default: 2. +
    • +
    • light + bool + Emit a colored light. Caution: Recommended only for a single particle. Too many particles with lights can overwhelm the lighting system. + Default: false. +
    • +
    • lightRadius + int + Light radius in 1/4 blocks. + Default: 0. +
    • +
    • lightFlicker + int + Interval at which the light should flicker. + Default: 0. +
    • +
    • soundID + int + Sound ID to play. Caution: Recommended only for a single particle. Too many particles with sounds can overwhelm the sound system. + Optional. +
    • +
    • animated + bool + Play animates sprite sequence. + Default: false. +
    • +
    • animType + ParticleAnimationType + Animation type of the sprite sequence. + Default: TEN.Effects.ParticleAnimationType.LOOP. +
    • +
    • frameRate + float + Sprite sequence animation framerate. + Default: 1. +
    • +
    + + + + +
    diff --git a/Documentation/doc/1 modules/Flow.html b/Documentation/doc/1 modules/Flow.html index 743e3d7c8..0f6720dc5 100644 --- a/Documentation/doc/1 modules/Flow.html +++ b/Documentation/doc/1 modules/Flow.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

    @@ -965,7 +1019,7 @@ Must be an integer value (0 means no secrets). @@ -988,7 +1042,7 @@ Must be an integer value (0 means no secrets).
      Settings - current settings table + Current settings table.
    @@ -1000,8 +1054,7 @@ Must be an integer value (0 means no secrets).
    -These functions used in strings.lua, which is generated by TombIDE. -You will not need to call them manually. +These functions used in strings.lua, which is generated by TombIDE. You will not need to call them manually.
    @@ -1016,8 +1069,8 @@ You will not need to call them manually.

    Parameters:

    • table - tab - array-style table with strings + table + Array-style table with strings.
    @@ -1028,7 +1081,7 @@ You will not need to call them manually.
    - GetString(string) + GetString(key)
    Get translated string. @@ -1037,9 +1090,9 @@ You will not need to call them manually.

    Parameters:

      -
    • string - key - key for translated string +
    • key + string + Key for translated string.
    @@ -1050,7 +1103,7 @@ You will not need to call them manually.
    - IsStringPresent(string) + IsStringPresent(key)
    Check if translated string is present. @@ -1059,9 +1112,9 @@ You will not need to call them manually.

    Parameters:

      -
    • string - key - key for translated string +
    • key + string + Key for translated string.
    @@ -1083,8 +1136,8 @@ Specify which translations in the strings table correspond to which languages.

    Parameters:

    • table - tab - array-style table with language names + table + Array-style table with language names.
    diff --git a/Documentation/doc/1 modules/Input.html b/Documentation/doc/1 modules/Input.html index 4d1f5dffc..db47196cd 100644 --- a/Documentation/doc/1 modules/Input.html +++ b/Documentation/doc/1 modules/Input.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

    - HandleEvent(name, type, activator) + HandleEvent(name, type, [activator])
    Attempt to find an event set and execute a particular event from it. @@ -298,7 +302,8 @@ MENU
  • activator Moveable - Optional activator. Default is the player object. + Optional activator. + Default: Lara.
  • @@ -368,7 +373,7 @@ MENU Lara
    - A Objects.Moveable representing Lara herself. + An Objects.Moveable entry representing Lara herself. diff --git a/Documentation/doc/1 modules/Objects.html b/Documentation/doc/1 modules/Objects.html index 032f9dc95..eee82fbf8 100644 --- a/Documentation/doc/1 modules/Objects.html +++ b/Documentation/doc/1 modules/Objects.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

      +
    • CustomBar
    • Diary
    • EventSequence
    • Timer
    • @@ -185,14 +189,14 @@
      • name string - the unique name of the Moveable as set in, or generated by, Tomb Editor + The unique name of the moveable as set in, or generated by, Tomb Editor.

      Returns:

        - Moveable + Moveable a non-owning Moveable referencing the item.
      @@ -213,15 +217,15 @@
      • name string - the unique name of the mesh as set in, or generated by, Tomb Editor + The unique name of the static mesh as set in, or generated by, Tomb Editor.

      Returns:

        - Static - a non-owning Static referencing the mesh. + Static + a non-owning Static referencing the static mesh.
      @@ -241,7 +245,7 @@
      • slot ObjID - the unique slot of the Moveable, e.g. Objects.ObjID.ANIMATING1 + The unique slot of the moveable, e.g. Objects.ObjID.ANIMATING1.
      @@ -249,7 +253,7 @@
        table - table of Moveables referencing the given slot. + Table of moveables referencing the given slot.
      @@ -269,7 +273,7 @@
      • slot int - the unique slot of the mesh like 10 + The unique numerical slot of the static mesh.
      @@ -277,7 +281,7 @@
        table - table of Statics referencing the given slot ID. + Table of static meshes referencing the given slot.
      @@ -297,7 +301,7 @@
      • tag string - to select rooms by + Tag to select rooms by.
      @@ -305,7 +309,7 @@
        table - table of Rooms containing the given tag. + Table of rooms containing the given tag.
      @@ -325,15 +329,15 @@
      • name string - the unique name of the camera as set in, or generated by, Tomb Editor + The unique name of the camera as set in, or generated by, Tomb Editor.

      Returns:

        - Camera - a non-owning Camera referencing the camera. + Camera + A non-owning Camera referencing the camera.
      @@ -353,15 +357,15 @@
      • name string - the unique name of the sink as set in, or generated by, Tomb Editor + The unique name of the sink as set in, or generated by, Tomb Editor.

      Returns:

        - Sink - a non-owning Sink referencing the sink. + Sink + A non-owning Sink referencing the sink.
      @@ -381,15 +385,15 @@
      • name string - the unique name of the sound source as set in, or generated by, Tomb Editor + The unique name of the sound source as set in, or generated by, Tomb Editor.

      Returns:

        - SoundSource - a non-owning SoundSource referencing the sound source. + SoundSource + A non-owning SoundSource referencing the sound source.
      @@ -409,15 +413,15 @@
      • name string - the unique name of the AIObject as set in, or generated by, Tomb Editor + The unique name of the AIObject as set in, or generated by, Tomb Editor.

      Returns:

        - AIObject - a non-owning SoundSource referencing the AI moveable. + AIObject + A non-owning AIObject referencing the AI object.
      @@ -437,15 +441,15 @@
      • name string - the unique name of the volume as set in, or generated by, Tomb Editor + The unique name of the volume as set in, or generated by, Tomb Editor.

      Returns:

        - Volume - a non-owning Volume referencing the room. + Volume + A non-owning Volume referencing the volume.
      @@ -465,15 +469,15 @@
      • name string - the unique name of the room as set in Tomb Editor + The unique name of the room as set in Tomb Editor.

      Returns:

        - Room - a non-owning Room referencing the room. + Room + A non-owning Room referencing the room.
      diff --git a/Documentation/doc/1 modules/Sound.html b/Documentation/doc/1 modules/Sound.html index b621dbddd..74b9aa3da 100644 --- a/Documentation/doc/1 modules/Sound.html +++ b/Documentation/doc/1 modules/Sound.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

      3 Primitive Classes

      5 Lua utility modules

        +
      • CustomBar
      • Diary
      • EventSequence
      • Timer
      • @@ -120,40 +124,40 @@

        Functions

        - - + + - + - + - + - + - - + + - - + + - - + + - - + + @@ -170,22 +174,22 @@
        - PlayAudioTrack(name, type) + PlayAudioTrack(filename, type)
        - Play an audio track + Play an audio track. Should be placed in the Audio folder. Supported formats are wav, mp3 and ogg.

        Parameters:

          -
        • name +
        • filename string - of track (without file extension) to play + Filename of a track (without file extension) to play.
        • type SoundTrackType - of the audio track to play + Type of the audio track to play.
        @@ -199,7 +203,7 @@ SetAmbientTrack(name, fromStart)
        - Set and play an ambient track + Set and play an ambient track. @@ -207,11 +211,11 @@
        • name string - of track (without file extension) to play + Name of track (without file extension) to play.
        • fromStart bool - specifies whether ambient track should play from the start, or crossfade at a random position + Specifies whether ambient track should play from the start, or crossfade at a random position.
        @@ -225,7 +229,7 @@ StopAudioTracks()
        - Stop any audio tracks currently playing + Stop any audio tracks currently playing. @@ -240,7 +244,7 @@ StopAudioTrack(type)
        - Stop audio track that is currently playing + Stop audio track that is currently playing. @@ -248,7 +252,7 @@ @@ -262,7 +266,7 @@ GetAudioTrackLoudness(type)
        - Get current loudness level for specified track type + Get current loudness level for specified track type. @@ -270,7 +274,7 @@ @@ -278,7 +282,7 @@
          float - current loudness of a specified audio track + Current loudness of a specified audio track.
        @@ -287,23 +291,23 @@
        - PlaySound(sound[, position]) + PlaySound(soundID, [position])
        - Play sound effect + Play sound effect.

        Parameters:

          -
        • sound +
        • soundID int - ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window. + Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
        • position Vec3 The 3D position of the sound, i.e. where the sound "comes from". If not given, the sound will not be positional. - (optional) + Optional.
        @@ -314,18 +318,18 @@
        - StopSound(sound) + StopSound(soundID)
        - Stop sound effect + Stop sound effect.

        Parameters:

          -
        • sound +
        • soundID int - ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window. + Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
        @@ -336,18 +340,18 @@
        - IsSoundPlaying(Sound) + IsSoundPlaying(soundID)
        - Check if the sound effect is playing + Check if the sound effect is playing.

        Parameters:

          -
        • Sound +
        • soundID int - ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window. + Sound ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
        @@ -358,18 +362,18 @@
        - IsAudioTrackPlaying(Track) + IsAudioTrackPlaying(track)
        - Check if the audio track is playing + Check if the audio track is playing.

        Parameters:

          -
        • Track +
        • track string - filename to check. Should be without extension and without full directory path. + Filename to check. Should be without extension and without full directory path.
        @@ -384,8 +388,8 @@
        Get current subtitle string for a voice track currently playing. -Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track. -Returns nil if no voice track is playing or no subtitle present. + Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track. + Returns nil if no voice track is playing or no subtitle present. @@ -394,7 +398,7 @@ Returns nil if no voice track is playing or no subtitle present.
          string - current subtitle string + Current subtitle string.
        diff --git a/Documentation/doc/1 modules/Strings.html b/Documentation/doc/1 modules/Strings.html index 519476f74..8ff839806 100644 --- a/Documentation/doc/1 modules/Strings.html +++ b/Documentation/doc/1 modules/Strings.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

        3 Primitive Classes

        5 Lua utility modules

        PlayAudioTrack(name, type)Play an audio trackPlayAudioTrack(filename, type)Play an audio track.
        SetAmbientTrack(name, fromStart)Set and play an ambient trackSet and play an ambient track.
        StopAudioTracks()Stop any audio tracks currently playingStop any audio tracks currently playing.
        StopAudioTrack(type)Stop audio track that is currently playingStop audio track that is currently playing.
        GetAudioTrackLoudness(type)Get current loudness level for specified track typeGet current loudness level for specified track type.
        PlaySound(sound[, position])Play sound effectPlaySound(soundID, [position])Play sound effect.
        StopSound(sound)Stop sound effectStopSound(soundID)Stop sound effect.
        IsSoundPlaying(Sound)Check if the sound effect is playingIsSoundPlaying(soundID)Check if the sound effect is playing.
        IsAudioTrackPlaying(Track)Check if the audio track is playingIsAudioTrackPlaying(track)Check if the audio track is playing.
        GetCurrentSubtitle()
        - + - + - +
        ShowString(str, time, autoDelete)ShowString(string, [time], [autoDelete]) Show some text on-screen.
        HideString(str)HideString(string) Hide some on-screen text.
        IsStringDisplaying(str)IsStringDisplaying(string) Checks if the string is shown
        @@ -142,7 +146,7 @@
        - ShowString(str, time, autoDelete) + ShowString(string, [time], [autoDelete])
        Show some text on-screen. @@ -151,23 +155,21 @@

        Parameters:

          -
        • str +
        • string DisplayString - the string object to draw + The string object to draw.
        • time float - the time in seconds for which to show the string. -If not given, the string will have an "infinite" life, and will show + The time in seconds for which to show the string. If not given, the string will have an "infinite" life, and will show until HideString is called or until the level is finished. -Default: nil (i.e. infinite) + Optional.
        • autoDelete bool - should be string automatically deleted after timeout is reached. -If not given, the string will remain allocated even after timeout is reached, and can be -shown again without re-initialization. -Default: true + Should be string automatically deleted after timeout is reached. If not given, the string will remain +allocated even after timeout is reached, and can be shown again without re-initialization. + Default: true.
        @@ -178,7 +180,7 @@ Default: true
        - HideString(str) + HideString(string)
        Hide some on-screen text. @@ -187,10 +189,9 @@ Default: true

        Parameters:

          -
        • str +
        • string DisplayString - the string object to hide. Must previously have been shown -with a call to ShowString, or this function will have no effect. + The string object to hide. Must previously have been shown with a call to ShowString, or this function will have no effect.
        @@ -201,7 +202,7 @@ with a call to ShowString, or
        - IsStringDisplaying(str) + IsStringDisplaying(string)
        Checks if the string is shown @@ -210,9 +211,9 @@ with a call to ShowString, or

        Parameters:

          -
        • str +
        • string DisplayString - the string object to be checked + The string object to be checked.
        diff --git a/Documentation/doc/1 modules/Util.html b/Documentation/doc/1 modules/Util.html index caf818c90..1955d8d41 100644 --- a/Documentation/doc/1 modules/Util.html +++ b/Documentation/doc/1 modules/Util.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

        3 Primitive Classes

        5 Lua utility modules

        @@ -382,7 +385,7 @@ To be used with - PickStaticByDisplayPosition(Display) + PickStaticByDisplayPosition(position)
        Pick a static mesh by the given display position. @@ -391,9 +394,9 @@ To be used with Display +
      • position Vec2 - space position in percent. + Display space position in percent.
      @@ -410,7 +413,7 @@ To be used with - PrintLog(message, logLevel[, allowSpam]) + PrintLog(Message, logLevel, [allowSpam])
      Write messages within the Log file @@ -424,18 +427,18 @@ To be used with message +
    • Message string - to be displayed within the Log + to be displayed within the log.
    • logLevel LogLevel - log level to be displayed + Log level to be displayed.
    • allowSpam bool - true allows spamming of the message - (optional) + If true, allows continuous spamming of the message. + Optional.
    diff --git a/Documentation/doc/1 modules/View.html b/Documentation/doc/1 modules/View.html index ece60eef2..f30980297 100644 --- a/Documentation/doc/1 modules/View.html +++ b/Documentation/doc/1 modules/View.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

      +
    • CustomBar
    • Diary
    • EventSequence
    • Timer
    • @@ -120,15 +124,15 @@

      Functions

      - + - + - + @@ -160,7 +164,7 @@ - + @@ -168,15 +172,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -184,7 +212,7 @@ - + @@ -202,7 +230,7 @@
      - FadeIn(speed) + FadeIn([speed])
      Do a full-screen fade-in from black. @@ -213,7 +241,8 @@
      • speed float - (default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second. + Speed in units per second. A value of 1 will make the fade take one second. + Default: 1.
      @@ -224,7 +253,7 @@
      - FadeOut(speed) + FadeOut([speed])
      Do a full-screen fade-to-black. The screen will remain black until a call to FadeIn. @@ -235,7 +264,8 @@
      • speed float - (default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second. + Speed in units per second. A value of 1 will make the fade take one second. + Default: 1.
      @@ -246,7 +276,7 @@
      - SetCineBars(height, speed) + SetCineBars([height], [speed])
      Move black cinematic bars in from the top and bottom of the game window. @@ -257,11 +287,13 @@
      • height float - (default 30) Percentage of the screen to be covered + Percentage of the screen to be covered. + Default: 30.
      • speed float - (default 30) Coverage percent per second + Coverage percent per second. + Default: 30.
      @@ -283,7 +315,7 @@
      • angle float - in degrees (clamped to [10, 170]) + Angle in degrees (clamped to [10, 170]).
      @@ -306,7 +338,7 @@
        float - current FOV angle in degrees + Current FOV angle in degrees.
      @@ -327,7 +359,7 @@
        CameraType - value used by the Main Camera. + Value used by the game camera.
      @@ -356,7 +388,7 @@
        Vec3 - current camera position + Current camera position.
      @@ -377,7 +409,7 @@
        Vec3 - current camera target + Current camera target.
      @@ -398,7 +430,7 @@
        Room - current room of the camera + Current room of the camera.
      @@ -418,7 +450,7 @@ @@ -429,7 +461,7 @@
      - SetPostProcessStrength(strength) + SetPostProcessStrength([strength])
      Sets the post-process effect strength. @@ -440,7 +472,8 @@
      • strength float - (default 1.0). How strong the effect is. + How strong the effect is. + Default: 1.
      @@ -470,6 +503,152 @@ +
      +
      + + PlayVideo(fileName, [background], [silent], [loop]) +
      +
      + Play a video file. File should be placed in the FMV folder. + + + +

      Parameters:

      +
        +
      • fileName + string + Video file name. Can be provided without extension, if type is mp4, mkv, mov or avi. +
      • +
      • background + bool + Play video in the background mode. + In such case, video won't play in fullscreen, but must be shown using special animated texture type in Tomb Editor, or using View.DisplaySprite. + Default: false. +
      • +
      • silent + bool + Play video without sound. + Default: false. +
      • +
      • loop + bool + Play video in a loop. + Default: false. +
      • +
      + + + + + +
      +
      + + StopVideo() +
      +
      + Stop the currently playing video. Only possible if video is playing in the background mode. + + + + + + + + +
      +
      + + GetVideoPosition() +
      +
      + Gets the currently playing video position. + + + + +

      Returns:

      +
        + + Time + Current video position. +
      + + + + +
      +
      + + SetVideoPosition(position) +
      +
      + Sets the currently playing video position. + + + +

      Parameters:

      +
        +
      • position + Time + New video position. +
      • +
      + + + + + +
      +
      + + GetVideoDominantColor() +
      +
      + Gets the dominant color for the current video frame. If no video is playing, returns black. + + + + +

      Returns:

      +
        + + Color + Dominant video color. +
      + + + + +
      +
      + + IsVideoPlaying([name]) +
      +
      + Checks if video is currently playing. + + + +

      Parameters:

      +
        +
      • name + string + Video file name. If provided, checks if the currently playing video file name is the same as the provided one. + Optional. +
      • +
      + +

      Returns:

      +
        + + bool + True if video is currently playing. +
      + + + +
      @@ -495,7 +674,7 @@
      - GetFlybyPosition(seqID, progress) + GetFlybyPosition(seqID, progress, [loop])
      Get a flyby sequence's position at a specified progress point in percent. @@ -512,6 +691,11 @@ float Progress point in percent. Clamped to [0, 100]. +
    • loop + bool + Smooth the position near start and end points, as if the sequence is looped. + Optional. +
    • Returns:

      @@ -527,7 +711,7 @@
      - GetFlybyRotation(seqID, progress) + GetFlybyRotation(seqID, progress, [loop])
      Get a flyby sequence's rotation at a specified progress point in percent. @@ -544,6 +728,11 @@ float Progress point in percent. Clamped to [0, 100]. +
    • loop + bool + Smooth the position near start and end points, as if the sequence is looped. + Optional. +
    • Returns:

      @@ -574,7 +763,7 @@
      - FlashScreen(color, speed) + FlashScreen([color], [speed])
      Flash screen. @@ -585,11 +774,13 @@
      • color Color - (default Color(255, 255, 255)) + Color. + Default: Color(255, 255, 255).
      • speed float - (default 1.0). Speed in "amount" per second. Value of 1 will make flash take one second. Clamped to [0.005, 1.0]. + Speed in units per second. Value of 1 will make flash take one second. Clamped to [0.005, 1.0]. + Default: 1.
      diff --git a/Documentation/doc/2 classes/Collision.Probe.html b/Documentation/doc/2 classes/Collision.Probe.html index e6fc8bf34..662726038 100644 --- a/Documentation/doc/2 classes/Collision.Probe.html +++ b/Documentation/doc/2 classes/Collision.Probe.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

      3 Primitive Classes

      5 Lua utility modules

      FadeIn(speed)FadeIn([speed]) Do a full-screen fade-in from black.
      FadeOut(speed)FadeOut([speed]) Do a full-screen fade-to-black.
      SetCineBars(height, speed)SetCineBars([height], [speed]) Move black cinematic bars in from the top and bottom of the game window.
      Sets the post-process effect mode, like negative or monochrome.
      SetPostProcessStrength(strength)SetPostProcessStrength([strength]) Sets the post-process effect strength.
      Sets the post-process tint.
      PlayVideo(fileName, [background], [silent], [loop])Play a video file.
      StopVideo()Stop the currently playing video.
      GetVideoPosition()Gets the currently playing video position.
      SetVideoPosition(position)Sets the currently playing video position.
      GetVideoDominantColor()Gets the dominant color for the current video frame.
      IsVideoPlaying([name])Checks if video is currently playing.
      PlayFlyby(seqID) Play a flyby sequence.
      GetFlybyPosition(seqID, progress)GetFlybyPosition(seqID, progress, [loop]) Get a flyby sequence's position at a specified progress point in percent.
      GetFlybyRotation(seqID, progress)GetFlybyRotation(seqID, progress, [loop]) Get a flyby sequence's rotation at a specified progress point in percent.
      Reset object camera back to Lara and deactivate object camera.
      FlashScreen(color, speed)FlashScreen([color], [speed]) Flash screen.
      - + - + - - + + - - + + + + + + + + + + @@ -177,11 +187,11 @@ - + - + @@ -189,11 +199,15 @@ - + - + + + + +
      Probe(pos, roomNumber)Probe(pos, [roomNumber]) Create a Probe at a specified world position in a room.
      Probe(pos, originRoomNumber, dir, dist)Probe(pos, roomNumber, dir, dist) Create a Probe that casts from an origin world position in a room in a given direction for a specified distance.
      Probe(Origin, originRoomNumber, rot, dist)Create a Probe that casts from an origin world position in a room in the direction of a given Rotation for a specified distance.Probe(pos, roomNumber, rot, dist)Create a Probe that casts from an origin world position in a room in the direction of a given rotation for a specified distance.
      Probe(Origin, originRoomNumber, rot, relOffset)Create a Probe that casts from an origin world position, where a given relative offset is rotated according to a given Rotation.Probe(pos, roomNumber, rot, relOffset)Create a Probe that casts from an origin world position, where a given relative offset is rotated according to a given rotation.
      GetPosition() Get the world position of this Probe.
      GetRoom()Get the Room object of this Probe.
      GetRoomName()Get the room name of this Probe.
      GetFloorHeight() Get the floor height at this Probe.
      IsWall()Check if there is a wall at this Probe.Check if the Probe is inside a wall.
      IsInsideSolidGeometry()Check if this Probe is inside solid geometry, i.e.Check if this Probe is inside solid geometry (below a floor, above a ceiling, inside a bridge, or inside a wall).
      IsClimbableWall(headingAngle)
      IsMonkeySwing()Check if there is a monkey swing at this Probe.Check if there is a monkey swing sector at this Probe.
      IsDeath()Check if there is a death tile at this Probe.Check if there is a death sector at this Probe.
      Preview()Preview this Probe in the Collision Stats debug page.
      @@ -206,7 +220,7 @@
      - Probe(pos, roomNumber) + Probe(pos, [roomNumber])
      Create a Probe at a specified world position in a room. @@ -221,7 +235,8 @@
    • roomNumber int - Room number. + Room number. Must be used if probing a position in an overlapping room. + Optional.
    @@ -229,7 +244,7 @@
      Probe - a new Probe. + A new Probe.
    @@ -238,7 +253,7 @@
    - Probe(pos, originRoomNumber, dir, dist) + Probe(pos, roomNumber, dir, dist)
    Create a Probe that casts from an origin world position in a room in a given direction for a specified distance. @@ -252,9 +267,9 @@ Vec3 Origin world position to cast from. -
  • originRoomNumber +
  • roomNumber int - Origin's room number. + Origin room number.
  • dir Vec3 @@ -270,7 +285,7 @@
      Probe - a new Probe. + A new Probe.
    @@ -279,23 +294,23 @@
  • - Probe(Origin, originRoomNumber, rot, dist) + Probe(pos, roomNumber, rot, dist)
    - Create a Probe that casts from an origin world position in a room in the direction of a given Rotation for a specified distance. + Create a Probe that casts from an origin world position in a room in the direction of a given rotation for a specified distance. Required to correctly traverse between rooms.

    Parameters:

      -
    • Origin +
    • pos Vec3 - world position to cast from. + Origin world position to cast from.
    • -
    • originRoomNumber +
    • roomNumber int - Origin's room number. + Origin room number.
    • rot Rotation @@ -311,7 +326,7 @@
        Probe - a new Probe. + A new Probe.
      @@ -320,23 +335,23 @@
    - Probe(Origin, originRoomNumber, rot, relOffset) + Probe(pos, roomNumber, rot, relOffset)
    - Create a Probe that casts from an origin world position, where a given relative offset is rotated according to a given Rotation. + Create a Probe that casts from an origin world position, where a given relative offset is rotated according to a given rotation. Required to correctly traverse between rooms.

    Parameters:

      -
    • Origin +
    • pos Vec3 - world position to cast from. + Origin world position to cast from.
    • -
    • originRoomNumber +
    • roomNumber int - Origin's room number. + Origin room number.
    • rot Rotation @@ -352,7 +367,7 @@
        Probe - a new Probe. + A new Probe.
      @@ -379,6 +394,48 @@ +
    +
    + + GetRoom() +
    +
    + Get the Room object of this Probe. + + + + +

    Returns:

    +
      + + Room + Room object. +
    + + + + +
    +
    + + GetRoomName() +
    +
    + Get the room name of this Probe. + + + + +

    Returns:

    +
      + + string + Room name. +
    + + + +
    @@ -393,8 +450,8 @@

    Returns:

      - int[opt] - Floor height. nil: no floor exists. + int + Floor height. nil: no floor exists
    @@ -414,8 +471,8 @@

    Returns:

      - int[opt] - Ceiling height. nil: no ceiling exists. + int + Ceiling height. nil: no ceiling exists
    @@ -435,8 +492,8 @@

    Returns:

      - int[opt] - Water surface height. nil: no water surface exists. + int + Water surface height. nil: no water surface exists
    @@ -456,8 +513,8 @@

    Returns:

      - Vec3[opt] - Floor normal. nil: no floor exists. + Vec3 + Floor normal. nil: no floor exists
    @@ -477,8 +534,8 @@

    Returns:

      - Vec3[opt] - Ceiling normal. nil: no ceiling exists. + Vec3 + Ceiling normal. nil: no ceiling exists
    @@ -498,8 +555,8 @@

    Returns:

      - Collision.MaterialType[opt] - Floor material type. nil: no floor exists. + MaterialType + Floor material type. nil: no floor exists
    @@ -519,8 +576,8 @@

    Returns:

      - Collision.MaterialType[opt] - Ceiling material type. nil: no ceiling exists. + MaterialType + Ceiling material type. nil: no ceiling exists
    @@ -540,8 +597,8 @@

    Returns:

      - bool[opt] - Steep floor status. true: is a steep floor, false: isn't a steep floor, nil: no floor exists. + bool + Steep floor status. true: is a steep floor, false: isn't a steep floor, nil: no floor exists
    @@ -561,8 +618,8 @@

    Returns:

      - bool[opt] - Steep ceiling status. true: is a steep ceiling, false: isn't a steep ceiling, nil: no ceiling exists. + bool + Steep ceiling status. true: is a steep ceiling, false: isn't a steep ceiling, nil: no ceiling exists
    @@ -574,7 +631,7 @@ IsWall()
    - Check if there is a wall at this Probe. Can be used to determine if a wall and ceiling exist. + Check if the Probe is inside a wall. Can be used to determine if a wall and ceiling exist. @@ -595,7 +652,7 @@ IsInsideSolidGeometry()
    - Check if this Probe is inside solid geometry, i.e. below a floor, above a ceiling, or inside a wall. + Check if this Probe is inside solid geometry (below a floor, above a ceiling, inside a bridge, or inside a wall). @@ -632,7 +689,7 @@
      bool - Climbable wall status. true: is climbable, false: isn't climbable + Climbable wall status. true: is climbable wall, false: isn't climbable
    @@ -644,7 +701,7 @@ IsMonkeySwing()
    - Check if there is a monkey swing at this Probe. + Check if there is a monkey swing sector at this Probe. @@ -653,7 +710,7 @@
      bool - Monkey swing status. true: is a monkey swing, false: isn't a monkey swing + Monkey swing sector status. true: is a monkey swing, false: isn't a monkey swing
    @@ -665,7 +722,7 @@ IsDeath()
    - Check if there is a death tile at this Probe. + Check if there is a death sector at this Probe. @@ -674,12 +731,27 @@
      bool - Death tile status. true: is a death tile, false: isn't a death tile + Death sector status. true: is a death sector, false: isn't a death sector
    +
    +
    + + Preview() +
    +
    + Preview this Probe in the Collision Stats debug page. + + + + + + + +
    diff --git a/Documentation/doc/2 classes/Flow.Level.html b/Documentation/doc/2 classes/Flow.Level.html index 8f69753ca..f37dc3fb6 100644 --- a/Documentation/doc/2 classes/Flow.Level.html +++ b/Documentation/doc/2 classes/Flow.Level.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

    @@ -1479,7 +1512,7 @@ sas:SetAIBits({1, 0,
  • frame int - the new frame number + The new frame number.
  • @@ -1515,7 +1548,7 @@ sas:SetAIBits({1, 0, Moveable:GetActive()
    - Determine whether the moveable is active or not + Determine whether the moveable is active or not. @@ -1524,7 +1557,7 @@ sas:SetAIBits({1, 0, bool - true if the moveable is active + True if the moveable is active. @@ -1545,7 +1578,7 @@ sas:SetAIBits({1, 0, bool - true if the moveable was hit by something in the last gameplay frame, false otherwise + true if the moveable was hit by something in the last gameplay frame, false otherwise. @@ -1557,7 +1590,7 @@ sas:SetAIBits({1, 0, Moveable:GetRoom()
    - Get the current room of the object + Get the current room of the moveable. @@ -1566,7 +1599,7 @@ sas:SetAIBits({1, 0, Room - current room of the object + Current room of the moveable. @@ -1578,7 +1611,7 @@ sas:SetAIBits({1, 0, Moveable:GetRoomNumber()
    - Get the current room number of the object + Get the current room number of the moveable. @@ -1587,7 +1620,7 @@ sas:SetAIBits({1, 0, int - number representing the current room of the object + Number representing the current room of the moveable. @@ -1628,7 +1661,7 @@ sas:SetPosition(newPos, false) Moveable:GetStatus()
    - Get the moveable's status. () + Get the moveable's status. @@ -1649,7 +1682,7 @@ sas:SetPosition(newPos, false) Moveable:SetStatus(status)
    - Set the moveable's status. () + Set the moveable's status. @@ -1671,7 +1704,7 @@ sas:SetPosition(newPos, false) Moveable:GetMeshCount()
    - Get number of meshes for a particular object + Get number of meshes for a particular object. Returns number of meshes in an object @@ -1681,7 +1714,7 @@ sas:SetPosition(newPos, false)
      int - number of meshes + Number of meshes.
    @@ -1693,7 +1726,7 @@ sas:SetPosition(newPos, false) Moveable:GetMeshVisible(index)
    - Get state of specified mesh visibility of object + Get state of specified mesh visibility of object. Returns true if specified mesh is visible on an object, and false if it is not visible. @@ -1703,7 +1736,7 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh + Index of a mesh.
    @@ -1711,7 +1744,7 @@ sas:SetPosition(newPos, false)
      bool - visibility status + Visibility status.
    @@ -1723,7 +1756,7 @@ sas:SetPosition(newPos, false) Moveable:SetMeshVisible(index, isVisible)
    - Makes specified mesh visible or invisible + Makes specified mesh visible or invisible. Use this to show or hide a specified mesh of an object. @@ -1732,11 +1765,11 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh + Index of a mesh.
    • isVisible bool - true if you want the mesh to be visible, false otherwise + true if you want the mesh to be visible, false otherwise.
    @@ -1750,7 +1783,7 @@ sas:SetPosition(newPos, false) Moveable:ShatterMesh(index)
    - Shatters specified mesh and makes it invisible + Shatters specified mesh and makes it invisible. Note that you can re-enable mesh later by using SetMeshVisible(). @@ -1759,7 +1792,7 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh + Index of a mesh to shatter.
    @@ -1773,9 +1806,8 @@ sas:SetPosition(newPos, false) Moveable:GetMeshSwapped(index)
    - Get state of specified mesh swap of object - Returns true if specified mesh is swapped on an object, and false - if it is not swapped. + Get state of specified mesh swap of object. + Returns true if specified mesh is swapped on an object, and false if it is not swapped. @@ -1783,7 +1815,7 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh + Index of a mesh.
    @@ -1791,7 +1823,7 @@ sas:SetPosition(newPos, false)
      bool - mesh swap status + Mesh swap status.
    @@ -1800,10 +1832,10 @@ sas:SetPosition(newPos, false)
    - Moveable:SwapMesh(index, slotIndex[, swapIndex]) + Moveable:SwapMesh(index, slotIndex, [swapIndex])
    - Set state of specified mesh swap of object + Set state of specified mesh swap of object. Use this to swap specified mesh of an object. @@ -1812,16 +1844,16 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh + Index of a mesh.
    • slotIndex int - index of a slot to get meshswap from + Index of a slot to get meshswap from.
    • swapIndex int - index of a mesh from meshswap slot to use - (optional) + Index of a mesh from meshswap slot to use. + Optional.
    @@ -1835,7 +1867,7 @@ sas:SetPosition(newPos, false) Moveable:UnswapMesh(index)
    - Set state of specified mesh swap of object + Set state of specified mesh swap of object. Use this to bring back original unswapped mesh @@ -1844,7 +1876,7 @@ sas:SetPosition(newPos, false)
    • index int - index of a mesh to unswap + Index of a mesh to unswap.
    @@ -1855,7 +1887,7 @@ sas:SetPosition(newPos, false)
    - Moveable:Enable(timeout) + Moveable:Enable([timeout])
    Enable the item, as if a trigger for it had been stepped on. @@ -1866,7 +1898,8 @@ sas:SetPosition(newPos, false)
    • timeout float - time (in seconds) after which moveable automatically disables (optional). + Time (in seconds) after which moveable automatically disables. + Optional.
    @@ -1880,8 +1913,8 @@ sas:SetPosition(newPos, false) Moveable:Disable()
    - Disable the item, as if an antitrigger for it had been stepped on (i.e. it will close an open door or extinguish a flame emitter). - Note that this will not trigger an OnKilled callback. + Disable the item, as if an antitrigger for it had been stepped on. + For example, it will close an open door or extinguish a flame emitter. Note that this will not trigger an OnKilled callback. @@ -1935,7 +1968,7 @@ sas:SetPosition(newPos, false)
      bool - item's collision state + Item's collision state.
    @@ -1963,28 +1996,13 @@ sas:SetPosition(newPos, false) -
    -
    - - Moveable:MakeInvisible() -
    -
    - Make the item invisible. Alias for Moveable:SetVisible(false). - - - - - - - -
    Moveable:SetVisible(visible)
    - Set the item's visibility. An invisible item will have collision turned off, as if it no longer exists in the game world. + Set the item's visibility. An invisible item will have collision turned off, as if it no longer exists in the game world. @@ -1992,7 +2010,7 @@ sas:SetPosition(newPos, false)
    • visible bool - true if the caller should become visible, false if it should become invisible + true if the caller should become visible, false if it should become invisible.
    @@ -2006,7 +2024,7 @@ sas:SetPosition(newPos, false) Moveable:GetValid()
    - Test if the object is in a valid state (i.e. has not been destroyed through Lua or killed by Lara). + Test if the object is in a valid state. Indicates that it has not been destroyed through Lua or killed by Lara. @@ -2015,7 +2033,7 @@ sas:SetPosition(newPos, false)
      bool - valid true if the object is still not destroyed + true if the object is still not destroyed.
    @@ -2050,15 +2068,15 @@ sas:SetPosition(newPos, false)
    • mesh int - of a target moveable to use as a camera target + Mesh of a target moveable to use as a camera target.
    • target - Moveable - moveable to attach camera to + Moveable + Target moveable to attach camera to.
    • mesh int - of a target moveable to use as a camera target + Mesh of a target moveable to use as a camera target.
    @@ -2069,26 +2087,26 @@ sas:SetPosition(newPos, false)
    - Moveable:AnimFromObject(ObjectID, animNumber, stateID) + Moveable:AnimFromObject(objectID, animNumber, stateID)
    - Borrow animation from an object + Borrow animation from an object.

    Parameters:

      -
    • ObjectID +
    • objectID ObjID - to take animation and stateID from, + Object ID to take animation and state ID from.
    • animNumber int - animation from object + Animation from object.
    • stateID int - state from object + State from object.
    diff --git a/Documentation/doc/2 classes/Objects.Room.html b/Documentation/doc/2 classes/Objects.Room.html index d9588a12a..d99e4cbf6 100644 --- a/Documentation/doc/2 classes/Objects.Room.html +++ b/Documentation/doc/2 classes/Objects.Room.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

      +
    • CustomBar
    • Diary
    • EventSequence
    • Timer
    • @@ -140,11 +144,11 @@ Set the room's unique string identifier. - Room:SetReverbType(Reverb) + Room:SetReverbType(reverb) Set the room's reverb type. - Room:SetFlag(flagID, Boolean) + Room:SetFlag(flagID, value) Set the room's specified flag. @@ -173,7 +177,7 @@ Room:GetRoomNumber()
      - Get the room's number. () + Get the room's number. @@ -194,7 +198,7 @@ Room:GetName()
      - Get the room's unique string identifier. () + Get the room's unique string identifier. @@ -215,7 +219,7 @@ Room:GetColor()
      - Get the room's ambient light color. () + Get the room's ambient light color. @@ -236,7 +240,7 @@ Room:GetReverbType()
      - Get the room's reverb type. () + Get the room's reverb type. @@ -257,7 +261,7 @@ Room:SetName(name)
      - Set the room's unique string identifier. () + Set the room's unique string identifier. @@ -276,18 +280,18 @@
      - Room:SetReverbType(Reverb) + Room:SetReverbType(reverb)
      - Set the room's reverb type. () + Set the room's reverb type.

      Parameters:

        -
      • Reverb +
      • reverb RoomReverb - type. + Reverb type.
      @@ -298,10 +302,10 @@
      - Room:SetFlag(flagID, Boolean) + Room:SetFlag(flagID, value)
      - Set the room's specified flag. () + Set the room's specified flag. @@ -311,9 +315,9 @@ RoomFlagID Room flag ID. -
    • Boolean +
    • value bool - to set the flag to. + Boolean to set the flag to.
    @@ -327,7 +331,7 @@ Room:GetFlag(flagID)
    - Get the room's specified flag value (true or false). () + Get the room's specified flag value (true or false). @@ -349,7 +353,7 @@ Room:IsTagPresent(tag)
    - Check if the specified tag is set for the room. () + Check if the specified tag is set for the room. @@ -377,7 +381,7 @@ Room:GetActive()
    - Check if the room is active. () + Check if the room is active. diff --git a/Documentation/doc/2 classes/Objects.Sink.html b/Documentation/doc/2 classes/Objects.Sink.html index 9ec996ac9..67e467d19 100644 --- a/Documentation/doc/2 classes/Objects.Sink.html +++ b/Documentation/doc/2 classes/Objects.Sink.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

      +
    • CustomBar
    • Diary
    • EventSequence
    • Timer
    • diff --git a/Documentation/doc/2 classes/Objects.SoundSource.html b/Documentation/doc/2 classes/Objects.SoundSource.html index 34d46d407..1ff54349a 100644 --- a/Documentation/doc/2 classes/Objects.SoundSource.html +++ b/Documentation/doc/2 classes/Objects.SoundSource.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

      3 Primitive Classes

      5 Lua utility modules

        +
      • CustomBar
      • Diary
      • EventSequence
      • Timer
      • @@ -121,28 +125,27 @@ - + - + - + - + - + - +
        SoundSource:GetPosition()Get the sound source's positionGet the sound source's position.
        SoundSource:SetPosition(position)Set the sound source's positionSet the sound source's position.
        SoundSource:GetName()Get the sound source's unique string identifierGet the sound source's unique string identifier.
        SoundSource:SetName(name)Set the sound source's name (its unique string identifier)Set the sound source's unique string identifier.
        SoundSource:GetSoundID()Get the sound source's unique int identifierGet the sound source's sound ID.
        SoundSource:SetSoundID(name)Set the sound source's ID - TODO this and getSoundID should use enumsSet the sound source's ID.
        @@ -158,7 +161,7 @@ SoundSource:GetPosition()
        - Get the sound source's position + Get the sound source's position. @@ -167,7 +170,7 @@
          Vec3 - a copy of the sound source's position + Sound source's position.
        @@ -179,7 +182,7 @@ SoundSource:SetPosition(position)
        - Set the sound source's position + Set the sound source's position. @@ -187,7 +190,7 @@
        • position Vec3 - the new position of the sound source + The new position of the sound source.
        @@ -201,7 +204,7 @@ SoundSource:GetName()
        - Get the sound source's unique string identifier + Get the sound source's unique string identifier. @@ -210,7 +213,7 @@
          string - the sound source's name + The sound source's name.
        @@ -222,7 +225,7 @@ SoundSource:SetName(name)
        - Set the sound source's name (its unique string identifier) + Set the sound source's unique string identifier. @@ -230,7 +233,7 @@
        • name string - The sound source's new name + The sound source's new name.
        @@ -244,7 +247,7 @@ SoundSource:GetSoundID()
        - Get the sound source's unique int identifier + Get the sound source's sound ID. @@ -253,7 +256,7 @@
          int - the ID of the sound + The ID of the sound.
        @@ -265,8 +268,7 @@ SoundSource:SetSoundID(name)
        - Set the sound source's ID - TODO this and getSoundID should use enums + Set the sound source's ID. @@ -274,7 +276,7 @@
        • name int - The sound source's new name + The sound source's new sound ID.
        diff --git a/Documentation/doc/2 classes/Objects.Static.html b/Documentation/doc/2 classes/Objects.Static.html index 11a877ac2..0ad8251f4 100644 --- a/Documentation/doc/2 classes/Objects.Static.html +++ b/Documentation/doc/2 classes/Objects.Static.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

        3 Primitive Classes

        5 Lua utility modules

        +
        + + Static:GetCollidable() +
        +
        + Get this static's collision status. + + + + +

        Returns:

        +
          + + bool + Collision status. true if can be collided with, false otherwise.
        @@ -390,7 +423,7 @@
          bool - Solid Status. true: solid, false: soft + Solid Status. true if solid, false if soft.
        @@ -564,7 +597,29 @@
        • status bool - New status. true: solid, false: soft + New status, true is solid, false is soft. +
        • +
        + + + + + +
        +
        + + Static:SetCollidable(collidable) +
        +
        + Set this static's collision status. + + + +

        Parameters:

        +
          +
        • collidable + bool + New collision status. true if can be collided with, false: no collision.
        diff --git a/Documentation/doc/2 classes/Objects.Volume.html b/Documentation/doc/2 classes/Objects.Volume.html index fad783f63..0a3c41b06 100644 --- a/Documentation/doc/2 classes/Objects.Volume.html +++ b/Documentation/doc/2 classes/Objects.Volume.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

        3 Primitive Classes

        5 Lua utility modules

          +
        • CustomBar
        • Diary
        • EventSequence
        • Timer
        • @@ -156,7 +160,7 @@ Determine if this volume is active. - Volume:IsMoveableInside(Moveable) + Volume:IsMoveableInside(moveable) Determine if a moveable is inside this volume. @@ -185,7 +189,7 @@ Volume:GetName()
          - Get the unique string identifier of this volume. () + Get the unique string identifier of this volume. @@ -206,7 +210,7 @@ Volume:GetPosition()
          - Get the position of this volume. () + Get the position of this volume. @@ -227,7 +231,7 @@ Volume:GetRotation()
          - Get the rotation of this volume. () + Get the rotation of this volume. @@ -248,7 +252,7 @@ Volume:GetScale()
          - Get this scale of this volume. () + Get this scale of this volume. @@ -269,7 +273,7 @@ Volume:SetName(name)
          - Set the unique string identifier of this volume. () + Set the unique string identifier of this volume. @@ -291,7 +295,7 @@ Volume:SetPosition(pos)
          - Set the position of this volume. () + Set the position of this volume. @@ -313,7 +317,7 @@ Volume:SetRotation(rot)
          - Set the rotation of this volume. () + Set the rotation of this volume. @@ -335,7 +339,7 @@ Volume:SetScale(scale)
          - Set the scale of the volume. () + Set the scale of the volume. @@ -357,7 +361,7 @@ Volume:GetActive()
          - Determine if this volume is active. () + Determine if this volume is active. @@ -375,18 +379,18 @@
          - Volume:IsMoveableInside(Moveable) + Volume:IsMoveableInside(moveable)
          - Determine if a moveable is inside this volume. () + Determine if a moveable is inside this volume.

          Parameters:

            -
          • Moveable +
          • moveable Moveable - to be checked for containment. + Moveable to be checked for containment.
          @@ -406,7 +410,7 @@ Volume:Enable()
          - Enable this volume. () + Enable this volume. @@ -421,7 +425,7 @@ Volume:Disable()
          - Disable this volume. () + Disable this volume. @@ -436,7 +440,7 @@ Volume:ClearActivators()
          - Clear the activators for this volume, allowing it to trigger again. () + Clear the activators for this volume, allowing it to trigger again. diff --git a/Documentation/doc/2 classes/Strings.DisplayString.html b/Documentation/doc/2 classes/Strings.DisplayString.html index c4c42536d..958d506a8 100644 --- a/Documentation/doc/2 classes/Strings.DisplayString.html +++ b/Documentation/doc/2 classes/Strings.DisplayString.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

          3 Primitive Classes

          5 Lua utility modules

            +
          • CustomBar
          • Diary
          • EventSequence
          • Timer
          • @@ -125,23 +129,23 @@ when you need to use screen-space coordinates.

            Functions

            - + - + - + - + - + @@ -162,11 +166,7 @@ when you need to use screen-space coordinates.

            - - - - - +
            DisplayString(string, Position[, scale][, color][, translated], table)DisplayString(string, position, [scale], [color], [translated], [flags]) Create a DisplayString.
            DisplayString:GetColor()Get the display string's colorGet the display string's color.
            DisplayString:SetColor(color)Set the display string's colorSet the display string's color.
            DisplayString:GetKey()Get the string key to use.Get the string key.
            DisplayString:SetKey(string)DisplayString:SetKey(key) Set the string key to use.
            DisplayString:SetFlags(table)Set the display string's flags
            DisplayString:SetTranslated(shouldTranslate)Set translated parameter of the stringSet the display string's flags.
            @@ -179,7 +179,7 @@ when you need to use screen-space coordinates.

            - DisplayString(string, Position[, scale][, color][, translated], table) + DisplayString(string, position, [scale], [color], [translated], [flags])
            Create a DisplayString. @@ -193,29 +193,30 @@ For use in ShowString and string The string to display or key of the translated string. -
          • Position +
          • position Vec2 - of the string in pixel coordinates. + Position of the string in pixel coordinates.
          • scale float - size of the string, relative to the default size. Default: 1.0 - (optional) + Size of the string, relative to the default size. + Default: 1.
          • color Color - the color of the text. Default: white - (optional) + The color of the text. + Default: Color(255, 255, 255).
          • translated bool If false or omitted, the input string argument will be displayed. -If true, the string argument will be the key of a translated string specified in strings.lua. Default: false. - (optional) +If true, the string argument will be the key of a translated string specified in strings.lua. + Default: false.
          • -
          • table +
          • flags DisplayStringOption - Default: None. Please note that Strings are automatically aligned to the LEFT + Flags which affect visual representation of a string, such as shadow or alignment. + Optional.
          @@ -235,7 +236,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:GetColor()
          - Get the display string's color + Get the display string's color. @@ -244,7 +245,7 @@ If true, the string argument will be the key of a translated string specified in
            Color - a copy of the display string's color + Display string's color.
          @@ -256,7 +257,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:SetColor(color)
          - Set the display string's color + Set the display string's color. @@ -264,7 +265,7 @@ If true, the string argument will be the key of a translated string specified in
          • color Color - the new color of the display string + The new color of the display string.
          @@ -278,9 +279,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:GetKey()
          - Get the string key to use. If isTranslated is true when DisplayString - is called, this will be the string key for the translation that will be displayed. - If false or omitted, this will be the string that's displayed.() + Get the string key. @@ -289,7 +288,7 @@ If true, the string argument will be the key of a translated string specified in
            string - the string to use + The string key.
          @@ -298,20 +297,18 @@ If true, the string argument will be the key of a translated string specified in
          - DisplayString:SetKey(string) + DisplayString:SetKey(key)
          - Set the string key to use. If isTranslated is true when DisplayString - is called, this will be the string key for the translation that will be displayed. - If false or omitted, this will be the string that's displayed.() + Set the string key to use.

          Parameters:

            -
          • string +
          • key string - the new key for the display string + The new key for the display string.
          @@ -325,7 +322,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:SetScale(scale)
          - Set the scale of the string. () + Set the scale of the string. @@ -347,7 +344,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:GetScale()
          - Get the scale of the string. () + Get the scale of the string. @@ -369,7 +366,7 @@ If true, the string argument will be the key of a translated string specified in
          Set the position of the string. - Screen-space coordinates are expected.() + Screen-space coordinates are expected. @@ -392,7 +389,7 @@ If true, the string argument will be the key of a translated string specified in
          Get the position of the string. - Screen-space coordinates are returned.() + Screen-space coordinates are returned. @@ -413,7 +410,7 @@ If true, the string argument will be the key of a translated string specified in DisplayString:SetFlags(table)
          - Set the display string's flags () + Set the display string's flags. @@ -421,7 +418,7 @@ If true, the string argument will be the key of a translated string specified in
          • table table - the new table with display flags options + The new table with display flags options.
          @@ -440,29 +437,6 @@ varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW, TEN.Strings. varDisplayString:SetFlags{ TEN.Strings.DisplayStringOption.CENTER }
        -
        -
        - - DisplayString:SetTranslated(shouldTranslate) -
        -
        - Set translated parameter of the string - - - -

        Parameters:

        -
          -
        • shouldTranslate - bool - if true, the string's key will be used as the key for the translation that will be displayed. - If false, the key itself will be displayed -
        • -
        - - - - -
        diff --git a/Documentation/doc/2 classes/View.DisplaySprite.html b/Documentation/doc/2 classes/View.DisplaySprite.html index 28b4952ab..9347dded9 100644 --- a/Documentation/doc/2 classes/View.DisplaySprite.html +++ b/Documentation/doc/2 classes/View.DisplaySprite.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

        3 Primitive Classes

        5 Lua utility modules

    -
    - - __tostring(This) -
    -
    - Metafunction. Use tostring(vector). - - - -

    Parameters:

    -
      -
    • This - Vec2 - Vec2. -
    • -
    - -

    Returns:

    -
      - - string - A string showing the X and Y components of the Vec2. -
    - - - -
    @@ -335,8 +311,8 @@
    - - Translate(dir, dist) + + Vec2:Translate(dir, dist)
    Get a copy of this Vec2 translated in the input Vec2 direction by the input distance. @@ -367,8 +343,8 @@
    - - Translate(rot, dist) + + Vec2:Translate(rot, dist)
    Get a copy of this Vec2 translated in the direction of the input rotation in degrees by the input distance. @@ -378,7 +354,7 @@

    Parameters:

    • rot - Rotation + float Rotation in degrees defining the direction.
    • dist @@ -399,8 +375,8 @@
    - - Translate(rot, relOffset) + + Vec2:Translate(rot, relOffset)
    Get a copy of this Vec2 translated by an offset, where the input relative offset Vec2 is rotated according to the input rotation in degrees. @@ -594,6 +570,34 @@ +
    +
    + + __tostring(This) +
    +
    + Metafunction. Use tostring(vector). + + + +

    Parameters:

    +
      +
    • This + Vec2 + Vec2. +
    • +
    + +

    Returns:

    +
      + + string + A string showing the X and Y components of the Vec2. +
    + + + +
    diff --git a/Documentation/doc/3 primitive classes/Vec3.html b/Documentation/doc/3 primitive classes/Vec3.html index 7976a2254..f8e233fbc 100644 --- a/Documentation/doc/3 primitive classes/Vec3.html +++ b/Documentation/doc/3 primitive classes/Vec3.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

    3 Primitive Classes

    5 Lua utility modules

      +
    • CustomBar
    • Diary
    • EventSequence
    • Timer
    • diff --git a/Documentation/doc/4 enums/Collision.MaterialType.html b/Documentation/doc/4 enums/Collision.MaterialType.html index 869027788..8ed328b63 100644 --- a/Documentation/doc/4 enums/Collision.MaterialType.html +++ b/Documentation/doc/4 enums/Collision.MaterialType.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

      3 Primitive Classes

      5 Lua utility modules

        +
      • CustomBar
      • Diary
      • EventSequence
      • Timer
      • @@ -138,7 +142,10 @@
        -

        Table of MaterialType constants.

        +

        Table of MaterialType constants. +
        + Corresponds to Tomb Editor texture sound material types. + To be used with Collision.Probe.GetFloorMaterialType and Collision.Probe.GetCeilingMaterialType.

        • MUD
        • diff --git a/Documentation/doc/4 enums/Effects.BlendID.html b/Documentation/doc/4 enums/Effects.BlendID.html index b6f9a497a..5c3fc42f4 100644 --- a/Documentation/doc/4 enums/Effects.BlendID.html +++ b/Documentation/doc/4 enums/Effects.BlendID.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

          3 Primitive Classes

          5 Lua utility modules

            +
          • CustomBar
          • Diary
          • EventSequence
          • Timer
          • @@ -138,18 +142,20 @@
            -

            Table of Effects.BlendID constants.

            +

            Table of Effects.BlendID constants. +
            + All blending modes except OPAQUE, ADDITIVE and ALPHA_BLEND will use depth sorting for applicable polygons. + This may reduce engine performance, so it is preferable to minimize usage of other blending modes.

              -
            • OPAQUE
            • -
            • ALPHA_TEST
            • -
            • ADDITIVE
            • -
            • NO_DEPTH_TEST
            • -
            • SUBTRACTIVE
            • -
            • EXCLUDE
            • -
            • SCREEN
            • -
            • LIGHTEN
            • -
            • ALPHA_BLEND
            • +
            • OPAQUE - No transparency.
            • +
            • ALPHA_TEST - So called "magenta transparency", every pixel can be either fully transparent or opaque.
            • +
            • ADDITIVE - Standard additive blending.
            • +
            • SUBTRACTIVE - Subtractive blending, with brighter texture areas making everything darker behind them.
            • +
            • EXCLUDE - Produces "inversion" effect.
            • +
            • SCREEN - Similar to ADDITIVE, but without excessive overbright.
            • +
            • LIGHTEN - Similar to SCREEN, but with a little different blending formula.
            • +
            • ALPHA_BLEND - True alpha blending. Should be used for textures with gradually changing alpha values.
            diff --git a/Documentation/doc/4 enums/Effects.EffectID.html b/Documentation/doc/4 enums/Effects.EffectID.html index aa86e705d..504db707c 100644 --- a/Documentation/doc/4 enums/Effects.EffectID.html +++ b/Documentation/doc/4 enums/Effects.EffectID.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

            3 Primitive Classes

            5 Lua utility modules

              +
            • CustomBar
            • Diary
            • EventSequence
            • Timer
            • diff --git a/Documentation/doc/4 enums/Effects.ParticleAnimationType.html b/Documentation/doc/4 enums/Effects.ParticleAnimationType.html new file mode 100644 index 000000000..d9acddbe4 --- /dev/null +++ b/Documentation/doc/4 enums/Effects.ParticleAnimationType.html @@ -0,0 +1,172 @@ + + + + + TombEngine 1.8.2 Lua API + + + + +
              + +
              + +
              +
              +
              + + +
              + + + + + + +
              + +

              Enum Effects.ParticleAnimationType

              +

              Constants for particle animation type constants.

              +

              To be used with Effects.EmitAdvancedParticle function.

              + + +

              Tables

              + + + + + +
              Effects.ParticleAnimationTypeTable of Effects.ParticleAnimationType type constants.
              + +
              +
              + + +

              Tables

              + +
              +
              + + Effects.ParticleAnimationType +
              +
              + +

              Table of Effects.ParticleAnimationType type constants. To be used with particles.

              + +
                +
              • LOOP - Frames loop sequentially.
              • +
              • ONE_SHOT - Frames play once and freeze on the last frame.
              • +
              • BACK_AND_FORTH - Frames bounce back and forth.
              • +
              • LIFE_TIME_SPREAD - Frames are distributed over the particle's lifetime
              • +
              + + + + + + + + + + +
              +
              + + +
              +
              +
              +generated by TEN-LDoc (a fork of LDoc 1.4.6) +
              +
              + + diff --git a/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html b/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html new file mode 100644 index 000000000..c345a047e --- /dev/null +++ b/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html @@ -0,0 +1,175 @@ + + + + + TombEngine 1.8.2 Lua API + + + + +
              + +
              + +
              +
              +
              + + +
              + + + + + + +
              + +

              Enum Effects.StreamerFeatherMode

              +

              Constants for feather modes.

              +

              + +

              + + +

              Tables

              + + + + + +
              Effects.StreamerFeatherModeTable of Effects.StreamerFeatherMode constants.
              + +
              +
              + + +

              Tables

              + +
              +
              + + Effects.StreamerFeatherMode +
              +
              + +

              Table of Effects.StreamerFeatherMode constants. + To be used with Effects.EmitStreamer function.

              + +
                +
              • NONE
              • +
              • CENTER
              • +
              • LEFT
              • +
              • RIGHT
              • +
              + + + + + + + + + + +
              +
              + + +
              +
              +
              +generated by TEN-LDoc (a fork of LDoc 1.4.6) +
              +
              + + diff --git a/Documentation/doc/4 enums/Flow.ErrorMode.html b/Documentation/doc/4 enums/Flow.ErrorMode.html index 2d0b7dab7..de10d20bd 100644 --- a/Documentation/doc/4 enums/Flow.ErrorMode.html +++ b/Documentation/doc/4 enums/Flow.ErrorMode.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

              3 Primitive Classes

              5 Lua utility modules

                +
              • CustomBar
              • Diary
              • EventSequence
              • Timer
              • @@ -142,12 +146,12 @@

                The following constants are inside Flow.ErrorMode:

                  -
                • TERMINATE - print to the log file and return to the title level when any script error is hit. - This is the one you will want to go for if you want to know IMMEDIATELY if something has gone wrong.

                • -
                • WARN - print to the log file and continue running the application when a recoverable script error is hit. +

                • TERMINATE - Print to the log file and return to the title level when any script error is hit. + This is the one you will want to go for if you want to know immediately if something has gone wrong.

                • +
                • WARN - Print to the log file and continue running the application when a recoverable script error is hit. Choose this one if booting to the title level is too much for you.

                • -
                • SILENT - do nothing when a recoverable script error is hit. - Think very carefully before using this setting. These error modes are here to help you to keep your scripts +

                • SILENT - Do nothing when a recoverable script error is hit. + Think very carefully before using this setting. These error modes are here to help you to keep your scripts working properly, but if you opt to ignore errors, you won't be alerted if you've misused a function or passed an invalid argument.

                diff --git a/Documentation/doc/4 enums/Flow.FreezeMode.html b/Documentation/doc/4 enums/Flow.FreezeMode.html index 074bedd81..9b9032383 100644 --- a/Documentation/doc/4 enums/Flow.FreezeMode.html +++ b/Documentation/doc/4 enums/Flow.FreezeMode.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                3 Primitive Classes

                5 Lua utility modules

                  +
                • CustomBar
                • Diary
                • EventSequence
                • Timer
                • diff --git a/Documentation/doc/4 enums/Flow.GameStatus.html b/Documentation/doc/4 enums/Flow.GameStatus.html index 955d7a5cd..1c85193ae 100644 --- a/Documentation/doc/4 enums/Flow.GameStatus.html +++ b/Documentation/doc/4 enums/Flow.GameStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                  3 Primitive Classes

                  5 Lua utility modules

                    +
                  • CustomBar
                  • Diary
                  • EventSequence
                  • Timer
                  • diff --git a/Documentation/doc/4 enums/Input.ActionID.html b/Documentation/doc/4 enums/Input.ActionID.html index ac3ba5f7e..6e112df91 100644 --- a/Documentation/doc/4 enums/Input.ActionID.html +++ b/Documentation/doc/4 enums/Input.ActionID.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                    3 Primitive Classes

                    5 Lua utility modules

                      +
                    • CustomBar
                    • Diary
                    • EventSequence
                    • Timer
                    • diff --git a/Documentation/doc/4 enums/Objects.AmmoType.html b/Documentation/doc/4 enums/Objects.AmmoType.html index 3f9711c25..114163de2 100644 --- a/Documentation/doc/4 enums/Objects.AmmoType.html +++ b/Documentation/doc/4 enums/Objects.AmmoType.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                      3 Primitive Classes

                      5 Lua utility modules

                        +
                      • CustomBar
                      • Diary
                      • EventSequence
                      • Timer
                      • diff --git a/Documentation/doc/4 enums/Objects.HandStatus.html b/Documentation/doc/4 enums/Objects.HandStatus.html index 75c3dec50..b0582d69f 100644 --- a/Documentation/doc/4 enums/Objects.HandStatus.html +++ b/Documentation/doc/4 enums/Objects.HandStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                        3 Primitive Classes

                        5 Lua utility modules

                          +
                        • CustomBar
                        • Diary
                        • EventSequence
                        • Timer
                        • diff --git a/Documentation/doc/4 enums/Objects.MoveableStatus.html b/Documentation/doc/4 enums/Objects.MoveableStatus.html index edee47c8e..87325f180 100644 --- a/Documentation/doc/4 enums/Objects.MoveableStatus.html +++ b/Documentation/doc/4 enums/Objects.MoveableStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                          3 Primitive Classes

                          5 Lua utility modules

                            +
                          • CustomBar
                          • Diary
                          • EventSequence
                          • Timer
                          • @@ -143,10 +147,10 @@

                            To be used with Objects.Moveable.GetStatus and Objects.Moveable.SetStatus functions.

                              -
                            • INACTIVE - moveable is inactive (was never activated).
                            • -
                            • ACTIVE - moveable is active.
                            • -
                            • DEACTIVATED - moveable is deactivated (was previously active and later deactivated).
                            • -
                            • INVISIBLE - moveable is invisible.
                            • +
                            • INACTIVE - Moveable is inactive (was never activated).
                            • +
                            • ACTIVE - Moveable is active.
                            • +
                            • DEACTIVATED - Moveable is deactivated (was previously active and later deactivated).
                            • +
                            • INVISIBLE - Moveable is invisible.
                            diff --git a/Documentation/doc/4 enums/Objects.ObjID.html b/Documentation/doc/4 enums/Objects.ObjID.html index b8a5bafce..889c4b9a3 100644 --- a/Documentation/doc/4 enums/Objects.ObjID.html +++ b/Documentation/doc/4 enums/Objects.ObjID.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                            3 Primitive Classes

                            5 Lua utility modules

                              +
                            • CustomBar
                            • Diary
                            • EventSequence
                            • Timer
                            • @@ -127,6 +131,10 @@ PickupConstants Objects.ObjID pickup constants. + + SpriteConstants + Objects.ObjID sprite constants. +
                              @@ -141,7 +149,8 @@ Members
                              - Objects.ObjID constants.

                              + +

                              Objects.ObjID constants.

                              The following constants are inside ObjID.

                              @@ -294,6 +303,7 @@ GLADIATOR CYBORG SNIPER CHEF +KOLD WINGED_MUMMY CENTAUR_MUTANT DOPPELGANGER @@ -318,14 +328,14 @@ SWORD_GUARDIAN SWORD_GUARDIAN_STATUE SHIVA SHIVA_STATUE -TRIBEBOSS +WILLARD CIVVY MUTANT2 LIZARD TONY_BOSS TONY_BOSS_FLAME PUNA_BOSS -SOPHIA_LEE_BOSS +SOPHIA_LEIGH_BOSS LASER_BOLT SKELETON MUMMY @@ -357,7 +367,7 @@ ATTACK_SUB IMP IMP_ROCK GUNSHIP -AUTOGUN +AUTO_GUN_VCI ROMAN_GOD1 ROMAN_GOD2 LAGOON_WITCH @@ -366,6 +376,7 @@ BOSS_EXPLOSION_SHOCKWAVE BOSS_EXPLOSION_RING CLAW_MUTANT WASP_MUTANT +TWIN_AUTO_GUN SKATEBOARD SKATEBOARD_KID WINSTON @@ -501,6 +512,11 @@ DAMOCLES_SWORD ELECTRIC_CLEANER SLAMMING_DOORS SWINGING_BLADE +ELECTRIC_BALL +ELECTRIC_BALL_IMPACT_POINT +THOR_HAMMER_HANDLE +THOR_HAMMER_HEAD +MOVING_LASER PUZZLE_ITEM1 PUZZLE_ITEM2 PUZZLE_ITEM3 @@ -733,7 +749,6 @@ BURNING_TORCH_ITEM CLOCKWORK_BEETLE CLOCKWORK_BEETLE_COMBO1 CLOCKWORK_BEETLE_COMBO2 - SWITCH_TYPE1 SWITCH_TYPE2 SWITCH_TYPE3 @@ -755,10 +770,10 @@ SHOOT_SWITCH2 SHOOT_SWITCH3 SHOOT_SWITCH4 AIRLOCK_SWITCH -ID_UNDERWATER_WALL_SWITCH_1 -ID_UNDERWATER_WALL_SWITCH_2 -ID_UNDERWATER_CEILING_SWITCH_1 -ID_UNDERWATER_CEILING_SWITCH_2 +UNDERWATER_WALL_SWITCH1 +UNDERWATER_WALL_SWITCH2 +UNDERWATER_CEILING_SWITCH1 +UNDERWATER_CEILING_SWITCH2 TURN_SWITCH COG_SWITCH LEVER_SWITCH @@ -868,7 +883,7 @@ INVENTORY_PASSPORT INVENTORY_SUNGLASSES INVENTORY_KEYS INVENTORY_HEADPHONES -INVENTORY_POLAROID +INVENTORY_PHOTO SMOKE_EMITTER_WHITE SMOKE_EMITTER_BLACK SMOKE_EMITTER @@ -905,7 +920,7 @@ FLOOR_LASERS KILL_ALL_TRIGGERS TRIGGER_TRIGGERER HIGH_OBJECT1 -HIGH_OBJECT2 +EMBER_EMITTER SMASH_OBJECT1 SMASH_OBJECT2 SMASH_OBJECT3 @@ -936,6 +951,8 @@ FISHTANK DOPPELGANGER_ORIGIN CORPSE WRAITH_TRAP +WATERFALL_EMITTER +FIREFLY_EMITTER MESHSWAP1 MESHSWAP2 MESHSWAP3 @@ -1093,8 +1110,6 @@ BRIDGE_TILT3 BRIDGE_TILT4 BRIDGE_CUSTOM HORIZON -BINOCULAR_GRAPHICS -TARGET_GRAPHICS SKY_GRAPHICS DEFAULT_SPRITES MISC_SPRITES @@ -1109,31 +1124,24 @@ RUBBER_BOAT_WAVE_SPRITES SKIDOO_SNOW_TRAIL_SPRITES KAYAK_PADDLE_TRAIL_SPRITE KAYAK_WAKE_SPRTIES -BINOCULAR_GRAPHIC -LASER_SIGHT_GRAPHIC -CAUSTICS_TEXTURES -BAR_BORDER_GRAPHIC +BINOCULAR_GRAPHICS +LASERSIGHT_GRAPHICS +CAUSTIC_TEXTURES +BAR_BORDER_GRAPHICS HEALTH_BAR_TEXTURE AIR_BAR_TEXTURE DASH_BAR_TEXTURE SFX_BAR_TEXTURE -SPEEDOMETER -WATERFALL -CUSTOM_BAR_GRAPHIC -CUSTOM_AMMO_GRAPHIC +WATERFALL_SPRITES +FIREFLY_SPRITES +CROSSHAIR_GRAPHICS +SPEEDOMETER_GRAPHICS +CUSTOM_BAR_GRAPHICS +CUSTOM_AMMO_GRAPHICS DIARY_SPRITES DIARY_ENTRY_SPRITES - -PANEL_BORDER -PANEL_MIDDLE -PANEL_CORNER -PANEL_DIAGONAL -PANEL_STRIP -PANEL_HALF_BORDER1 -PANEL_HALF_BORDER2 -PANEL_MIDDLE_CORNER -

                              Table of constants. + @@ -1148,7 +1156,8 @@ PANEL_MIDDLE_CORNER PickupConstants

                              - Objects.ObjID pickup constants.

                              + +

                              Objects.ObjID pickup constants.

                              The following ObjID members refer to pickups.

                              @@ -1296,6 +1305,30 @@ PICKUP_ITEM15_COMBO1 PICKUP_ITEM15_COMBO2 PICKUP_ITEM16_COMBO1 PICKUP_ITEM16_COMBO2 +EXAMINE1 +EXAMINE2 +EXAMINE3 +EXAMINE4 +EXAMINE5 +EXAMINE6 +EXAMINE7 +EXAMINE8 +EXAMINE1_COMBO1 +EXAMINE1_COMBO2 +EXAMINE2_COMBO1 +EXAMINE2_COMBO2 +EXAMINE3_COMBO1 +EXAMINE3_COMBO2 +EXAMINE4_COMBO1 +EXAMINE4_COMBO2 +EXAMINE5_COMBO1 +EXAMINE5_COMBO2 +EXAMINE6_COMBO1 +EXAMINE6_COMBO2 +EXAMINE7_COMBO1 +EXAMINE7_COMBO2 +EXAMINE8_COMBO1 +EXAMINE8_COMBO2 HAMMER_ITEM CROWBAR_ITEM BURNING_TORCH_ITEM @@ -1333,10 +1366,61 @@ FLARE_INV_ITEM COMPASS_ITEM DIARY_ITEM STOPWATCH_ITEM +MEMCARD_LOAD_INV_ITEM +MEMCARD_SAVE_INV_ITEM PC_LOAD_INV_ITEM PC_SAVE_INV_ITEM -

                              Table of constants. + + + + + + + + + +

                              +
                              + + SpriteConstants +
                              +
                              + +

                              Objects.ObjID sprite constants.

                              + +

                              The following ObjID members refer to sprites.

                              + +
                              SKY_GRAPHICS
                              +DEFAULT_SPRITES
                              +MISC_SPRITES
                              +CUSTOM_SPRITES
                              +FIRE_SPRITES
                              +SMOKE_SPRITES
                              +SPARK_SPRITE
                              +DRIP_SPRITE
                              +EXPLOSION_SPRITES
                              +MOTORBOAT_FOAM_SPRITES
                              +RUBBER_BOAT_WAVE_SPRITES
                              +SKIDOO_SNOW_TRAIL_SPRITES
                              +KAYAK_PADDLE_TRAIL_SPRITE
                              +LASERSIGHT_GRAPHICS
                              +CAUSTIC_TEXTURES
                              +BAR_BORDER_GRAPHICS
                              +HEALTH_BAR_TEXTURE
                              +AIR_BAR_TEXTURE
                              +DASH_BAR_TEXTURE
                              +SFX_BAR_TEXTURE
                              +WATERFALL_SPRITES
                              +FIREFLY_SPRITES
                              +CROSSHAIR_GRAPHICS
                              +SPEEDOMETER_GRAPHICS
                              +CUSTOM_BAR_GRAPHICS
                              +CUSTOM_AMMO_GRAPHICS
                              +DIARY_SPRITES
                              +DIARY_ENTRY_SPRITES
                              +
                              + diff --git a/Documentation/doc/4 enums/Objects.RoomFlagID.html b/Documentation/doc/4 enums/Objects.RoomFlagID.html index 7bb77ff27..cdd7e43ea 100644 --- a/Documentation/doc/4 enums/Objects.RoomFlagID.html +++ b/Documentation/doc/4 enums/Objects.RoomFlagID.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                              3 Primitive Classes

                              5 Lua utility modules

                                +
                              • CustomBar
                              • Diary
                              • EventSequence
                              • Timer
                              • @@ -139,7 +143,8 @@

                                Table of Objects.RoomFlagID constants. -To be used with Objects.Room.SetFlag and Objects.Room.GetFlag functions.

                                +
                                +Corresponds to room flags in Tomb Editor. To be used with Objects.Room.SetFlag and Objects.Room.GetFlag functions.

                                The following constants are inside RoomFlagID.

                                diff --git a/Documentation/doc/4 enums/Objects.RoomReverb.html b/Documentation/doc/4 enums/Objects.RoomReverb.html index a728399b5..555358c9c 100644 --- a/Documentation/doc/4 enums/Objects.RoomReverb.html +++ b/Documentation/doc/4 enums/Objects.RoomReverb.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                3 Primitive Classes

                                5 Lua utility modules

                                  +
                                • CustomBar
                                • Diary
                                • EventSequence
                                • Timer
                                • @@ -139,16 +143,16 @@

                                  Table of Objects.RoomReverb constants. -To be used with Objects.Room.GetReverbType and Objects.Room.SetReverbType functions.

                                  - -

                                  The following constants are inside RoomReverb.

                                  +
                                  +Corresponds to room reverb setting set in Tomb Editor. To be used with Objects.Room.GetReverbType and Objects.Room.SetReverbType functions. +The following constants are inside RoomReverb.

                                    -
                                  • OUTSIDE
                                  • -
                                  • SMALL
                                  • -
                                  • MEDIUM
                                  • -
                                  • LARGE
                                  • -
                                  • PIPE
                                  • +
                                  • OUTSIDE
                                  • +
                                  • SMALL
                                  • +
                                  • MEDIUM
                                  • +
                                  • LARGE
                                  • +
                                  • PIPE
                                  diff --git a/Documentation/doc/4 enums/Objects.WeaponType.html b/Documentation/doc/4 enums/Objects.WeaponType.html index 9dfbc7b5b..6b6a87ea2 100644 --- a/Documentation/doc/4 enums/Objects.WeaponType.html +++ b/Documentation/doc/4 enums/Objects.WeaponType.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                  3 Primitive Classes

                                  5 Lua utility modules

                                    +
                                  • CustomBar
                                  • Diary
                                  • EventSequence
                                  • Timer
                                  • diff --git a/Documentation/doc/4 enums/Sound.SoundTrackType.html b/Documentation/doc/4 enums/Sound.SoundTrackType.html index e57bb2fbd..1b80f2b82 100644 --- a/Documentation/doc/4 enums/Sound.SoundTrackType.html +++ b/Documentation/doc/4 enums/Sound.SoundTrackType.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                    3 Primitive Classes

                                    5 Lua utility modules

                                      +
                                    • CustomBar
                                    • Diary
                                    • EventSequence
                                    • Timer
                                    • @@ -143,9 +147,9 @@

                                      To be used with sound track functions, such as Sound.PlayAudioTrack and Sound.StopAudioTrack.

                                        -
                                      • ONESHOT - used for one-time music tracks.
                                      • -
                                      • LOOPED - used for looped ambience or music.
                                      • -
                                      • VOICE - used for dialogs. Also supports subtitles, set by Sound.GetCurrentSubtitle function.
                                      • +
                                      • ONESHOT - Used for one-time music tracks.
                                      • +
                                      • LOOPED - Used for looped ambience or music.
                                      • +
                                      • VOICE - Used for dialogs. Also supports subtitles, set by Sound.GetCurrentSubtitle function.
                                      diff --git a/Documentation/doc/4 enums/Strings.DisplayStringOption.html b/Documentation/doc/4 enums/Strings.DisplayStringOption.html index 2f469bd78..32a0f566d 100644 --- a/Documentation/doc/4 enums/Strings.DisplayStringOption.html +++ b/Documentation/doc/4 enums/Strings.DisplayStringOption.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                      3 Primitive Classes

                                      5 Lua utility modules

                                        +
                                      • CustomBar
                                      • Diary
                                      • EventSequence
                                      • Timer
                                      • @@ -141,10 +145,10 @@

                                        Strings.DisplayStringOption constants. To be used with Strings.DisplayString class.

                                          -
                                        • CENTER - set the horizontal origin point to the center of the string.
                                        • -
                                        • RIGHT - set the horizontal origin point to right of the string.
                                        • -
                                        • SHADOW - gives the string a small drop shadow.
                                        • -
                                        • BLINK - blinks the string
                                        • +
                                        • CENTER - Set the horizontal origin point to the center of the string.
                                        • +
                                        • RIGHT - Set the horizontal origin point to right of the string.
                                        • +
                                        • SHADOW - Gives the string a small drop shadow.
                                        • +
                                        • BLINK - Blinks the string.
                                        diff --git a/Documentation/doc/4 enums/Util.LogLevel.html b/Documentation/doc/4 enums/Util.LogLevel.html index b4824fc0d..db5b3d0c1 100644 --- a/Documentation/doc/4 enums/Util.LogLevel.html +++ b/Documentation/doc/4 enums/Util.LogLevel.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                        3 Primitive Classes

                                        5 Lua utility modules

                                          +
                                        • CustomBar
                                        • Diary
                                        • EventSequence
                                        • Timer
                                        • diff --git a/Documentation/doc/4 enums/View.AlignMode.html b/Documentation/doc/4 enums/View.AlignMode.html index 85abe33ff..90ce2b553 100644 --- a/Documentation/doc/4 enums/View.AlignMode.html +++ b/Documentation/doc/4 enums/View.AlignMode.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                          3 Primitive Classes

                                          5 Lua utility modules

                                            +
                                          • CustomBar
                                          • Diary
                                          • EventSequence
                                          • Timer
                                          • diff --git a/Documentation/doc/4 enums/View.CameraType.html b/Documentation/doc/4 enums/View.CameraType.html index b1db0ce92..cd0848ceb 100644 --- a/Documentation/doc/4 enums/View.CameraType.html +++ b/Documentation/doc/4 enums/View.CameraType.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                            3 Primitive Classes

                                            5 Lua utility modules

                                              +
                                            • CustomBar
                                            • Diary
                                            • EventSequence
                                            • Timer
                                            • @@ -141,13 +145,13 @@

                                              Table of View.CameraType constants. To be used with View.GetCameraType function.

                                                -
                                              • NORMAL - standard in-game camera when weapons are holstered.
                                              • -
                                              • COMBAT - in-game camera when weapons are unholstered.
                                              • -
                                              • FIXED - classic fixed camera.
                                              • -
                                              • LOOK - look camera.
                                              • -
                                              • FLYBY - flyby or tracking camera.
                                              • -
                                              • BINOCULARS - binoculars is active.
                                              • -
                                              • LASERSIGHT - lasersight is active.
                                              • +
                                              • NORMAL - Standard in-game camera when weapons are holstered.
                                              • +
                                              • COMBAT - In-game camera when weapons are unholstered.
                                              • +
                                              • FIXED - Classic fixed camera.
                                              • +
                                              • LOOK - Look camera.
                                              • +
                                              • FLYBY - Flyby or tracking camera.
                                              • +
                                              • BINOCULARS - Binocular camera.
                                              • +
                                              • LASERSIGHT - Lasersight camera.
                                              diff --git a/Documentation/doc/4 enums/View.PostProcessMode.html b/Documentation/doc/4 enums/View.PostProcessMode.html index 7d80a57ca..0036ba5c3 100644 --- a/Documentation/doc/4 enums/View.PostProcessMode.html +++ b/Documentation/doc/4 enums/View.PostProcessMode.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                              3 Primitive Classes

                                              5 Lua utility modules

                                                +
                                              • CustomBar
                                              • Diary
                                              • EventSequence
                                              • Timer
                                              • diff --git a/Documentation/doc/4 enums/View.ScaleMode.html b/Documentation/doc/4 enums/View.ScaleMode.html index 1336eab9f..445c35879 100644 --- a/Documentation/doc/4 enums/View.ScaleMode.html +++ b/Documentation/doc/4 enums/View.ScaleMode.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                3 Primitive Classes

                                                5 Lua utility modules

                                                  +
                                                • CustomBar
                                                • Diary
                                                • EventSequence
                                                • Timer
                                                • @@ -141,9 +145,9 @@

                                                  Table of View.ScaleMode constants. To be used with View.DisplaySprite class.

                                                    -
                                                  • FIT
                                                  • -
                                                  • FILL
                                                  • -
                                                  • STRETCH +
                                                  • FIT - Image will proportionally fit the whole image into the sprite surface.
                                                  • +
                                                  • FILL - Image will scale up proportionally and crop to fill all sprite surface.
                                                  • +
                                                  • STRETCH - Image will stretch according to sprite dimensions, not taking aspect ratio into consideration.
                                                  diff --git a/Documentation/doc/5 lua utility modules/CustomBar.html b/Documentation/doc/5 lua utility modules/CustomBar.html new file mode 100644 index 000000000..b0f3fe3be --- /dev/null +++ b/Documentation/doc/5 lua utility modules/CustomBar.html @@ -0,0 +1,1510 @@ + + + + + TombEngine 1.8.2 Lua API + + + + +
                                                  + +
                                                  + +
                                                  +
                                                  +
                                                  + + +
                                                  + + + + + + +
                                                  + +

                                                  Lua utility module CustomBar

                                                  +

                                                  This module provides functions for creating and managing custom progress bars.

                                                  +

                                                  +

                                                  It stores bar definitions and configurations in LevelVars.Engine.CustomBars, enabling seamless state management. + Each bar is independently controlled through its associated functions.

                                                  + +

                                                  Example usage:

                                                  + + +
                                                  +local CustomBar = require("Engine.CustomBar")
                                                  +
                                                  +-- Create a table with all the bar properties
                                                  +local barData = {
                                                  +    barName             = "water",
                                                  +    startValue          = 0,
                                                  +    maxValue            = 1000,
                                                  +    objectIdBg          = TEN.Objects.ObjID.CUSTOM_BAR_GRAPHIC,
                                                  +    spriteIdBg          = 0,
                                                  +    colorBg             = TEN.Color(255,255,255),
                                                  +    posBg               = TEN.Vec2(20, 20),
                                                  +    rotBg               = 0,
                                                  +    scaleBg             = TEN.Vec2(19.05, 19.1),
                                                  +    alignModeBg         = TEN.View.AlignMode.CENTER_LEFT,
                                                  +    scaleModeBg         = TEN.View.ScaleMode.FIT,
                                                  +    blendModeBg         = TEN.Effects.BlendID.ALPHABLEND,
                                                  +    objectIdBar         = TEN.Objects.ObjID.CUSTOM_BAR_GRAPHIC,
                                                  +    spriteIdBar         = 1,
                                                  +    colorBar            = TEN.Color(255,0,0),
                                                  +    posBar              = TEN.Vec2(20.15, 20),
                                                  +    rot                 = 0,
                                                  +    scaleBar            = TEN.Vec2(18.7, 18.48),
                                                  +    alignMode           = TEN.View.AlignMode.CENTER_LEFT,
                                                  +    scaleMode           = TEN.View.ScaleMode.FIT,
                                                  +    blendMode           = TEN.Effects.BlendID.ALPHABLEND,
                                                  +    text                = "Water Bar",
                                                  +    textPos             = TEN.Vec2(20, 15),
                                                  +    textOptions         = {TEN.Strings.DisplayStringOption.SHADOW,TEN.Strings.DisplayStringOption.CENTER},
                                                  +    textScale           = 1,
                                                  +    textColor           = TEN.Color(255,0,0),
                                                  +    hideText            = false,
                                                  +    alphaBlendSpeed     = 50,
                                                  +    blink               = false,
                                                  +    blinkLimit          = 0.25
                                                  +}
                                                  +
                                                  +-- This function creates the bar.
                                                  +CustomBar.Create(barData)
                                                  +
                                                  +-- This method gets the bar with name "water" and stores it in variable bar.
                                                  +local bar = CustomBar.Get("water")
                                                  +-- This method displays the bar
                                                  +bar:SetVisibility(true)
                                                  +-- This method sets the bar value to 1000 over 5 seconds.
                                                  +bar:SetBarValue(1000,5)
                                                  +
                                                  + +

                                                  + + +

                                                  Functions

                                                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                  Create(barData)Creates a custom progress bar with extensive configuration options.
                                                  CreatePlayerBar(playerBarData)Creates a bar tied to Players's attributes (Health, Air, Stamina).
                                                  CreateEnemyHpBar(enemyBarData)Creates a custom health bar for a specific enemy (like a boss).
                                                  SetEnemiesHpGenericBar(enemiesBarData)Creates health bars for all enemies.
                                                  Get(barName)The function retrieves an existing bar instance by its unique identifier (barName).
                                                  Delete(barName)The function removes a custom bar and its associated data from the system.
                                                  SetBarValue(value, time)The function sets the value of a custom bar over a specified time period.
                                                  ChangeBarValueOverTimespan(value, time)The function adjusts the bar's value relative to its current or target value over a specified time span.
                                                  SetVisibility(visible)The function controls the visibility of a custom bar.
                                                  IsVisible()The function checks whether a custom bar is currently visible.
                                                  GetValue()The function retrieves the current value of a custom bar.
                                                  DeleteAllBars()The function deletes all custom bars.
                                                  ShowEnemiesHpGenericBar(value)This function prevents the creation of new health bars for enemies when set to false.
                                                  DeleteExistingHpGenericBars()The function deletes all the enemy health bars excluding those created by CustomBar.CreateEnemyHpBar.
                                                  SetBackgroundPosition(pos)Sets the custom bar background sprite position.
                                                  SetBackgroundRotation(rot)Sets the custom bar background sprite rotation.
                                                  SetBackgroundScale(scale)Sets the custom bar background sprite scale.
                                                  SetBackgroundSpriteSlot(slot, id)Sets the custom bar background sprite slot and sprite ID.
                                                  SetBackgroundAlignMode(alignMode)Sets the custom bar background sprite align mode.
                                                  SetBackgroundScaleMode(scaleMode)Sets the custom bar background sprite scale mode.
                                                  SetBackgroundBlendMode(blendMode)Sets the custom bar background sprite blend mode.
                                                  SetBarPosition(pos)Sets the custom bar sprite position.
                                                  SetBarRotation(rot)Sets the custom bar sprite rotation.
                                                  SetBarColor(color)Sets the custom bar sprite color.
                                                  SetBarScale(scale)Sets the custom bar sprite scale.
                                                  SetBarSpriteSlot(slot, id)Sets the custom bar sprite slot and sprite ID.
                                                  SetBarAlignMode(alignMode)Sets the custom bar sprite alignment mode.
                                                  SetBarScaleMode(scaleMode)Sets the custom bar sprite scale mode.
                                                  SetBarBlendMode(blendMode)Sets the custom bar sprite blend mode.
                                                  +

                                                  Tables

                                                  + + + + + + + + + + + + + + + + + +
                                                  barDataTable setup for creating custom bar.
                                                  playerBarDataTable setup for creating custom player attribute bar.
                                                  enemyBarDataTable setup for creating a specific enemy health bar.
                                                  enemiesBarDataTable setup for creating health bars for all enemies.
                                                  + +
                                                  +
                                                  + + +

                                                  Functions

                                                  + +
                                                  +
                                                  + + Create(barData) +
                                                  +
                                                  + Creates a custom progress bar with extensive configuration options. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • barData + table + The table that contains all the bar data. Refer to table setup for barData. +
                                                  • +
                                                  + +

                                                  Returns:

                                                  +
                                                    + + CustomBar + The custombar in its hidden state +
                                                  + + + + +
                                                  +
                                                  + + CreatePlayerBar(playerBarData) +
                                                  +
                                                  + Creates a bar tied to Players's attributes (Health, Air, Stamina). + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • playerBarData + table + The table that contains all the player bar data. Refer to table setup for playerBarData. +
                                                  • +
                                                  + +

                                                  Returns:

                                                  +
                                                    + + CustomBar + Player attribute bar. +
                                                  + + + + +
                                                  +
                                                  + + CreateEnemyHpBar(enemyBarData) +
                                                  +
                                                  + Creates a custom health bar for a specific enemy (like a boss). Ensure this function is called before Lara aims at the enemy if using generic enemy HP bars as well. + Also be sure to call this function after increasing the HP of the enemy via LUA. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • enemyBarData + table + The table that contains all the enemy bar data. Refer to table setup for enemyBarData. +
                                                  • +
                                                  + +

                                                  Returns:

                                                  +
                                                    + + CustomBar + Enemy health bar. +
                                                  + + + + +
                                                  +
                                                  + + SetEnemiesHpGenericBar(enemiesBarData) +
                                                  +
                                                  + Creates health bars for all enemies. A new bar is generated whenever Lara targets an enemy. If the "hide text" option is disabled, the enemy's name (as set in the editor) is displayed. + Multiple enemies can share the same name by appending _number to the name in the editor. If adjusting an enemy's max HP, ensure this is done before Lara targets the enemy. + To create health bars for specific enemies, use CustomBar.CreateEnemyHpBar, ensuring the bar is created prior to targeting. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • enemiesBarData + table + The table that contains all the enemies bar data. Refer to table setup for enemiesBarData. +
                                                  • +
                                                  + +

                                                  Returns:

                                                  +
                                                    + + CustomBar + Enemy health bars. +
                                                  + + + + +
                                                  +
                                                  + + Get(barName) +
                                                  +
                                                  + The function retrieves an existing bar instance by its unique identifier (barName). This function is useful when you need to access or manipulate a bar that has already been created. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • barName + string + The unique identifier assigned to the bar when it was created using CustomBar.New +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + Delete(barName) +
                                                  +
                                                  + The function removes a custom bar and its associated data from the system. It ensures that the bar is no longer tracked or accessible in the LevelVars.Engine.CustomBars.bars table. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • barName + string + The name of the custom bar to be deleted. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarValue(value, time) +
                                                  +
                                                  + The function sets the value of a custom bar over a specified time period. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • value + number + The new target to which the bar's current value should transition. (Must be a non-negative number; between 0 and the bar's maxValue. +
                                                  • +
                                                  • time + number + The time (in seconds) over which the bar's value should transition to the target value. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + ChangeBarValueOverTimespan(value, time) +
                                                  +
                                                  + The function adjusts the bar's value relative to its current or target value over a specified time span. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • value + number + The relative value to add (positive or negative) to the current bar value. +
                                                  • +
                                                  • time + number + The duration (in seconds) over which the change should occur. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetVisibility(visible) +
                                                  +
                                                  + The function controls the visibility of a custom bar. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • visible + bool + true: Makes the bar visible.; false: Hides the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + IsVisible() +
                                                  +
                                                  + The function checks whether a custom bar is currently visible. + + + + +

                                                  Returns:

                                                  +
                                                    + + bool + true if the bar is visible and false if it is not. +
                                                  + + + + +
                                                  +
                                                  + + GetValue() +
                                                  +
                                                  + The function retrieves the current value of a custom bar. + + + + +

                                                  Returns:

                                                  +
                                                    + + float + returns the current value of a custom bar. +
                                                  + + + + +
                                                  +
                                                  + + DeleteAllBars() +
                                                  +
                                                  + The function deletes all custom bars. + + + + + + + + +
                                                  +
                                                  + + ShowEnemiesHpGenericBar(value) +
                                                  +
                                                  + This function prevents the creation of new health bars for enemies when set to false. However, it does not affect the health bars that have already been created. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • value + bool + Specifies whether new health bars for enemies should be created. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + DeleteExistingHpGenericBars() +
                                                  +
                                                  + The function deletes all the enemy health bars excluding those created by CustomBar.CreateEnemyHpBar. + + + + + + + + +
                                                  +
                                                  + + SetBackgroundPosition(pos) +
                                                  +
                                                  + Sets the custom bar background sprite position. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • pos + Vec2 + X,Y position of the bar's background in screen percent (0-100). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundRotation(rot) +
                                                  +
                                                  + Sets the custom bar background sprite rotation. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • rot + number + rotation of the bar's background. sprite (0-360). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundScale(scale) +
                                                  +
                                                  + Sets the custom bar background sprite scale. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • scale + Vec2 + X,Y Scaling factor for the bar's background sprite. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundSpriteSlot(slot, id) +
                                                  +
                                                  + Sets the custom bar background sprite slot and sprite ID. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • slot + ObjID + Object ID for the bar's background sprite. +
                                                  • +
                                                  • id + number + SpriteID from the specified object for the bar's background. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundAlignMode(alignMode) +
                                                  +
                                                  + Sets the custom bar background sprite align mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • alignMode + AlignMode + Alignment for the bar's background. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundScaleMode(scaleMode) +
                                                  +
                                                  + Sets the custom bar background sprite scale mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • scaleMode + ScaleMode + Scaling for the bar's background. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBackgroundBlendMode(blendMode) +
                                                  +
                                                  + Sets the custom bar background sprite blend mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • blendMode + BlendID + Blending modes for the bar's background. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarPosition(pos) +
                                                  +
                                                  + Sets the custom bar sprite position. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • pos + Vec2 + X,Y position of the bar in screen percent (0-100). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarRotation(rot) +
                                                  +
                                                  + Sets the custom bar sprite rotation. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • rot + number + rotation of the bar's sprite (0-360). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarColor(color) +
                                                  +
                                                  + Sets the custom bar sprite color. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • color + Color + Color of the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarScale(scale) +
                                                  +
                                                  + Sets the custom bar sprite scale. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • scale + Vec2 + X,Y Scaling factor for the bar's sprite. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarSpriteSlot(slot, id) +
                                                  +
                                                  + Sets the custom bar sprite slot and sprite ID. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • slot + ObjID + Object ID for the bar sprite. +
                                                  • +
                                                  • id + number + SpriteID from the specified object for the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarAlignMode(alignMode) +
                                                  +
                                                  + Sets the custom bar sprite alignment mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • alignMode + AlignMode + Alignment for the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarScaleMode(scaleMode) +
                                                  +
                                                  + Sets the custom bar sprite scale mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • scaleMode + ScaleMode + Scaling for the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + SetBarBlendMode(blendMode) +
                                                  +
                                                  + Sets the custom bar sprite blend mode. + + + +

                                                  Parameters:

                                                  +
                                                    +
                                                  • blendMode + BlendID + Blending modes for the bar. +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  +

                                                  Tables

                                                  + +
                                                  +
                                                  + + barData +
                                                  +
                                                  + Table setup for creating custom bar. + + + +

                                                  Fields:

                                                  +
                                                    +
                                                  • barName + string + Unique identifier for the bar. +
                                                  • +
                                                  • startValue + float + Initial value of the bar. +
                                                  • +
                                                  • maxValue + float + Maximum value of the bar. +
                                                  • +
                                                  • objectIdBg + ObjID + Object ID for the bar's background sprite. +
                                                  • +
                                                  • spriteIdBg + number + SpriteID from the specified object for the bar's background. +
                                                  • +
                                                  • colorBg + Color + Color of bar's background. +
                                                  • +
                                                  • posBg + Vec2 + X,Y position of the bar's background in screen percent (0-100). +
                                                  • +
                                                  • rotBg + float + rotation of the bar's background. sprite (0-360). +
                                                  • +
                                                  • scaleBg + Vec2 + X,Y Scaling factor for the bar's background sprite. +
                                                  • +
                                                  • alignModeBg + AlignMode + Alignment for the bar's background. +
                                                  • +
                                                  • scaleModeBg + ScaleMode + Scaling for the bar's background. +
                                                  • +
                                                  • blendModeBg + BlendID + Blending modes for the bar's background. +
                                                  • +
                                                  • objectIdBar + ObjID + Object ID for the bar sprite. +
                                                  • +
                                                  • spriteIdBar + number + SpriteID from the specified object for the bar. +
                                                  • +
                                                  • colorBar + Color + Color of the bar. +
                                                  • +
                                                  • posBar + Vec2 + X,Y position of the bar in screen percent (0-100). +
                                                  • +
                                                  • rot + float + rotation of the bar's sprite (0-360). +
                                                  • +
                                                  • scaleBar + Vec2 + X,Y Scaling factor for the bar's sprite. +
                                                  • +
                                                  • alignMode + AlignMode + Alignment for the bar. +
                                                  • +
                                                  • scaleMode + ScaleMode + Scaling for the bar. +
                                                  • +
                                                  • blendMode + BlendID + Blending modes for the bar. +
                                                  • +
                                                  • text + string + Text to display on the bar. +
                                                  • +
                                                  • textPos + Vec2 + X,Y position of the text. +
                                                  • +
                                                  • textOptions + DisplayStringOption + alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +
                                                  • +
                                                  • textScale + number + Scale factor for the text. +
                                                  • +
                                                  • textColor + Color + Color of the text. +
                                                  • +
                                                  • hideText + bool + Whether to hide the text. +
                                                  • +
                                                  • alphaBlendSpeed + number + Speed of alpha blending for bar visibility (0-255). +
                                                  • +
                                                  • blink + bool + Whether the bar blinks. +
                                                  • +
                                                  • blinkLimit + number + % Limit below which bar starts blinking (0-1). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + playerBarData +
                                                  +
                                                  + Table setup for creating custom player attribute bar. + + + +

                                                  Fields:

                                                  +
                                                    +
                                                  • getActionType + number + Determines the bar type: 1: Health, 2: Air, 3: Stamina. +
                                                  • +
                                                  • objectIdBg + ObjID + Object ID for the bar's background sprite. +
                                                  • +
                                                  • spriteIdBg + number + SpriteID from the specified object for the bar's background. +
                                                  • +
                                                  • colorBg + Color + Color of bar's background. +
                                                  • +
                                                  • posBg + Vec2 + X,Y position of the bar's background in screen percent (0-100). +
                                                  • +
                                                  • rotBg + number + rotation of the bar's background. sprite (0-360). +
                                                  • +
                                                  • scaleBg + Vec2 + X,Y Scaling factor for the bar's background sprite. +
                                                  • +
                                                  • alignModeBg + AlignMode + Alignment for the bar's background. +
                                                  • +
                                                  • scaleModeBg + ScaleMode + Scaling for the bar's background. +
                                                  • +
                                                  • blendModeBg + BlendID + Blending modes for the bar's background. +
                                                  • +
                                                  • objectIdBar + ObjID + Object ID for the bar sprite. +
                                                  • +
                                                  • spriteIdBar + number + SpriteID from the specified object for the bar. +
                                                  • +
                                                  • colorBar + Color + Color of the bar. +
                                                  • +
                                                  • posBar + Vec2 + X,Y position of the bar in screen percent (0-100). +
                                                  • +
                                                  • rot + number + rotation of the bar's sprite (0-360). +
                                                  • +
                                                  • scaleBar + Vec2 + X,Y Scaling factor for the bar's sprite. +
                                                  • +
                                                  • alignMode + AlignMode + Alignment for the bar. +
                                                  • +
                                                  • scaleMode + ScaleMode + Scaling for the bar. +
                                                  • +
                                                  • blendMode + BlendID + Blending modes for the bar. +
                                                  • +
                                                  • alphaBlendSpeed + number + Speed of alpha blending for bar visibility (0-255). +
                                                  • +
                                                  • showBar + bool + Option to always show the bar. If set to false, the bars will automatically hide when they stop updating. +
                                                  • +
                                                  • blink + bool + Whether the bar blinks. +
                                                  • +
                                                  • blinkLimit + number + % Limit below which bar starts blinking (0-1). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + enemyBarData +
                                                  +
                                                  + Table setup for creating a specific enemy health bar. + + + +

                                                  Fields:

                                                  +
                                                    +
                                                  • barName + string + Unique identifier for the bar. +
                                                  • +
                                                  • objectIdBg + ObjID + Object ID for the bar's background sprite. +
                                                  • +
                                                  • spriteIdBg + number + SpriteID from the specified object for the bar's background. +
                                                  • +
                                                  • colorBg + Color + Color of bar's background. +
                                                  • +
                                                  • posBg + Vec2 + X,Y position of the bar's background in screen percent (0-100). +
                                                  • +
                                                  • rotBg + number + rotation of the bar's background. sprite (0-360). +
                                                  • +
                                                  • scaleBg + Vec2 + X,Y Scaling factor for the bar's background sprite. +
                                                  • +
                                                  • alignModeBg + AlignMode + Alignment for the bar's background. +
                                                  • +
                                                  • scaleModeBg + ScaleMode + Scaling for the bar's background. +
                                                  • +
                                                  • blendModeBg + BlendID + Blending modes for the bar's background. +
                                                  • +
                                                  • objectIdBar + ObjID + Object ID for the bar sprite. +
                                                  • +
                                                  • spriteIdBar + number + SpriteID from the specified object for the bar. +
                                                  • +
                                                  • colorBar + Color + Color of the bar. +
                                                  • +
                                                  • posBar + Vec2 + X,Y position of the bar in screen percent (0-100). +
                                                  • +
                                                  • rot + number + rotation of the bar's sprite (0-360). +
                                                  • +
                                                  • scaleBar + Vec2 + X,Y Scaling factor for the bar's sprite. +
                                                  • +
                                                  • alignMode + AlignMode + Alignment for the bar. +
                                                  • +
                                                  • scaleMode + ScaleMode + Scaling for the bar. +
                                                  • +
                                                  • blendMode + BlendID + Blending modes for the bar. +
                                                  • +
                                                  • text + string + Text to display for the enemy. +
                                                  • +
                                                  • textPos + Vec2 + X,Y position of the text. +
                                                  • +
                                                  • textOptions + DisplayStringOption + alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +
                                                  • +
                                                  • textScale + number + Scale factor for the text. +
                                                  • +
                                                  • textColor + Color + Color of the text. +
                                                  • +
                                                  • hideText + bool + Whether to hide the text. +
                                                  • +
                                                  • alphaBlendSpeed + number + Speed of alpha blending for bar visibility (0-255). +
                                                  • +
                                                  • object + string + Enemy name set in Editor for which to create HP for. +
                                                  • +
                                                  • showBar + bool + Option to always show the bar whether the enemy is current target or not. Useful for boss health bars. +
                                                  • +
                                                  • blink + bool + Whether the bar blinks. +
                                                  • +
                                                  • blinkLimit + number + %Limit below which bar starts blinking (0-1). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + enemiesBarData +
                                                  +
                                                  + Table setup for creating health bars for all enemies. + + + +

                                                  Fields:

                                                  +
                                                    +
                                                  • objectIdBg + ObjID + Object ID for the bar's background sprite. +
                                                  • +
                                                  • spriteIdBg + number + SpriteID from the specified object for the bar's background. +
                                                  • +
                                                  • colorBg + Color + Color of bar's background. +
                                                  • +
                                                  • posBg + Vec2 + X,Y position of the bar's background in screen percent (0-100). +
                                                  • +
                                                  • rotBg + number + rotation of the bar's background. sprite (0-360). +
                                                  • +
                                                  • scaleBg + Vec2 + X,Y Scaling factor for the bar's background sprite. +
                                                  • +
                                                  • alignModeBg + AlignMode + Alignment for the bar's background. +
                                                  • +
                                                  • scaleModeBg + ScaleMode + Scaling for the bar's background. +
                                                  • +
                                                  • blendModeBg + BlendID + Blending modes for the bar's background. +
                                                  • +
                                                  • objectIdBar + ObjID + Object ID for the bar sprite. +
                                                  • +
                                                  • spriteIdBar + number + SpriteID from the specified object for the bar. +
                                                  • +
                                                  • colorBar + Color + Color of the bar. +
                                                  • +
                                                  • posBar + Vec2 + X,Y position of the bar in screen percent (0-100). +
                                                  • +
                                                  • rot + number + rotation of the bar's sprite (0-360). +
                                                  • +
                                                  • scaleBar + Vec2 + X,Y Scaling factor for the bar's sprite. +
                                                  • +
                                                  • alignMode + AlignMode + Alignment for the bar. +
                                                  • +
                                                  • scaleMode + ScaleMode + Scaling for the bar. +
                                                  • +
                                                  • blendMode + BlendID + Blending modes for the bar. +
                                                  • +
                                                  • textPos + number + X position of the text. +
                                                  • +
                                                  • textOptions + DisplayStringOption + alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +
                                                  • +
                                                  • textScale + number + Scale factor for the text. +
                                                  • +
                                                  • textColor + Color + Color of the text. +
                                                  • +
                                                  • hideText + bool + Whether to hide the enemy name text. +
                                                  • +
                                                  • alphaBlendSpeed + number + Speed of alpha blending for bar visibility (0-255). +
                                                  • +
                                                  • blink + bool + Whether the bar blinks. +
                                                  • +
                                                  • blinkLimit + number + %Limit below which bar starts blinking (0-1). +
                                                  • +
                                                  + + + + + +
                                                  +
                                                  + + +
                                                  +
                                                  +
                                                  +generated by TEN-LDoc (a fork of LDoc 1.4.6) +
                                                  +
                                                  + + diff --git a/Documentation/doc/5 lua utility modules/Diary.html b/Documentation/doc/5 lua utility modules/Diary.html index 0f44992ca..ee01685e7 100644 --- a/Documentation/doc/5 lua utility modules/Diary.html +++ b/Documentation/doc/5 lua utility modules/Diary.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                  3 Primitive Classes

                                                  5 Lua utility modules

                                                    +
                                                  • CustomBar
                                                  • Diary
                                                  • EventSequence
                                                  • Timer
                                                  • @@ -111,8 +115,7 @@

                                                    Lua utility module Diary

                                                    -

                                                    Diaries: - The module provides functions to create and manage Diaries.

                                                    +

                                                    This module provides functions to create and manage diaries.

                                                    It maintains diary definitions and entries through all levels and hubs. Each diary is accessed by the object that was used to create it.

                                                    @@ -291,7 +294,7 @@
                                                  • pos Vec2 - X,Y position of the bar's background in screen percent (0-100). + X,Y position of the diary background sprite in screen percent (0-100).
                                                  • rot float @@ -299,7 +302,7 @@
                                                  • scale Vec2 - X,Y Scaling factor for the bar's background sprite. + X,Y Scaling factor for the diary background sprite.
                                                  • alignMode AlignMode diff --git a/Documentation/doc/5 lua utility modules/EventSequence.html b/Documentation/doc/5 lua utility modules/EventSequence.html index 81fb79793..906d9ee53 100644 --- a/Documentation/doc/5 lua utility modules/EventSequence.html +++ b/Documentation/doc/5 lua utility modules/EventSequence.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                    3 Primitive Classes

                                                    5 Lua utility modules

                                                      +
                                                    • CustomBar
                                                    • Diary
                                                    • EventSequence
                                                    • Timer
                                                    • @@ -164,7 +168,7 @@ LevelFuncs.SpawnBaddy = function(baddy, name, pos)

                                                      Functions

                                                      - + @@ -202,7 +206,7 @@ LevelFuncs.SpawnBaddy = function(baddy, name, pos)
                                                      - Create(name, loop, timerFormat[, ...]) + Create(name, loop, timerFormat, [...])
                                                      Create (but do not start) a new event sequence. @@ -225,7 +229,7 @@ LevelFuncs.SpawnBaddy = function(baddy, name, pos)
                                                    • ... a variable number of pairs of arguments - a time in seconds, followed by the function (must be defined in the LevelFuncs table) to call once the time has elapsed, followed by another duration in seconds, another function name, etc. You can specify a function either by its name as a string, or by a table with the function name as the first member, followed by its arguments (see above example). - (optional) + Optional.
                                                    • diff --git a/Documentation/doc/5 lua utility modules/Timer.html b/Documentation/doc/5 lua utility modules/Timer.html index 85364b632..557367fd8 100644 --- a/Documentation/doc/5 lua utility modules/Timer.html +++ b/Documentation/doc/5 lua utility modules/Timer.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                      3 Primitive Classes

                                                      5 Lua utility modules

                                                      Create(name, loop, timerFormat[, ...])Create(name, loop, timerFormat, [...]) Create (but do not start) a new event sequence.
                                                      - + @@ -156,7 +160,7 @@ LevelFuncs.TriggerTimer = function(obj) - + @@ -210,7 +214,7 @@ LevelFuncs.TriggerTimer = function(obj)
                                                      - Create(name, totalTime, loop, timerFormat, func[, ...]) + Create(name, totalTime, loop, timerFormat, func, [...])
                                                      Create (but do not start) a new timer.

                                                      @@ -263,7 +267,7 @@ LevelFuncs.TriggerTimer = function(obj)
                                                    • ... a variable number of arguments with which the above function will be called - (optional) + Optional.
                                                    • @@ -308,7 +312,7 @@ LevelFuncs.TriggerTimer = function(obj)
                                                      - myTimer:SetFunction(func[, ...]) + myTimer:SetFunction(func, [...])
                                                      Give the timer a new function and args @@ -323,7 +327,7 @@ LevelFuncs.TriggerTimer = function(obj)
                                                    • ... a variable number of arguments with which the above function will be called - (optional) + Optional.
                                                    • diff --git a/Documentation/doc/5 lua utility modules/Type.html b/Documentation/doc/5 lua utility modules/Type.html index b7be0f357..8c8ce46a0 100644 --- a/Documentation/doc/5 lua utility modules/Type.html +++ b/Documentation/doc/5 lua utility modules/Type.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                      3 Primitive Classes

                                                      5 Lua utility modules

                                                        +
                                                      • CustomBar
                                                      • Diary
                                                      • EventSequence
                                                      • Timer
                                                      • diff --git a/Documentation/doc/index.html b/Documentation/doc/index.html index 28f720d02..0d8c40599 100644 --- a/Documentation/doc/index.html +++ b/Documentation/doc/index.html @@ -3,7 +3,7 @@ - TombEngine 1.7.2 (Developer) Lua API + TombEngine 1.8.2 Lua API @@ -64,6 +64,7 @@

                                                        3 Primitive Classes

                                                        5 Lua utility modules

                                                          +
                                                        • CustomBar
                                                        • Diary
                                                        • EventSequence
                                                        • Timer
                                                        • @@ -111,25 +115,25 @@
                                                          -

                                                          TombEngine 1.7.2 (Developer) scripting interface

                                                          -

                                                          Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.

                                                          +

                                                          TombEngine 1.8.2 scripting interface

                                                          +

                                                          Welcome to the TombEngine scripting API.

                                                          -

                                                          At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website.

                                                          -

                                                          Module Hierarchy (boring but important)

                                                          -

                                                          Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN. +

                                                          Note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. +At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website.

                                                          + +

                                                          Module Hierarchy

                                                          +

                                                          Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN. For convenience, these modules and classes are automatically put in the global table. For example, you can call GetMoveableByName either of these two ways:

                                                          local door = TEN.Objects.GetMoveableByName("door_type4_14")
                                                           local door = GetMoveableByName("door_type4_14")
                                                           

                                                          Always check logs/TENLog.txt

                                                          -

                                                          If you are scripting levels, TombEngine will often kick you back to the title screen, even if errorMode (see Flow.Settings) is set to ErrorMode.WARN or ErrorMode.SILENT.

                                                          +

                                                          If you are scripting levels, TombEngine will often kick you back to the title screen, even if errorMode (see Flow.Settings) is set to ErrorMode.WARN or ErrorMode.SILENT.

                                                          -

                                                          This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing end at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.

                                                          +

                                                          This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing end at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless. If this happens, check logs/TENLog.txt and look for an error message with the word "unrecoverable".

                                                          -

                                                          If this happens, check logs/TENLog.txt and look for an error message with the word "unrecoverable".

                                                          - -

                                                          Enjoy.

                                                          +

                                                          Happy building!

                                                          - squidshire and the TombEngine development team.

                                                          @@ -204,7 +208,7 @@ local door = GetMoveableByName("door_type4_14")
                                                      - + @@ -243,7 +247,11 @@ local door = GetMoveableByName("door_type4_14")
                                                      Create(name, totalTime, loop, timerFormat, func[, ...])Create(name, totalTime, loop, timerFormat, func, [...]) Create (but do not start) a new timer.
                                                      Get a timer by its name.
                                                      myTimer:SetFunction(func[, ...])myTimer:SetFunction(func, [...]) Give the timer a new function and args
                                                      Objects.LaraObjectClass for extra player-only functions.Class for player-only functions.
                                                      Objects.Moveable
                                                      - + + + + + @@ -259,7 +267,7 @@ local door = GetMoveableByName("door_type4_14") - + @@ -296,6 +304,14 @@ local door = GetMoveableByName("door_type4_14") + + + + + + + + @@ -371,10 +387,13 @@ local door = GetMoveableByName("door_type4_14")
                                                      Flow.FogDistance fog.Represesnts distance fog.
                                                      Flow.HorizonRepresents a horizon.
                                                      Flow.InventoryItem
                                                      Flow.StarfieldRepresents a starfield in the sky.Represents a star field in the sky.
                                                      ColorEffects.EffectID Constants for effect IDs.
                                                      Effects.StreamerFeatherModeConstants for feather modes.
                                                      Effects.ParticleAnimationTypeConstants for particle animation type constants.
                                                      Flow.ErrorMode Constants for error modes.

                                                      5 Lua utility modules

                                                      + + + + - + diff --git a/Documentation/doc/ldoc.css b/Documentation/doc/ldoc.css index b00cfcf57..fad2a0c62 100644 --- a/Documentation/doc/ldoc.css +++ b/Documentation/doc/ldoc.css @@ -32,7 +32,9 @@ span.types:after { content:")"; } body, td, th { font-size: .95em; line-height: 1.2em;} p { line-height: 1.2em;} -p, ul { margin: 10px 0 0 0px;} +ul { margin: 10px 0 0 0px;} + +p { margin: 3px 0px 0px 0px; } strong { font-weight: bold;} @@ -63,6 +65,10 @@ blockquote { margin-left: 3em; } ul { list-style-type: disc; } +ul li:not(:last-child) { + margin-bottom: 0.3em; +} + p.name { font-family: "Andale Mono", monospace; padding-top: 1em; @@ -103,11 +109,11 @@ table.index td { text-align: left; vertical-align: top; } #main { background-color: #f0f0f0; border-left: 2px solid #cccccc; + display: flex } #navigation { - float: left; - width: 16em; + width: 18em; vertical-align: top; background-color: #f0f0f0; overflow: visible; @@ -141,7 +147,6 @@ table.index td { text-align: left; vertical-align: top; } } #content { - margin-left: 18em; padding: 2em; width: 900px; border-left: 2px solid #cccccc; diff --git a/Documentation/generate_objectlist.ps1 b/Documentation/generate_objectlist.ps1 new file mode 100644 index 000000000..d86cd5c4e --- /dev/null +++ b/Documentation/generate_objectlist.ps1 @@ -0,0 +1,149 @@ +# PowerShell script to generate ObjectIDs.h from game_object_ids.h + +$inputFile = "../TombEngine/Objects/game_object_ids.h" # Adjust path if necessary. +$tempOutputFile = "../TombEngine/Scripting/Internal/TEN/Objects/temp.h" +$outputFile = "../TombEngine/Scripting/Internal/TEN/Objects/ObjectIDs.h" + +# Read the input file +if (-Not (Test-Path $inputFile)) +{ + Write-Host "Error: File '$inputFile' not found." + exit 1 +} + +# Get the last modified times for both files. +$inputFileLastModified = (Get-Item $inputFile).LastWriteTime +if (Test-Path $outputFile) { + $outputFileLastModified = (Get-Item $outputFile).LastWriteTime +} else { + $outputFileLastModified = [datetime]::MinValue # If output file doesn't exist, treat it as very old. +} + +# Exit early if the output file is newer than the input file. +if ($outputFileLastModified -ge $inputFileLastModified) { + Write-Host "$outputFile is up to date. No changes made." + exit 0 +} + +$content = Get-Content $inputFile + +# Extract enum values and categorize them. +$enumValues = @() +$pickupConstants = @() +$spriteConstants = @() + +$inPickupSection = $false +$inSpriteSection = $false + +foreach ($line in $content) +{ + if ($line -match "^\s*ID_([A-Za-z0-9_]+)") + { + $enumName = $matches[1] + $enumValues += $enumName + + if ($enumName -match "_ITEM|EXAMINE") + { + $pickupConstants += $enumName + } + elseif ($enumName -match "_SPRITE|_GRAPHIC|TEXTURE") + { + # These two object IDs are deprecated 3D objects, not sprites. + if ($enumName -in @("BINOCULAR_GRAPHICS", "TARGET_GRAPHICS")) + { + continue + } + + $spriteConstants += $enumName + } + + } +} + +if ($enumValues.Count -gt 0) { $enumValues = $enumValues[1..($enumValues.Count - 2)] } + +# Generate ObjectIDs.h content. +$header = @" +#pragma once + +// This file is generated automatically, do not edit it. +// Last generated on $(Get-Date -Format "dd/MM/yyyy"). + +#include +#include +#include "Objects/game_object_ids.h" + +/*** +Constants for object IDs. +@enum Objects.ObjID +@pragma nostrip +*/ + +/*** Objects.ObjID constants. + +The following constants are inside ObjID. + +"@ + +$body = $enumValues | ForEach-Object { "`t$_" } +$footer = @" +@table Members +*/ +"@ + +# Pickup Constants Section. +$pickupHeader = @" + +/*** Objects.ObjID pickup constants. + +The following ObjID members refer to pickups. + +"@ + +$pickupBody = $pickupConstants | ForEach-Object { "`t$_" } +$pickupFooter = @" +@table PickupConstants +*/ +"@ + +# Sprite Constants Section. +$spriteHeader = @" + +/*** Objects.ObjID sprite constants. + +The following ObjID members refer to sprites. + +"@ + +$spriteBody = $spriteConstants | ForEach-Object { "`t$_" } +$spriteFooter = @" +@table SpriteConstants +*/ +"@ + +# Map definition. +$mapHeader = "static const std::unordered_map GAME_OBJECT_IDS {" +$mapBody = ($enumValues | ForEach-Object { "`t" + '{ "' + "$_" + '", ID_' + "$_" + ' }' }) -join ",`r`n" +$mapFooter = "};" + +# Write to output file +$header | Set-Content $tempOutputFile +$body | Add-Content $tempOutputFile +$footer | Add-Content $tempOutputFile +$pickupHeader | Add-Content $tempOutputFile +$pickupBody | Add-Content $tempOutputFile +$pickupFooter | Add-Content $tempOutputFile +$spriteHeader | Add-Content $tempOutputFile +$spriteBody | Add-Content $tempOutputFile +$spriteFooter | Add-Content $tempOutputFile +$mapHeader | Add-Content $tempOutputFile +$mapBody | ForEach-Object { Add-Content $tempOutputFile $_ } +$mapFooter | Add-Content $tempOutputFile + +# Rename the temporary file to the final name. +if (Test-Path $outputFile) { + Remove-Item $outputFile -Force +} +Move-Item -Path $tempOutputFile -Destination $outputFile -Force + +Write-Host "Generated $outputFile successfully." \ No newline at end of file diff --git a/Documentation/ldoc.css b/Documentation/ldoc.css index 306dcd9f5..109cd5720 100644 --- a/Documentation/ldoc.css +++ b/Documentation/ldoc.css @@ -32,7 +32,9 @@ span.types:after { content:")"; } body, td, th { font-size: .95em; line-height: 1.2em;} p { line-height: 1.2em;} -p, ul { margin: 10px 0 0 0px;} +ul { margin: 10px 0 0 0px;} + +p { margin: 3px 0px 0px 0px; } strong { font-weight: bold;} @@ -63,6 +65,10 @@ blockquote { margin-left: 3em; } ul { list-style-type: disc; } +ul li:not(:last-child) { + margin-bottom: 0.3em; +} + p.name { font-family: "Andale Mono", monospace; padding-top: 1em; @@ -103,11 +109,11 @@ table.index td { text-align: left; vertical-align: top; } #main { background-color: #f0f0f0; border-left: 2px solid #cccccc; + display: flex } #navigation { - float: left; - width: 16em; + width: 18em; vertical-align: top; background-color: #f0f0f0; overflow: visible; @@ -141,7 +147,6 @@ table.index td { text-align: left; vertical-align: top; } } #content { - margin-left: 18em; padding: 2em; width: 900px; border-left: 2px solid #cccccc; diff --git a/Documentation/ldoc.ltp b/Documentation/ldoc.ltp index 77472d077..5034016d4 100644 --- a/Documentation/ldoc.ltp +++ b/Documentation/ldoc.ltp @@ -216,12 +216,12 @@ # end $(M(item.params.map[p],item)) # if def == true then - (optional) + Optional. # elseif def then - (default $(def)) + Default: $(def). # end # if item:readonly(p) then - readonly + Read-only. # end # end diff --git a/LICENSE b/LICENSE index 350616db7..1010c5693 100644 --- a/LICENSE +++ b/LICENSE @@ -1,16 +1,23 @@ -MIT License +Modified MIT License (for non-commercial use only) Copyright (c) 2025 TombEngine Team Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +of this software and associated documentation files (the “Software”), to use, +copy, modify, merge, publish, and distribute copies of the Software, and to +permit persons to whom the Software is furnished to do so, for non-commercial +purposes only, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Commercial use of the Software — including, but not limited to, selling, +renting, leasing, or using it in a product or service for which you receive +compensation (monetary or otherwise) — is strictly prohibited. + +2. The Software may be combined with proprietary or closed-source third-party +components, provided those components are available for non-commercial use, +and the resulting product is not used for commercial purposes. + +3. The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/Libs/vlc/libvlc.h b/Libs/vlc/libvlc.h new file mode 100644 index 000000000..0970dc294 --- /dev/null +++ b/Libs/vlc/libvlc.h @@ -0,0 +1,546 @@ +/***************************************************************************** + * libvlc.h: libvlc external API + ***************************************************************************** + * Copyright (C) 1998-2009 VLC authors and VideoLAN + * + * Authors: Clément Stenac + * Jean-Paul Saman + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +/** + * \defgroup libvlc LibVLC + * LibVLC is the external programming interface of the VLC media player. + * It is used to embed VLC into other applications or frameworks. + * @{ + * \file + * LibVLC core external API + */ + +#ifndef VLC_LIBVLC_H +#define VLC_LIBVLC_H 1 + +#if defined (_WIN32) && defined (LIBVLC_DLL_EXPORT) +# define LIBVLC_API __declspec(dllexport) +#elif defined (__GNUC__) && (__GNUC__ >= 4) +# define LIBVLC_API __attribute__((visibility("default"))) +#else +# define LIBVLC_API +#endif + +#ifdef LIBVLC_INTERNAL_ +/* Avoid unhelpful warnings from libvlc with our deprecated APIs */ +# define LIBVLC_DEPRECATED +#elif defined(__GNUC__) && \ + (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) +# define LIBVLC_DEPRECATED __attribute__((deprecated)) +#else +# define LIBVLC_DEPRECATED +#endif + +#include +#include +#include + +# ifdef __cplusplus +extern "C" { +# endif + +/** \defgroup libvlc_core LibVLC core + * \ingroup libvlc + * Before it can do anything useful, LibVLC must be initialized. + * You can create one (or more) instance(s) of LibVLC in a given process, + * with libvlc_new() and destroy them with libvlc_release(). + * + * \version Unless otherwise stated, these functions are available + * from LibVLC versions numbered 1.1.0 or more. + * Earlier versions (0.9.x and 1.0.x) are not compatible. + * @{ + */ + +/** This structure is opaque. It represents a libvlc instance */ +typedef struct libvlc_instance_t libvlc_instance_t; + +typedef int64_t libvlc_time_t; + +/** \defgroup libvlc_error LibVLC error handling + * @{ + */ + +/** + * A human-readable error message for the last LibVLC error in the calling + * thread. The resulting string is valid until another error occurs (at least + * until the next LibVLC call). + * + * @warning + * This will be NULL if there was no error. + */ +LIBVLC_API const char *libvlc_errmsg (void); + +/** + * Clears the LibVLC error status for the current thread. This is optional. + * By default, the error status is automatically overridden when a new error + * occurs, and destroyed when the thread exits. + */ +LIBVLC_API void libvlc_clearerr (void); + +/** + * Sets the LibVLC error status and message for the current thread. + * Any previous error is overridden. + * \param fmt the format string + * \param ... the arguments for the format string + * \return a nul terminated string in any case + */ +const char *libvlc_printerr (const char *fmt, ...); + +/**@} */ + +/** + * Create and initialize a libvlc instance. + * This functions accept a list of "command line" arguments similar to the + * main(). These arguments affect the LibVLC instance default configuration. + * + * \note + * LibVLC may create threads. Therefore, any thread-unsafe process + * initialization must be performed before calling libvlc_new(). In particular + * and where applicable: + * - setlocale() and textdomain(), + * - setenv(), unsetenv() and putenv(), + * - with the X11 display system, XInitThreads() + * (see also libvlc_media_player_set_xwindow()) and + * - on Microsoft Windows, SetErrorMode(). + * - sigprocmask() shall never be invoked; pthread_sigmask() can be used. + * + * On POSIX systems, the SIGCHLD signal must not be ignored, i.e. the + * signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. + * Also while LibVLC is active, the wait() function shall not be called, and + * any call to waitpid() shall use a strictly positive value for the first + * parameter (i.e. the PID). Failure to follow those rules may lead to a + * deadlock or a busy loop. + * Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, + * even if it is not, in principles, necessary, e.g.: + * @code + sigset_t set; + + signal(SIGCHLD, SIG_DFL); + sigemptyset(&set); + sigaddset(&set, SIGPIPE); + pthread_sigmask(SIG_BLOCK, &set, NULL); + * @endcode + * + * On Microsoft Windows, setting the default DLL directories to SYSTEM32 + * exclusively is strongly recommended for security reasons: + * @code + SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32); + * @endcode + * + * \version + * Arguments are meant to be passed from the command line to LibVLC, just like + * VLC media player does. The list of valid arguments depends on the LibVLC + * version, the operating system and platform, and set of available LibVLC + * plugins. Invalid or unsupported arguments will cause the function to fail + * (i.e. return NULL). Also, some arguments may alter the behaviour or + * otherwise interfere with other LibVLC functions. + * + * \warning + * There is absolutely no warranty or promise of forward, backward and + * cross-platform compatibility with regards to libvlc_new() arguments. + * We recommend that you do not use them, other than when debugging. + * + * \param argc the number of arguments (should be 0) + * \param argv list of arguments (should be NULL) + * \return the libvlc instance or NULL in case of error + */ +LIBVLC_API libvlc_instance_t * +libvlc_new( int argc , const char *const *argv ); + +/** + * Decrement the reference count of a libvlc instance, and destroy it + * if it reaches zero. + * + * \param p_instance the instance to destroy + */ +LIBVLC_API void libvlc_release( libvlc_instance_t *p_instance ); + +/** + * Increments the reference count of a libvlc instance. + * The initial reference count is 1 after libvlc_new() returns. + * + * \param p_instance the instance to reference + * \return the same object + */ +LIBVLC_API libvlc_instance_t *libvlc_retain( libvlc_instance_t *p_instance ); + +/** + * Get the ABI version of the libvlc library. + * + * This is different than the VLC version, which is the version of the whole + * VLC package. The value is the same as LIBVLC_ABI_VERSION_INT used when + * compiling. + * + * \return a value with the following mask in hexadecimal + * 0xFF000000: major VLC version, similar to VLC major version, + * 0x00FF0000: major ABI version, incremented incompatible changes are added, + * 0x0000FF00: minor ABI version, incremented when new functions are added + * 0x000000FF: micro ABI version, incremented with new release/builds + * + * \note This the same value as the .so version but cross platform. + */ +LIBVLC_API int libvlc_abi_version(void); + +/** + * Sets the application name. LibVLC passes this as the user agent string + * when a protocol requires it. + * + * \param p_instance LibVLC instance + * \param name human-readable application name, e.g. "FooBar player 1.2.3" + * \param http HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0" + * \version LibVLC 1.1.1 or later + */ +LIBVLC_API +void libvlc_set_user_agent( libvlc_instance_t *p_instance, + const char *name, const char *http ); + +/** + * Sets some meta-information about the application. + * See also libvlc_set_user_agent(). + * + * \param p_instance LibVLC instance + * \param id Java-style application identifier, e.g. "com.acme.foobar" + * \param version application version numbers, e.g. "1.2.3" + * \param icon application icon name, e.g. "foobar" + * \version LibVLC 2.1.0 or later. + */ +LIBVLC_API +void libvlc_set_app_id( libvlc_instance_t *p_instance, const char *id, + const char *version, const char *icon ); + +/** + * Retrieve libvlc version. + * + * Example: "1.1.0-git The Luggage" + * + * \return a string containing the libvlc version + */ +LIBVLC_API const char * libvlc_get_version(void); + +/** + * Retrieve libvlc compiler version. + * + * Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)" + * + * \return a string containing the libvlc compiler version + */ +LIBVLC_API const char * libvlc_get_compiler(void); + +/** + * Retrieve libvlc changeset. + * + * Example: "aa9bce0bc4" + * + * \return a string containing the libvlc changeset + */ +LIBVLC_API const char * libvlc_get_changeset(void); + +/** + * Frees an heap allocation returned by a LibVLC function. + * If you know you're using the same underlying C run-time as the LibVLC + * implementation, then you can call ANSI C free() directly instead. + * + * \param ptr the pointer + */ +LIBVLC_API void libvlc_free( void *ptr ); + +/** \defgroup libvlc_event LibVLC asynchronous events + * LibVLC emits asynchronous events. + * + * Several LibVLC objects (such @ref libvlc_instance_t as + * @ref libvlc_media_player_t) generate events asynchronously. Each of them + * provides @ref libvlc_event_manager_t event manager. You can subscribe to + * events with libvlc_event_attach() and unsubscribe with + * libvlc_event_detach(). + * @{ + */ + +/** + * Event manager that belongs to a libvlc object, and from whom events can + * be received. + */ +typedef struct libvlc_event_manager_t libvlc_event_manager_t; + +struct libvlc_event_t; + +/** + * Type of a LibVLC event. + */ +typedef int libvlc_event_type_t; + +/** + * Callback function notification + * \param p_event the event triggering the callback + */ +typedef void ( *libvlc_callback_t )( const struct libvlc_event_t *p_event, void *p_data ); + +/** + * Register for an event notification. + * + * \param p_event_manager the event manager to which you want to attach to. + * Generally it is obtained by vlc_my_object_event_manager() where + * my_object is the object you want to listen to. + * \param i_event_type the desired event to which we want to listen + * \param f_callback the function to call when i_event_type occurs + * \param user_data user provided data to carry with the event + * \return 0 on success, ENOMEM on error + */ +LIBVLC_API int libvlc_event_attach( libvlc_event_manager_t *p_event_manager, + libvlc_event_type_t i_event_type, + libvlc_callback_t f_callback, + void *user_data ); + +/** + * Unregister an event notification. + * + * \param p_event_manager the event manager + * \param i_event_type the desired event to which we want to unregister + * \param f_callback the function to call when i_event_type occurs + * \param p_user_data user provided data to carry with the event + */ +LIBVLC_API void libvlc_event_detach( libvlc_event_manager_t *p_event_manager, + libvlc_event_type_t i_event_type, + libvlc_callback_t f_callback, + void *p_user_data ); + +/** @} */ + +/** \defgroup libvlc_log LibVLC logging + * libvlc_log_* functions provide access to the LibVLC messages log. + * This is used for logging and debugging. + * @{ + */ + +/** + * Logging messages level. + * \note Future LibVLC versions may define new levels. + */ +enum libvlc_log_level +{ + LIBVLC_DEBUG=0, /**< Debug message */ + LIBVLC_NOTICE=2, /**< Important informational message */ + LIBVLC_WARNING=3, /**< Warning (potential error) message */ + LIBVLC_ERROR=4 /**< Error message */ +}; + +typedef struct vlc_log_t libvlc_log_t; + +/** + * Gets log message debug infos. + * + * This function retrieves self-debug information about a log message: + * - the name of the VLC module emitting the message, + * - the name of the source code module (i.e. file) and + * - the line number within the source code module. + * + * The returned module name and file name will be NULL if unknown. + * The returned line number will similarly be zero if unknown. + * + * \param ctx message context (as passed to the @ref libvlc_log_cb callback) + * \param module module name storage (or NULL) [OUT] + * \param file source code file name storage (or NULL) [OUT] + * \param line source code file line number storage (or NULL) [OUT] + * \warning The returned module name and source code file name, if non-NULL, + * are only valid until the logging callback returns. + * + * \version LibVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_log_get_context(const libvlc_log_t *ctx, + const char **module, const char **file, unsigned *line); + +/** + * Gets log message info. + * + * This function retrieves meta-information about a log message: + * - the type name of the VLC object emitting the message, + * - the object header if any, and + * - a temporaly-unique object identifier. + * + * This information is mainly meant for manual troubleshooting. + * + * The returned type name may be "generic" if unknown, but it cannot be NULL. + * The returned header will be NULL if unset; in current versions, the header + * is used to distinguish for VLM inputs. + * The returned object ID will be zero if the message is not associated with + * any VLC object. + * + * \param ctx message context (as passed to the @ref libvlc_log_cb callback) + * \param name object name storage (or NULL) [OUT] + * \param header object header (or NULL) [OUT] + * \param id temporarily-unique object identifier (or 0) [OUT] + * \warning The returned module name and source code file name, if non-NULL, + * are only valid until the logging callback returns. + * + * \version LibVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_log_get_object(const libvlc_log_t *ctx, + const char **name, const char **header, uintptr_t *id); + +/** + * Callback prototype for LibVLC log message handler. + * + * \param data data pointer as given to libvlc_log_set() + * \param level message level (@ref libvlc_log_level) + * \param ctx message context (meta-information about the message) + * \param fmt printf() format string (as defined by ISO C11) + * \param args variable argument list for the format + * \note Log message handlers must be thread-safe. + * \warning The message context pointer, the format string parameters and the + * variable arguments are only valid until the callback returns. + */ +typedef void (*libvlc_log_cb)(void *data, int level, const libvlc_log_t *ctx, + const char *fmt, va_list args); + +/** + * Unsets the logging callback. + * + * This function deregisters the logging callback for a LibVLC instance. + * This is rarely needed as the callback is implicitly unset when the instance + * is destroyed. + * + * \note This function will wait for any pending callbacks invocation to + * complete (causing a deadlock if called from within the callback). + * + * \param p_instance libvlc instance + * \version LibVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_log_unset( libvlc_instance_t *p_instance ); + +/** + * Sets the logging callback for a LibVLC instance. + * + * This function is thread-safe: it will wait for any pending callbacks + * invocation to complete. + * + * \param cb callback function pointer + * \param data opaque data pointer for the callback function + * + * \note Some log messages (especially debug) are emitted by LibVLC while + * is being initialized. These messages cannot be captured with this interface. + * + * \warning A deadlock may occur if this function is called from the callback. + * + * \param p_instance libvlc instance + * \version LibVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_log_set( libvlc_instance_t *p_instance, + libvlc_log_cb cb, void *data ); + + +/** + * Sets up logging to a file. + * \param p_instance libvlc instance + * \param stream FILE pointer opened for writing + * (the FILE pointer must remain valid until libvlc_log_unset()) + * \version LibVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_log_set_file( libvlc_instance_t *p_instance, FILE *stream ); + +/** @} */ + +/** + * Description of a module. + */ +typedef struct libvlc_module_description_t +{ + char *psz_name; + char *psz_shortname; + char *psz_longname; + char *psz_help; + char *psz_help_html; + struct libvlc_module_description_t *p_next; +} libvlc_module_description_t; + +/** + * Release a list of module descriptions. + * + * \param p_list the list to be released + */ +LIBVLC_API +void libvlc_module_description_list_release( libvlc_module_description_t *p_list ); + +/** + * Returns a list of audio filters that are available. + * + * \param p_instance libvlc instance + * + * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release(). + * In case of an error, NULL is returned. + * + * \see libvlc_module_description_t + * \see libvlc_module_description_list_release + */ +LIBVLC_API +libvlc_module_description_t *libvlc_audio_filter_list_get( libvlc_instance_t *p_instance ); + +/** + * Returns a list of video filters that are available. + * + * \param p_instance libvlc instance + * + * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release(). + * In case of an error, NULL is returned. + * + * \see libvlc_module_description_t + * \see libvlc_module_description_list_release + */ +LIBVLC_API +libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance ); + +/** @} */ + +/** \defgroup libvlc_clock LibVLC time + * These functions provide access to the LibVLC time/clock. + * @{ + */ + +/** + * Return the current time as defined by LibVLC. The unit is the microsecond. + * Time increases monotonically (regardless of time zone changes and RTC + * adjustments). + * The origin is arbitrary but consistent across the whole system + * (e.g. the system uptime, the time since the system was booted). + * \note On systems that support it, the POSIX monotonic clock is used. + */ +LIBVLC_API +int64_t libvlc_clock(void); + +/** + * Return the delay (in microseconds) until a certain timestamp. + * \param pts timestamp + * \return negative if timestamp is in the past, + * positive if it is in the future + */ +static inline int64_t libvlc_delay(int64_t pts) +{ + return pts - libvlc_clock(); +} + +/** @} */ + +# ifdef __cplusplus +} +# endif + +#endif /** @} */ diff --git a/Libs/vlc/libvlc_dialog.h b/Libs/vlc/libvlc_dialog.h new file mode 100644 index 000000000..e87d8464c --- /dev/null +++ b/Libs/vlc/libvlc_dialog.h @@ -0,0 +1,260 @@ +/***************************************************************************** + * libvlc_dialog.h: libvlc dialog API + ***************************************************************************** + * Copyright © 2016 VLC authors and VideoLAN + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef LIBVLC_DIALOG_H +#define LIBVLC_DIALOG_H 1 + +#include + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct libvlc_dialog_id libvlc_dialog_id; + +/** + * @defgroup libvlc_dialog LibVLC dialog + * @ingroup libvlc + * @{ + * @file + * LibVLC dialog external API + */ + +typedef enum libvlc_dialog_question_type +{ + LIBVLC_DIALOG_QUESTION_NORMAL, + LIBVLC_DIALOG_QUESTION_WARNING, + LIBVLC_DIALOG_QUESTION_CRITICAL, +} libvlc_dialog_question_type; + +/** + * Dialog callbacks to be implemented + * + * @attention starting with vlc 4.0.0 the error callback (pf_display_error) is + * no longer part of this struct and need to be registered separately + * using @a libvlc_dialog_set_error_callback + * + * @see libvlc_dialog_set_error_callback + */ +typedef struct libvlc_dialog_cbs +{ + /** + * Called when a login dialog needs to be displayed + * + * You can interact with this dialog by calling libvlc_dialog_post_login() + * to post an answer or libvlc_dialog_dismiss() to cancel this dialog. + * + * @note to receive this callback, libvlc_dialog_cbs.pf_cancel should not be + * NULL. + * + * @param p_data opaque pointer for the callback + * @param p_id id used to interact with the dialog + * @param psz_title title of the dialog + * @param psz_text text of the dialog + * @param psz_default_username user name that should be set on the user form + * @param b_ask_store if true, ask the user if he wants to save the + * credentials + */ + void (*pf_display_login)(void *p_data, libvlc_dialog_id *p_id, + const char *psz_title, const char *psz_text, + const char *psz_default_username, + bool b_ask_store); + + /** + * Called when a question dialog needs to be displayed + * + * You can interact with this dialog by calling libvlc_dialog_post_action() + * to post an answer or libvlc_dialog_dismiss() to cancel this dialog. + * + * @note to receive this callback, libvlc_dialog_cbs.pf_cancel should not be + * NULL. + * + * @param p_data opaque pointer for the callback + * @param p_id id used to interact with the dialog + * @param psz_title title of the dialog + * @param psz_text text of the dialog + * @param i_type question type (or severity) of the dialog + * @param psz_cancel text of the cancel button + * @param psz_action1 text of the first button, if NULL, don't display this + * button + * @param psz_action2 text of the second button, if NULL, don't display + * this button + */ + void (*pf_display_question)(void *p_data, libvlc_dialog_id *p_id, + const char *psz_title, const char *psz_text, + libvlc_dialog_question_type i_type, + const char *psz_cancel, const char *psz_action1, + const char *psz_action2); + + /** + * Called when a progress dialog needs to be displayed + * + * If cancellable (psz_cancel != NULL), you can cancel this dialog by + * calling libvlc_dialog_dismiss() + * + * @note to receive this callback, libvlc_dialog_cbs.pf_cancel and + * libvlc_dialog_cbs.pf_update_progress should not be NULL. + * + * @param p_data opaque pointer for the callback + * @param p_id id used to interact with the dialog + * @param psz_title title of the dialog + * @param psz_text text of the dialog + * @param b_indeterminate true if the progress dialog is indeterminate + * @param f_position initial position of the progress bar (between 0.0 and + * 1.0) + * @param psz_cancel text of the cancel button, if NULL the dialog is not + * cancellable + */ + void (*pf_display_progress)(void *p_data, libvlc_dialog_id *p_id, + const char *psz_title, const char *psz_text, + bool b_indeterminate, float f_position, + const char *psz_cancel); + + /** + * Called when a displayed dialog needs to be cancelled + * + * The implementation must call libvlc_dialog_dismiss() to really release + * the dialog. + * + * @param p_data opaque pointer for the callback + * @param p_id id of the dialog + */ + void (*pf_cancel)(void *p_data, libvlc_dialog_id *p_id); + + /** + * Called when a progress dialog needs to be updated + * + * @param p_data opaque pointer for the callback + * @param p_id id of the dialog + * @param f_position osition of the progress bar (between 0.0 and 1.0) + * @param psz_text new text of the progress dialog + */ + void (*pf_update_progress)(void *p_data, libvlc_dialog_id *p_id, + float f_position, const char *psz_text); +} libvlc_dialog_cbs; + + +/** + * Called when an error message needs to be displayed + * + * @param p_data opaque pointer for the callback + * @param psz_title title of the dialog + * @param psz_text text of the dialog + */ +typedef void (*libvlc_dialog_error_cbs)(void *p_data, const char *psz_title, const char *psz_text); + +/** + * Register callbacks in order to handle VLC dialogs + * + * @version LibVLC 3.0.0 and later. + * + * @param p_instance the libvlc instance to attach the dialog callbacks to + * @param p_cbs a pointer to callbacks, or NULL to unregister callbacks. + * @param p_data opaque pointer for the callback + */ +LIBVLC_API void +libvlc_dialog_set_callbacks(libvlc_instance_t *p_instance, + const libvlc_dialog_cbs *p_cbs, void *p_data); + +/* +* Register callback in order to handle VLC error messages +* +* @version LibVLC 4.0.0 and later. +* +* @param p_cbs a pointer to callback, or NULL to unregister callback. +* @param p_data opaque pointer for the callback +*/ +LIBVLC_API void +libvlc_dialog_set_error_callback(libvlc_instance_t *p_instance, + libvlc_dialog_error_cbs p_cbs, void *p_data); + +/** + * Associate an opaque pointer with the dialog id + * + * @version LibVLC 3.0.0 and later. + */ +LIBVLC_API void +libvlc_dialog_set_context(libvlc_dialog_id *p_id, void *p_context); + +/** + * Return the opaque pointer associated with the dialog id + * \see libvlc_dialog_set_context + * @version LibVLC 3.0.0 and later. + */ +LIBVLC_API void * +libvlc_dialog_get_context(libvlc_dialog_id *p_id); + +/** + * Post a login answer + * + * After this call, p_id won't be valid anymore + * + * @see libvlc_dialog_cbs.pf_display_login + * + * @version LibVLC 3.0.0 and later. + * + * @param p_id id of the dialog + * @param psz_username valid and non empty string + * @param psz_password valid string (can be empty) + * @param b_store if true, store the credentials + * @return 0 on success, or -1 on error + */ +LIBVLC_API int +libvlc_dialog_post_login(libvlc_dialog_id *p_id, const char *psz_username, + const char *psz_password, bool b_store); + +/** + * Post a question answer + * + * After this call, p_id won't be valid anymore + * + * @see libvlc_dialog_cbs.pf_display_question + * + * @version LibVLC 3.0.0 and later. + * + * @param p_id id of the dialog + * @param i_action 1 for action1, 2 for action2 + * @return 0 on success, or -1 on error + */ +LIBVLC_API int +libvlc_dialog_post_action(libvlc_dialog_id *p_id, int i_action); + +/** + * Dismiss a dialog + * + * After this call, p_id won't be valid anymore + * + * @see libvlc_dialog_cbs.pf_cancel + * + * @version LibVLC 3.0.0 and later. + * + * @param p_id id of the dialog + * @return 0 on success, or -1 on error + */ +LIBVLC_API int +libvlc_dialog_dismiss(libvlc_dialog_id *p_id); + +/** @} */ + +# ifdef __cplusplus +} +# endif + +#endif /* LIBVLC_DIALOG_H */ diff --git a/Libs/vlc/libvlc_events.h b/Libs/vlc/libvlc_events.h new file mode 100644 index 000000000..3e4de7e46 --- /dev/null +++ b/Libs/vlc/libvlc_events.h @@ -0,0 +1,457 @@ +/***************************************************************************** + * libvlc_events.h: libvlc_events external API structure + ***************************************************************************** + * Copyright (C) 1998-2010 VLC authors and VideoLAN + * + * Authors: Filippo Carone + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef LIBVLC_EVENTS_H +#define LIBVLC_EVENTS_H 1 + +# include +# include +# include +# include + +/** + * \file + * This file defines libvlc_event external API + */ + +# ifdef __cplusplus +extern "C" { +# else +# include +# endif + +typedef struct libvlc_renderer_item_t libvlc_renderer_item_t; +typedef struct libvlc_title_description_t libvlc_title_description_t; +typedef struct libvlc_picture_t libvlc_picture_t; +typedef struct libvlc_picture_list_t libvlc_picture_list_t; +typedef struct libvlc_media_t libvlc_media_t; +typedef struct libvlc_media_list_t libvlc_media_list_t; + +/** + * \ingroup libvlc_event + * @{ + */ + +/** + * Event types + */ +enum libvlc_event_e { + /* Append new event types at the end of a category. + * Do not remove, insert or re-order any entry. + */ + + /** + * 1 or several Metadata of a \link #libvlc_media_t media item\endlink changed + */ + libvlc_MediaMetaChanged=0, + /** + * Subitem was added to a \link #libvlc_media_t media item\endlink + * \see libvlc_media_subitems() + */ + libvlc_MediaSubItemAdded, + /** + * Deprecated, use libvlc_MediaParsedChanged or libvlc_MediaPlayerLengthChanged. + */ + libvlc_MediaDurationChanged, + /** + * Parsing state of a \link #libvlc_media_t media item\endlink changed + * \see libvlc_media_parse_request(), + * libvlc_media_get_parsed_status(), + * libvlc_media_parse_stop() + */ + libvlc_MediaParsedChanged, + + /* Removed: libvlc_MediaFreed, */ + /* Removed: libvlc_MediaStateChanged */ + + /** + * Subitem tree was added to a \link #libvlc_media_t media item\endlink + */ + libvlc_MediaSubItemTreeAdded = libvlc_MediaParsedChanged + 3, + /** + * A thumbnail generation for this \link #libvlc_media_t media \endlink completed. + * \see libvlc_media_thumbnail_request_by_time() + * \see libvlc_media_thumbnail_request_by_pos() + */ + libvlc_MediaThumbnailGenerated, + /** + * One or more embedded thumbnails were found during the media preparsing + * The user can hold these picture(s) using libvlc_picture_retain if they + * wish to use them + */ + libvlc_MediaAttachedThumbnailsFound, + + libvlc_MediaPlayerMediaChanged=0x100, + libvlc_MediaPlayerNothingSpecial, + libvlc_MediaPlayerOpening, + libvlc_MediaPlayerBuffering, + libvlc_MediaPlayerPlaying, + libvlc_MediaPlayerPaused, + libvlc_MediaPlayerStopped, + libvlc_MediaPlayerForward, + libvlc_MediaPlayerBackward, + libvlc_MediaPlayerStopping, + libvlc_MediaPlayerEncounteredError, + libvlc_MediaPlayerTimeChanged, + libvlc_MediaPlayerPositionChanged, + libvlc_MediaPlayerSeekableChanged, + libvlc_MediaPlayerPausableChanged, + /* libvlc_MediaPlayerTitleChanged, */ + libvlc_MediaPlayerSnapshotTaken = libvlc_MediaPlayerPausableChanged + 2, + libvlc_MediaPlayerLengthChanged, + libvlc_MediaPlayerVout, + + /* libvlc_MediaPlayerScrambledChanged, use libvlc_MediaPlayerProgramUpdated */ + + /** A track was added, cf. media_player_es_changed in \ref libvlc_event_t.u + * to get the id of the new track. */ + libvlc_MediaPlayerESAdded = libvlc_MediaPlayerVout + 2, + /** A track was removed, cf. media_player_es_changed in \ref + * libvlc_event_t.u to get the id of the removed track. */ + libvlc_MediaPlayerESDeleted, + /** Tracks were selected or unselected, cf. + * media_player_es_selection_changed in \ref libvlc_event_t.u to get the + * unselected and/or the selected track ids. */ + libvlc_MediaPlayerESSelected, + libvlc_MediaPlayerCorked, + libvlc_MediaPlayerUncorked, + libvlc_MediaPlayerMuted, + libvlc_MediaPlayerUnmuted, + libvlc_MediaPlayerAudioVolume, + libvlc_MediaPlayerAudioDevice, + /** A track was updated, cf. media_player_es_changed in \ref + * libvlc_event_t.u to get the id of the updated track. */ + libvlc_MediaPlayerESUpdated, + libvlc_MediaPlayerProgramAdded, + libvlc_MediaPlayerProgramDeleted, + libvlc_MediaPlayerProgramSelected, + libvlc_MediaPlayerProgramUpdated, + /** + * The title list changed, call + * libvlc_media_player_get_full_title_descriptions() to get the new list. + */ + libvlc_MediaPlayerTitleListChanged, + /** + * The title selection changed, cf media_player_title_selection_changed in + * \ref libvlc_event_t.u + */ + libvlc_MediaPlayerTitleSelectionChanged, + libvlc_MediaPlayerChapterChanged, + libvlc_MediaPlayerRecordChanged, + + /** + * A \link #libvlc_media_t media item\endlink was added to a + * \link #libvlc_media_list_t media list\endlink. + */ + libvlc_MediaListItemAdded=0x200, + /** + * A \link #libvlc_media_t media item\endlink is about to get + * added to a \link #libvlc_media_list_t media list\endlink. + */ + libvlc_MediaListWillAddItem, + /** + * A \link #libvlc_media_t media item\endlink was deleted from + * a \link #libvlc_media_list_t media list\endlink. + */ + libvlc_MediaListItemDeleted, + /** + * A \link #libvlc_media_t media item\endlink is about to get + * deleted from a \link #libvlc_media_list_t media list\endlink. + */ + libvlc_MediaListWillDeleteItem, + /** + * A \link #libvlc_media_list_t media list\endlink has reached the + * end. + * All \link #libvlc_media_t items\endlink were either added (in + * case of a \ref libvlc_media_discoverer_t) or parsed (preparser). + */ + libvlc_MediaListEndReached, + + /** + * \deprecated No longer used. + * This belonged to the removed libvlc_media_list_view_t + */ + libvlc_MediaListViewItemAdded LIBVLC_DEPRECATED =0x300, + /** + * \deprecated No longer used. + * This belonged to the removed libvlc_media_list_view_t + */ + libvlc_MediaListViewWillAddItem LIBVLC_DEPRECATED, + /** + * \deprecated No longer used. + * This belonged to the removed libvlc_media_list_view_t + */ + libvlc_MediaListViewItemDeleted LIBVLC_DEPRECATED, + /** + * \deprecated No longer used. + * This belonged to the removed libvlc_media_list_view_t + */ + libvlc_MediaListViewWillDeleteItem LIBVLC_DEPRECATED, + + /** + * Playback of a \link #libvlc_media_list_player_t media list + * player\endlink has started. + */ + libvlc_MediaListPlayerPlayed=0x400, + + /** + * The current \link #libvlc_media_t item\endlink of a + * \link #libvlc_media_list_player_t media list player\endlink + * has changed to a different item. + */ + libvlc_MediaListPlayerNextItemSet, + + /** + * Playback of a \link #libvlc_media_list_player_t media list + * player\endlink has stopped. + */ + libvlc_MediaListPlayerStopped, + + /** + * A new \link #libvlc_renderer_item_t renderer item\endlink was found by a + * \link #libvlc_renderer_discoverer_t renderer discoverer\endlink. + * The renderer item is valid until deleted. + */ + libvlc_RendererDiscovererItemAdded=0x502, + + /** + * A previously discovered \link #libvlc_renderer_item_t renderer item\endlink + * was deleted by a \link #libvlc_renderer_discoverer_t renderer discoverer\endlink. + * The renderer item is no longer valid. + */ + libvlc_RendererDiscovererItemDeleted, + + /** + * The current media set into the \ref libvlc_media_player_t is stopping. + * + * This event can be used to notify when the media callbacks, initialized + * from \ref libvlc_media_new_callbacks, should be interrupted, and in + * particular the \ref libvlc_media_read_cb. It can also be used to signal + * the application state that any input resource (webserver, file mounting, + * etc) can be discarded. Output resources still need to be active until + * the player switches to the \ref libvlc_Stopped state. + */ + libvlc_MediaPlayerMediaStopping, +}; + +/** + * A LibVLC event + */ +typedef struct libvlc_event_t +{ + int type; /**< Event type (see @ref libvlc_event_e) */ + void *p_obj; /**< Object emitting the event */ + union + { + /* media descriptor */ + struct + { + libvlc_meta_t meta_type; /**< Deprecated, any meta_type can change */ + } media_meta_changed; + struct + { + libvlc_media_t * new_child; + } media_subitem_added; + struct + { + int64_t new_duration; + } media_duration_changed; + struct + { + int new_status; /**< see @ref libvlc_media_parsed_status_t */ + } media_parsed_changed; + struct + { + int new_state; /**< see @ref libvlc_state_t */ + } media_state_changed; + struct + { + libvlc_picture_t* p_thumbnail; + } media_thumbnail_generated; + struct + { + libvlc_media_t * item; + } media_subitemtree_added; + struct + { + libvlc_picture_list_t* thumbnails; + } media_attached_thumbnails_found; + + /* media instance */ + struct + { + float new_cache; + } media_player_buffering; + struct + { + int new_chapter; + } media_player_chapter_changed; + struct + { + double new_position; + } media_player_position_changed; + struct + { + libvlc_time_t new_time; + } media_player_time_changed; + struct + { + const libvlc_title_description_t *title; + int index; + } media_player_title_selection_changed; + struct + { + int new_seekable; + } media_player_seekable_changed; + struct + { + int new_pausable; + } media_player_pausable_changed; + struct + { + int new_scrambled; + } media_player_scrambled_changed; + struct + { + int new_count; + } media_player_vout; + + /* media list */ + struct + { + libvlc_media_t * item; + int index; + } media_list_item_added; + struct + { + libvlc_media_t * item; + int index; + } media_list_will_add_item; + struct + { + libvlc_media_t * item; + int index; + } media_list_item_deleted; + struct + { + libvlc_media_t * item; + int index; + } media_list_will_delete_item; + + /* media list player */ + struct + { + libvlc_media_t * item; + } media_list_player_next_item_set; + + /* snapshot taken */ + struct + { + char* psz_filename ; + } media_player_snapshot_taken ; + + /* Length changed */ + struct + { + libvlc_time_t new_length; + } media_player_length_changed; + + /* Extra MediaPlayer */ + struct + { + libvlc_media_t * new_media; + } media_player_media_changed; + + struct + { + libvlc_media_t * media; + } media_player_media_stopping; + + + /* ESAdded, ESDeleted, ESUpdated */ + struct + { + libvlc_track_type_t i_type; + int i_id; /**< Deprecated, use psz_id */ + /** Call libvlc_media_player_get_track_from_id() to get the track + * description. */ + const char *psz_id; + } media_player_es_changed; + + /* ESSelected */ + struct + { + libvlc_track_type_t i_type; + const char *psz_unselected_id; + const char *psz_selected_id; + } media_player_es_selection_changed; + + /* ProgramAdded, ProgramDeleted, ProgramUpdated */ + struct + { + int i_id; + } media_player_program_changed; + + /* ProgramSelected */ + struct + { + int i_unselected_id; + int i_selected_id; + } media_player_program_selection_changed; + + struct + { + float volume; + } media_player_audio_volume; + + struct + { + const char *device; + } media_player_audio_device; + + struct + { + bool recording; + /** Only valid when recording ends (recording == false) */ + const char *recorded_file_path; + } media_player_record_changed; + + struct + { + libvlc_renderer_item_t *item; + } renderer_discoverer_item_added; + struct + { + libvlc_renderer_item_t *item; + } renderer_discoverer_item_deleted; + } u; /**< Type-dependent event description */ +} libvlc_event_t; + + +/**@} */ + +# ifdef __cplusplus +} +# endif + +#endif /* _LIBVLC_EVENTS_H */ diff --git a/Libs/vlc/libvlc_media.h b/Libs/vlc/libvlc_media.h new file mode 100644 index 000000000..05ae45639 --- /dev/null +++ b/Libs/vlc/libvlc_media.h @@ -0,0 +1,917 @@ +/***************************************************************************** + * libvlc_media.h: libvlc external API + ***************************************************************************** + * Copyright (C) 1998-2009 VLC authors and VideoLAN + * + * Authors: Clément Stenac + * Jean-Paul Saman + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_MEDIA_H +#define VLC_LIBVLC_MEDIA_H 1 + +#include +#include + +# ifdef __cplusplus +extern "C" { +# else +# include +# endif +#include + +/** \defgroup libvlc_media LibVLC media + * \ingroup libvlc + * @ref libvlc_media_t is an abstract representation of a playable media. + * It consists of a media location and various optional meta data. + * @{ + * \file + * LibVLC media item/descriptor external API + */ + +typedef struct libvlc_media_t libvlc_media_t; + +/** Meta data types */ +typedef enum libvlc_meta_t { + libvlc_meta_Title, + libvlc_meta_Artist, + libvlc_meta_Genre, + libvlc_meta_Copyright, + libvlc_meta_Album, + libvlc_meta_TrackNumber, + libvlc_meta_Description, + libvlc_meta_Rating, + libvlc_meta_Date, + libvlc_meta_Setting, + libvlc_meta_URL, + libvlc_meta_Language, + libvlc_meta_NowPlaying, + libvlc_meta_Publisher, + libvlc_meta_EncodedBy, + libvlc_meta_ArtworkURL, + libvlc_meta_TrackID, + libvlc_meta_TrackTotal, + libvlc_meta_Director, + libvlc_meta_Season, + libvlc_meta_Episode, + libvlc_meta_ShowName, + libvlc_meta_Actors, + libvlc_meta_AlbumArtist, + libvlc_meta_DiscNumber, + libvlc_meta_DiscTotal + /* Add new meta types HERE */ +} libvlc_meta_t; + +/** + * libvlc media or media_player state + */ +typedef enum libvlc_state_t +{ + libvlc_NothingSpecial=0, + libvlc_Opening, + libvlc_Buffering, /* XXX: Deprecated value. Check the + * libvlc_MediaPlayerBuffering event to know the + * buffering state of a libvlc_media_player */ + libvlc_Playing, + libvlc_Paused, + libvlc_Stopped, + libvlc_Stopping, + libvlc_Error +} libvlc_state_t; + +enum +{ + libvlc_media_option_trusted = 0x2, + libvlc_media_option_unique = 0x100 +}; + +typedef struct libvlc_media_stats_t +{ + /* Input */ + uint64_t i_read_bytes; + float f_input_bitrate; + + /* Demux */ + uint64_t i_demux_read_bytes; + float f_demux_bitrate; + uint64_t i_demux_corrupted; + uint64_t i_demux_discontinuity; + + /* Decoders */ + uint64_t i_decoded_video; + uint64_t i_decoded_audio; + + /* Video Output */ + uint64_t i_displayed_pictures; + uint64_t i_late_pictures; + uint64_t i_lost_pictures; + + /* Audio output */ + uint64_t i_played_abuffers; + uint64_t i_lost_abuffers; +} libvlc_media_stats_t; + +/** + * Media type + * + * \see libvlc_media_get_type + */ +typedef enum libvlc_media_type_t { + libvlc_media_type_unknown, + libvlc_media_type_file, + libvlc_media_type_directory, + libvlc_media_type_disc, + libvlc_media_type_stream, + libvlc_media_type_playlist, +} libvlc_media_type_t; + +/** + * Parse flags used by libvlc_media_parse_request() + */ +typedef enum libvlc_media_parse_flag_t +{ + /** + * Parse media if it's a local file + */ + libvlc_media_parse_local = 0x01, + /** + * Parse media even if it's a network file + */ + libvlc_media_parse_network = 0x02, + /** + * Force parsing the media even if it would be skipped. + */ + libvlc_media_parse_forced = 0x04, + /** + * Fetch meta and cover art using local resources + */ + libvlc_media_fetch_local = 0x08, + /** + * Fetch meta and cover art using network resources + */ + libvlc_media_fetch_network = 0x10, + /** + * Interact with the user (via libvlc_dialog_cbs) when preparsing this item + * (and not its sub items). Set this flag in order to receive a callback + * when the input is asking for credentials. + */ + libvlc_media_do_interact = 0x20, +} libvlc_media_parse_flag_t; + +/** + * Parse status used sent by libvlc_media_parse_request() or returned by + * libvlc_media_get_parsed_status() + */ +typedef enum libvlc_media_parsed_status_t +{ + libvlc_media_parsed_status_none, + libvlc_media_parsed_status_pending, + libvlc_media_parsed_status_skipped, + libvlc_media_parsed_status_failed, + libvlc_media_parsed_status_timeout, + libvlc_media_parsed_status_cancelled, + libvlc_media_parsed_status_done, +} libvlc_media_parsed_status_t; + +/** + * Type of a media slave: subtitle or audio. + */ +typedef enum libvlc_media_slave_type_t +{ + libvlc_media_slave_type_subtitle, + libvlc_media_slave_type_generic, + libvlc_media_slave_type_audio = libvlc_media_slave_type_generic, +} libvlc_media_slave_type_t; + +/** + * A slave of a libvlc_media_t + * \see libvlc_media_slaves_get + */ +typedef struct libvlc_media_slave_t +{ + char * psz_uri; + libvlc_media_slave_type_t i_type; + unsigned int i_priority; +} libvlc_media_slave_t; + +/** + * Type of stat that can be requested from libvlc_media_get_filestat() + */ +#define libvlc_media_filestat_mtime 0 +#define libvlc_media_filestat_size 1 + +/** + * Callback prototype to open a custom bitstream input media. + * + * The same media item can be opened multiple times. Each time, this callback + * is invoked. It should allocate and initialize any instance-specific + * resources, then store them in *datap. The instance resources can be freed + * in the @ref libvlc_media_close_cb callback. + * + * \param opaque private pointer as passed to libvlc_media_new_callbacks() + * \param datap storage space for a private data pointer [OUT] + * \param sizep byte length of the bitstream or UINT64_MAX if unknown [OUT] + * + * \note For convenience, *datap is initially NULL and *sizep is initially 0. + * + * \return 0 on success, non-zero on error. In case of failure, the other + * callbacks will not be invoked and any value stored in *datap and *sizep is + * discarded. + */ +typedef int (*libvlc_media_open_cb)(void *opaque, void **datap, + uint64_t *sizep); + +/** + * Callback prototype to read data from a custom bitstream input media. + * + * \param opaque private pointer as set by the @ref libvlc_media_open_cb + * callback + * \param buf start address of the buffer to read data into + * \param len bytes length of the buffer + * + * \return strictly positive number of bytes read, 0 on end-of-stream, + * or -1 on non-recoverable error + * + * \note If no data is immediately available, then the callback should sleep. + * \warning The application is responsible for avoiding deadlock situations. + */ +typedef ptrdiff_t (*libvlc_media_read_cb)(void *opaque, unsigned char *buf, + size_t len); + +/** + * Callback prototype to seek a custom bitstream input media. + * + * \param opaque private pointer as set by the @ref libvlc_media_open_cb + * callback + * \param offset absolute byte offset to seek to + * \return 0 on success, -1 on error. + */ +typedef int (*libvlc_media_seek_cb)(void *opaque, uint64_t offset); + +/** + * Callback prototype to close a custom bitstream input media. + * + * \param opaque private pointer as set by the @ref libvlc_media_open_cb + * callback + */ +typedef void (*libvlc_media_close_cb)(void *opaque); + +/** + * Create a media with a certain given media resource location, + * for instance a valid URL. + * + * \note To refer to a local file with this function, + * the file://... URI syntax must be used (see IETF RFC3986). + * We recommend using libvlc_media_new_path() instead when dealing with + * local files. + * + * \see libvlc_media_release + * + * \param psz_mrl the media location + * \return the newly created media or NULL on error + */ +LIBVLC_API libvlc_media_t *libvlc_media_new_location(const char * psz_mrl); + +/** + * Create a media for a certain file path. + * + * \see libvlc_media_release + * + * \param path local filesystem path + * \return the newly created media or NULL on error + */ +LIBVLC_API libvlc_media_t *libvlc_media_new_path(const char *path); + +/** + * Create a media for an already open file descriptor. + * The file descriptor shall be open for reading (or reading and writing). + * + * Regular file descriptors, pipe read descriptors and character device + * descriptors (including TTYs) are supported on all platforms. + * Block device descriptors are supported where available. + * Directory descriptors are supported on systems that provide fdopendir(). + * Sockets are supported on all platforms where they are file descriptors, + * i.e. all except Windows. + * + * \note This library will not automatically close the file descriptor + * under any circumstance. Nevertheless, a file descriptor can usually only be + * rendered once in a media player. To render it a second time, the file + * descriptor should probably be rewound to the beginning with lseek(). + * + * \see libvlc_media_release + * + * \version LibVLC 1.1.5 and later. + * + * \param fd open file descriptor + * \return the newly created media or NULL on error + */ +LIBVLC_API libvlc_media_t *libvlc_media_new_fd(int fd); + +/** + * Create a media with custom callbacks to read the data from. + * + * \param open_cb callback to open the custom bitstream input media + * \param read_cb callback to read data (must not be NULL) + * \param seek_cb callback to seek, or NULL if seeking is not supported + * \param close_cb callback to close the media, or NULL if unnecessary + * \param opaque data pointer for the open callback + * + * \return the newly created media or NULL on error + * + * \note If open_cb is NULL, the opaque pointer will be passed to read_cb, + * seek_cb and close_cb, and the stream size will be treated as unknown. + * + * \note The callbacks may be called asynchronously (from another thread). + * A single stream instance need not be reentrant. However the open_cb needs to + * be reentrant if the media is used by multiple player instances. + * + * \warning The callbacks may be used until all or any player instances + * that were supplied the media item are stopped. + * + * \see libvlc_media_release + * + * \version LibVLC 3.0.0 and later. + */ +LIBVLC_API libvlc_media_t *libvlc_media_new_callbacks( + libvlc_media_open_cb open_cb, + libvlc_media_read_cb read_cb, + libvlc_media_seek_cb seek_cb, + libvlc_media_close_cb close_cb, + void *opaque ); + +/** + * Create a media as an empty node with a given name. + * + * \see libvlc_media_release + * + * \param psz_name the name of the node + * \return the new empty media or NULL on error + */ +LIBVLC_API libvlc_media_t *libvlc_media_new_as_node(const char * psz_name); + +/** + * Add an option to the media. + * + * This option will be used to determine how the media_player will + * read the media. This allows to use VLC's advanced + * reading/streaming options on a per-media basis. + * + * \note The options are listed in 'vlc --longhelp' from the command line, + * e.g. "--sout-all". Keep in mind that available options and their semantics + * vary across LibVLC versions and builds. + * \warning Not all options affects libvlc_media_t objects: + * Specifically, due to architectural issues most audio and video options, + * such as text renderer options, have no effects on an individual media. + * These options must be set through libvlc_new() instead. + * + * \param p_md the media descriptor + * \param psz_options the options (as a string) + */ +LIBVLC_API void libvlc_media_add_option( + libvlc_media_t *p_md, + const char * psz_options ); + +/** + * Add an option to the media with configurable flags. + * + * This option will be used to determine how the media_player will + * read the media. This allows to use VLC's advanced + * reading/streaming options on a per-media basis. + * + * The options are detailed in vlc --longhelp, for instance + * "--sout-all". Note that all options are not usable on medias: + * specifically, due to architectural issues, video-related options + * such as text renderer options cannot be set on a single media. They + * must be set on the whole libvlc instance instead. + * + * \param p_md the media descriptor + * \param psz_options the options (as a string) + * \param i_flags the flags for this option + */ +LIBVLC_API void libvlc_media_add_option_flag( + libvlc_media_t *p_md, + const char * psz_options, + unsigned i_flags ); + + +/** + * Retain a reference to a media descriptor object (libvlc_media_t). Use + * libvlc_media_release() to decrement the reference count of a + * media descriptor object. + * + * \param p_md the media descriptor + * \return the same object + */ +LIBVLC_API libvlc_media_t *libvlc_media_retain( libvlc_media_t *p_md ); + +/** + * Decrement the reference count of a media descriptor object. If the + * reference count is 0, then libvlc_media_release() will release the + * media descriptor object. If the media descriptor object has been released it + * should not be used again. + * + * \param p_md the media descriptor + */ +LIBVLC_API void libvlc_media_release( libvlc_media_t *p_md ); + + +/** + * Get the media resource locator (mrl) from a media descriptor object + * + * \param p_md a media descriptor object + * \return string with mrl of media descriptor object + */ +LIBVLC_API char *libvlc_media_get_mrl( libvlc_media_t *p_md ); + +/** + * Duplicate a media descriptor object. + * + * \warning the duplicated media won't share forthcoming updates from the + * original one. + * + * \param p_md a media descriptor object. + */ +LIBVLC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md ); + +/** + * Read the meta of the media. + * + * Note, you need to call libvlc_media_parse_request() or play the media + * at least once before calling this function. + * If the media has not yet been parsed this will return NULL. + * + * \see libvlc_MediaMetaChanged + * + * \param p_md the media descriptor + * \param e_meta the meta to read + * \return the media's meta + */ +LIBVLC_API char *libvlc_media_get_meta( libvlc_media_t *p_md, + libvlc_meta_t e_meta ); + +/** + * Set the meta of the media (this function will not save the meta, call + * libvlc_media_save_meta in order to save the meta) + * + * \param p_md the media descriptor + * \param e_meta the meta to write + * \param psz_value the media's meta + */ +LIBVLC_API void libvlc_media_set_meta( libvlc_media_t *p_md, + libvlc_meta_t e_meta, + const char *psz_value ); + +/** + * Read the meta extra of the media. + * + * If the media has not yet been parsed this will return NULL. + * + * \see libvlc_media_parse + * \see libvlc_media_parse_with_options + * + * \param p_md the media descriptor + * \param psz_name the meta extra to read (nonnullable) + * \return the media's meta extra or NULL + */ +LIBVLC_API char *libvlc_media_get_meta_extra( libvlc_media_t *p_md, + const char *psz_name ); + +/** + * Set the meta of the media (this function will not save the meta, call + * libvlc_media_save_meta in order to save the meta) + * + * \param p_md the media descriptor + * \param psz_name the meta extra to write (nonnullable) + * \param psz_value the media's meta extra (nullable) + * Removed from meta extra if set to NULL + */ +LIBVLC_API void libvlc_media_set_meta_extra( libvlc_media_t *p_md, + const char *psz_name, + const char *psz_value ); + +/** + * Read the meta extra names of the media. + * + * \param p_md the media descriptor + * \param pppsz_names the media's meta extra name array + * you can access the elements using the return value (count) + * must be released with libvlc_media_meta_extra_names_release() + * \return the meta extra count + */ +LIBVLC_API unsigned libvlc_media_get_meta_extra_names( libvlc_media_t *p_md, + char ***pppsz_names ); + +/** + * Release a media meta extra names + * + * \param ppsz_names meta extra names array to release + * \param i_count number of elements in the array + */ +LIBVLC_API void libvlc_media_meta_extra_names_release( char **ppsz_names, + unsigned i_count ); + +/** + * Save the meta previously set + * + * \param inst LibVLC instance + * \param p_md the media descriptor + * \return true if the write operation was successful + */ +LIBVLC_API int libvlc_media_save_meta( libvlc_instance_t *inst, + libvlc_media_t *p_md ); + +/** + * Get the current statistics about the media + * \param p_md media descriptor object + * \param p_stats structure that contain the statistics about the media + * (this structure must be allocated by the caller) + * \retval true statistics are available + * \retval false otherwise + */ +LIBVLC_API bool libvlc_media_get_stats(libvlc_media_t *p_md, + libvlc_media_stats_t *p_stats); + +/* The following method uses libvlc_media_list_t, however, media_list usage is optional + * and this is here for convenience */ +#define VLC_FORWARD_DECLARE_OBJECT(a) struct a + +/** + * Get subitems of media descriptor object. This will increment + * the reference count of supplied media descriptor object. Use + * libvlc_media_list_release() to decrement the reference counting. + * + * \param p_md media descriptor object + * \return list of media descriptor subitems or NULL + */ +LIBVLC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *) +libvlc_media_subitems( libvlc_media_t *p_md ); + +/** + * Get event manager from media descriptor object. + * NOTE: this function doesn't increment reference counting. + * + * \param p_md a media descriptor object + * \return event manager object + */ +LIBVLC_API libvlc_event_manager_t * + libvlc_media_event_manager( libvlc_media_t *p_md ); + +/** + * Get duration (in ms) of media descriptor object item. + * + * Note, you need to call libvlc_media_parse_request() or play the media + * at least once before calling this function. + * Not doing this will result in an undefined result. + * + * \param p_md media descriptor object + * \return duration of media item or -1 on error + */ +LIBVLC_API libvlc_time_t + libvlc_media_get_duration( libvlc_media_t *p_md ); + +/** + * Get a 'stat' value of media descriptor object item. + * + * \note 'stat' values are currently only parsed by directory accesses. This + * mean that only sub medias of a directory media, parsed with + * libvlc_media_parse_request() can have valid 'stat' properties. + * \version LibVLC 4.0.0 and later. + * + * \param p_md media descriptor object + * \param type a valid libvlc_media_stat_ define + * \param out field in which the value will be stored + * \return 1 on success, 0 if not found, -1 on error. + */ +LIBVLC_API int + libvlc_media_get_filestat( libvlc_media_t *p_md, unsigned type, uint64_t *out ); + +/** + * Parse the media asynchronously with options. + * + * This fetches (local or network) art, meta data and/or tracks information. + * + * To track when this is over you can listen to libvlc_MediaParsedChanged + * event. However if this functions returns an error, you will not receive any + * events. + * + * It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All + * these flags can be combined. By default, media is parsed if it's a local + * file. + * + * \note Parsing can be aborted with libvlc_media_parse_stop(). + * + * \see libvlc_MediaParsedChanged + * \see libvlc_media_get_meta + * \see libvlc_media_get_tracklist + * \see libvlc_media_get_parsed_status + * \see libvlc_media_parse_flag_t + * + * \param inst LibVLC instance that is to parse the media + * \param p_md media descriptor object + * \param parse_flag parse options: + * \param timeout maximum time allowed to preparse the media. If -1, the + * default "preparse-timeout" option will be used as a timeout. If 0, it will + * wait indefinitely. If > 0, the timeout will be used (in milliseconds). + * \return -1 in case of error, 0 otherwise + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int +libvlc_media_parse_request( libvlc_instance_t *inst, libvlc_media_t *p_md, + libvlc_media_parse_flag_t parse_flag, + int timeout ); + +/** + * Stop the parsing of the media + * + * When the media parsing is stopped, the libvlc_MediaParsedChanged event will + * be sent with the libvlc_media_parsed_status_timeout status. + * + * \see libvlc_media_parse_request() + * + * \param inst LibVLC instance that is to cease or give up parsing the media + * \param p_md media descriptor object + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API void +libvlc_media_parse_stop( libvlc_instance_t *inst, libvlc_media_t *p_md ); + +/** + * Get Parsed status for media descriptor object. + * + * \see libvlc_MediaParsedChanged + * \see libvlc_media_parsed_status_t + * \see libvlc_media_parse_request() + * + * \param p_md media descriptor object + * \return a value of the libvlc_media_parsed_status_t enum + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API libvlc_media_parsed_status_t + libvlc_media_get_parsed_status( libvlc_media_t *p_md ); + +/** + * Sets media descriptor's user_data. user_data is specialized data + * accessed by the host application, VLC.framework uses it as a pointer to + * an native object that references a libvlc_media_t pointer + * + * \param p_md media descriptor object + * \param p_new_user_data pointer to user data + */ +LIBVLC_API void + libvlc_media_set_user_data( libvlc_media_t *p_md, void *p_new_user_data ); + +/** + * Get media descriptor's user_data. user_data is specialized data + * accessed by the host application, VLC.framework uses it as a pointer to + * an native object that references a libvlc_media_t pointer + * + * \see libvlc_media_set_user_data + * + * \param p_md media descriptor object + */ +LIBVLC_API void *libvlc_media_get_user_data( libvlc_media_t *p_md ); + +/** + * Get the track list for one type + * + * \version LibVLC 4.0.0 and later. + * + * \note You need to call libvlc_media_parse_request() or play the media + * at least once before calling this function. Not doing this will result in + * an empty list. + * + * \see libvlc_media_tracklist_count + * \see libvlc_media_tracklist_at + * + * \param p_md media descriptor object + * \param type type of the track list to request + * + * \return a valid libvlc_media_tracklist_t or NULL in case of error, if there + * is no track for a category, the returned list will have a size of 0, delete + * with libvlc_media_tracklist_delete() + */ +LIBVLC_API libvlc_media_tracklist_t * +libvlc_media_get_tracklist( libvlc_media_t *p_md, libvlc_track_type_t type ); + +/** + * Get codec description from media elementary stream + * + * Note, you need to call libvlc_media_parse_request() or play the media + * at least once before calling this function. + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_track_t + * + * \param i_type i_type from libvlc_media_track_t + * \param i_codec i_codec or i_original_fourcc from libvlc_media_track_t + * + * \return codec description + */ +LIBVLC_API +const char *libvlc_media_get_codec_description( libvlc_track_type_t i_type, + uint32_t i_codec ); + +/** + * Get the media type of the media descriptor object + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_type_t + * + * \param p_md media descriptor object + * + * \return media type + */ +LIBVLC_API +libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md ); + +/** + * \brief libvlc_media_thumbnail_request_t An opaque thumbnail request object + */ +typedef struct libvlc_media_thumbnail_request_t libvlc_media_thumbnail_request_t; + +typedef enum libvlc_thumbnailer_seek_speed_t +{ + libvlc_media_thumbnail_seek_precise, + libvlc_media_thumbnail_seek_fast, +} libvlc_thumbnailer_seek_speed_t; + +/** + * \brief libvlc_media_request_thumbnail_by_time Start an asynchronous thumbnail generation + * + * If the request is successfully queued, the libvlc_MediaThumbnailGenerated is + * guaranteed to be emitted (except if the request is destroyed early by the + * user). + * The resulting thumbnail size can either be: + * - Hardcoded by providing both width & height. In which case, the image will + * be stretched to match the provided aspect ratio, or cropped if crop is true. + * - Derived from the media aspect ratio if only width or height is provided and + * the other one is set to 0. + * + * \param inst LibVLC instance to generate the thumbnail with + * \param md media descriptor object + * \param time The time at which the thumbnail should be generated + * \param speed The seeking speed \sa{libvlc_thumbnailer_seek_speed_t} + * \param width The thumbnail width + * \param height the thumbnail height + * \param crop Should the picture be cropped to preserve source aspect ratio + * \param picture_type The thumbnail picture type \sa{libvlc_picture_type_t} + * \param timeout A timeout value in ms, or 0 to disable timeout + * + * \return A valid opaque request object, or NULL in case of failure. + * It must be released by libvlc_media_thumbnail_request_destroy() and + * can be cancelled by calling it early. + * + * \version libvlc 4.0 or later + * + * \see libvlc_picture_t + * \see libvlc_picture_type_t + */ +LIBVLC_API libvlc_media_thumbnail_request_t* +libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst, + libvlc_media_t *md, libvlc_time_t time, + libvlc_thumbnailer_seek_speed_t speed, + unsigned int width, unsigned int height, + bool crop, libvlc_picture_type_t picture_type, + libvlc_time_t timeout ); + +/** + * \brief libvlc_media_request_thumbnail_by_pos Start an asynchronous thumbnail generation + * + * If the request is successfully queued, the libvlc_MediaThumbnailGenerated is + * guaranteed to be emitted (except if the request is destroyed early by the + * user). + * The resulting thumbnail size can either be: + * - Hardcoded by providing both width & height. In which case, the image will + * be stretched to match the provided aspect ratio, or cropped if crop is true. + * - Derived from the media aspect ratio if only width or height is provided and + * the other one is set to 0. + * + * \param inst LibVLC instance to generate the thumbnail with + * \param md media descriptor object + * \param pos The position at which the thumbnail should be generated + * \param speed The seeking speed \sa{libvlc_thumbnailer_seek_speed_t} + * \param width The thumbnail width + * \param height the thumbnail height + * \param crop Should the picture be cropped to preserve source aspect ratio + * \param picture_type The thumbnail picture type \sa{libvlc_picture_type_t} + * \param timeout A timeout value in ms, or 0 to disable timeout + * + * \return A valid opaque request object, or NULL in case of failure. + * It must be released by libvlc_media_thumbnail_request_destroy(). + * + * \version libvlc 4.0 or later + * + * \see libvlc_picture_t + * \see libvlc_picture_type_t + */ +LIBVLC_API libvlc_media_thumbnail_request_t* +libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst, + libvlc_media_t *md, double pos, + libvlc_thumbnailer_seek_speed_t speed, + unsigned int width, unsigned int height, + bool crop, libvlc_picture_type_t picture_type, + libvlc_time_t timeout ); + +/** + * @brief libvlc_media_thumbnail_destroy destroys a thumbnail request + * @param p_req An opaque thumbnail request object. + * + * This will also cancel the thumbnail request, no events will be emitted after + * this call. + */ +LIBVLC_API void +libvlc_media_thumbnail_request_destroy( libvlc_media_thumbnail_request_t *p_req ); + +/** + * Add a slave to the current media. + * + * A slave is an external input source that may contains an additional subtitle + * track (like a .srt) or an additional audio track (like a .ac3). + * + * \note This function must be called before the media is parsed (via + * libvlc_media_parse_request()) or before the media is played (via + * libvlc_media_player_play()) + * + * \version LibVLC 3.0.0 and later. + * + * \param p_md media descriptor object + * \param i_type subtitle or audio + * \param i_priority from 0 (low priority) to 4 (high priority) + * \param psz_uri Uri of the slave (should contain a valid scheme). + * + * \return 0 on success, -1 on error. + */ +LIBVLC_API +int libvlc_media_slaves_add( libvlc_media_t *p_md, + libvlc_media_slave_type_t i_type, + unsigned int i_priority, + const char *psz_uri ); + +/** + * Clear all slaves previously added by libvlc_media_slaves_add() or + * internally. + * + * \version LibVLC 3.0.0 and later. + * + * \param p_md media descriptor object + */ +LIBVLC_API +void libvlc_media_slaves_clear( libvlc_media_t *p_md ); + +/** + * Get a media descriptor's slave list + * + * The list will contain slaves parsed by VLC or previously added by + * libvlc_media_slaves_add(). The typical use case of this function is to save + * a list of slave in a database for a later use. + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_slaves_add + * + * \param p_md media descriptor object + * \param ppp_slaves address to store an allocated array of slaves (must be + * freed with libvlc_media_slaves_release()) [OUT] + * + * \return the number of slaves (zero on error) + */ +LIBVLC_API +unsigned int libvlc_media_slaves_get( libvlc_media_t *p_md, + libvlc_media_slave_t ***ppp_slaves ); + +/** + * Release a media descriptor's slave list + * + * \version LibVLC 3.0.0 and later. + * + * \param pp_slaves slave array to release + * \param i_count number of elements in the array + */ +LIBVLC_API +void libvlc_media_slaves_release( libvlc_media_slave_t **pp_slaves, + unsigned int i_count ); + +/** @}*/ + +# ifdef __cplusplus +} +# endif + +#endif /* VLC_LIBVLC_MEDIA_H */ diff --git a/Libs/vlc/libvlc_media_discoverer.h b/Libs/vlc/libvlc_media_discoverer.h new file mode 100644 index 000000000..9054c837b --- /dev/null +++ b/Libs/vlc/libvlc_media_discoverer.h @@ -0,0 +1,188 @@ +/***************************************************************************** + * libvlc_media_discoverer.h: libvlc external API + ***************************************************************************** + * Copyright (C) 1998-2009 VLC authors and VideoLAN + * + * Authors: Clément Stenac + * Jean-Paul Saman + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_MEDIA_DISCOVERER_H +#define VLC_LIBVLC_MEDIA_DISCOVERER_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct libvlc_media_list_t libvlc_media_list_t; + +/** + * Category of a media discoverer + * \see libvlc_media_discoverer_list_get() + */ +typedef enum libvlc_media_discoverer_category_t { + /** devices, like portable music player */ + libvlc_media_discoverer_devices, + /** LAN/WAN services, like Upnp, SMB, or SAP */ + libvlc_media_discoverer_lan, + /** Podcasts */ + libvlc_media_discoverer_podcasts, + /** Local directories, like Video, Music or Pictures directories */ + libvlc_media_discoverer_localdirs, +} libvlc_media_discoverer_category_t; + +/** + * Media discoverer description + * \see libvlc_media_discoverer_list_get() + */ +typedef struct libvlc_media_discoverer_description_t { + char *psz_name; + char *psz_longname; + libvlc_media_discoverer_category_t i_cat; +} libvlc_media_discoverer_description_t; + +/** \defgroup libvlc_media_discoverer LibVLC media discovery + * \ingroup libvlc + * LibVLC media discovery finds available media via various means. + * This corresponds to the service discovery functionality in VLC media player. + * Different plugins find potential medias locally (e.g. user media directory), + * from peripherals (e.g. video capture device), on the local network + * (e.g. SAP) or on the Internet (e.g. Internet radios). + * @{ + * \file + * LibVLC media discovery external API + */ + +typedef struct libvlc_media_discoverer_t libvlc_media_discoverer_t; + +/** + * Create a media discoverer object by name. + * + * After this object is created, you should attach to media_list events in + * order to be notified of new items discovered. + * + * You need to call libvlc_media_discoverer_start() in order to start the + * discovery. + * + * \see libvlc_media_discoverer_media_list + * \see libvlc_media_discoverer_start + * + * \param p_inst libvlc instance + * \param psz_name service name; use libvlc_media_discoverer_list_get() to get + * a list of the discoverer names available in this libVLC instance + * \return media discover object or NULL in case of error + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API libvlc_media_discoverer_t * +libvlc_media_discoverer_new( libvlc_instance_t * p_inst, + const char * psz_name ); + +/** + * Start media discovery. + * + * To stop it, call libvlc_media_discoverer_stop() or + * libvlc_media_discoverer_list_release() directly. + * + * \see libvlc_media_discoverer_stop + * + * \param p_mdis media discover object + * \return -1 in case of error, 0 otherwise + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API int +libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis ); + +/** + * Stop media discovery. + * + * \see libvlc_media_discoverer_start + * + * \param p_mdis media discover object + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API void +libvlc_media_discoverer_stop( libvlc_media_discoverer_t * p_mdis ); + +/** + * Release media discover object. If the reference count reaches 0, then + * the object will be released. + * + * \param p_mdis media service discover object + */ +LIBVLC_API void +libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis ); + +/** + * Get media service discover media list. + * + * \param p_mdis media service discover object + * \return list of media items + */ +LIBVLC_API libvlc_media_list_t * +libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis ); + +/** + * Query if media service discover object is running. + * + * \param p_mdis media service discover object + * + * \retval true running + * \retval false not running + */ +LIBVLC_API bool +libvlc_media_discoverer_is_running(libvlc_media_discoverer_t *p_mdis); + +/** + * Get media discoverer services by category + * + * \version LibVLC 3.0.0 and later. + * + * \param p_inst libvlc instance + * \param i_cat category of services to fetch + * \param ppp_services address to store an allocated array of media discoverer + * services (must be freed with libvlc_media_discoverer_list_release() by + * the caller) [OUT] + * + * \return the number of media discoverer services (0 on error) + */ +LIBVLC_API size_t +libvlc_media_discoverer_list_get( libvlc_instance_t *p_inst, + libvlc_media_discoverer_category_t i_cat, + libvlc_media_discoverer_description_t ***ppp_services ); + +/** + * Release an array of media discoverer services + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_discoverer_list_get() + * + * \param pp_services array to release + * \param i_count number of elements in the array + */ +LIBVLC_API void +libvlc_media_discoverer_list_release( libvlc_media_discoverer_description_t **pp_services, + size_t i_count ); + +/**@} */ + +# ifdef __cplusplus +} +# endif + +#endif /* */ diff --git a/Libs/vlc/libvlc_media_list.h b/Libs/vlc/libvlc_media_list.h new file mode 100644 index 000000000..ba2a340de --- /dev/null +++ b/Libs/vlc/libvlc_media_list.h @@ -0,0 +1,200 @@ +/***************************************************************************** + * libvlc_media_list.h: libvlc_media_list API + ***************************************************************************** + * Copyright (C) 1998-2008 VLC authors and VideoLAN + * + * Authors: Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef LIBVLC_MEDIA_LIST_H +#define LIBVLC_MEDIA_LIST_H 1 + +typedef struct libvlc_media_t libvlc_media_t; + +# ifdef __cplusplus +extern "C" { +# endif + +/** \defgroup libvlc_media_list LibVLC media list + * \ingroup libvlc + * A LibVLC media list holds multiple @ref libvlc_media_t media descriptors. + * @{ + * \file + * LibVLC media list (playlist) external API + */ + +typedef struct libvlc_media_list_t libvlc_media_list_t; + +/** + * Create an empty media list. + * + * \return empty media list, or NULL on error + */ +LIBVLC_API libvlc_media_list_t *libvlc_media_list_new(void); + +/** + * Release media list created with libvlc_media_list_new(). + * + * \param p_ml a media list created with libvlc_media_list_new() + */ +LIBVLC_API void + libvlc_media_list_release( libvlc_media_list_t *p_ml ); + +/** + * Retain reference to a media list + * + * \param p_ml a media list created with libvlc_media_list_new() + * \return the same object + */ +LIBVLC_API libvlc_media_list_t * + libvlc_media_list_retain( libvlc_media_list_t *p_ml ); + +/** + * Associate media instance with this media list instance. + * If another media instance was present it will be released. + * The libvlc_media_list_lock should NOT be held upon entering this function. + * + * \param p_ml a media list instance + * \param p_md media instance to add + */ +LIBVLC_API void +libvlc_media_list_set_media( libvlc_media_list_t *p_ml, libvlc_media_t *p_md ); + +/** + * Get media instance from this media list instance. This action will increase + * the refcount on the media instance. + * The libvlc_media_list_lock should NOT be held upon entering this function. + * + * \param p_ml a media list instance + * \return media instance + */ +LIBVLC_API libvlc_media_t * + libvlc_media_list_media( libvlc_media_list_t *p_ml ); + +/** + * Add media instance to media list + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \param p_md a media instance + * \return 0 on success, -1 if the media list is read-only + */ +LIBVLC_API int +libvlc_media_list_add_media( libvlc_media_list_t *p_ml, libvlc_media_t *p_md ); + +/** + * Insert media instance in media list on a position + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \param p_md a media instance + * \param i_pos position in array where to insert + * \return 0 on success, -1 if the media list is read-only + */ +LIBVLC_API int +libvlc_media_list_insert_media( libvlc_media_list_t *p_ml, + libvlc_media_t *p_md, int i_pos ); + +/** + * Remove media instance from media list on a position + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \param i_pos position in array where to insert + * \return 0 on success, -1 if the list is read-only or the item was not found + */ +LIBVLC_API int +libvlc_media_list_remove_index( libvlc_media_list_t *p_ml, int i_pos ); + +/** + * Get count on media list items + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \return number of items in media list + */ +LIBVLC_API int + libvlc_media_list_count( libvlc_media_list_t *p_ml ); + +/** + * List media instance in media list at a position + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \param i_pos position in array where to insert + * \return media instance at position i_pos, or NULL if not found. + * In case of success, libvlc_media_retain() is called to increase the refcount + * on the media. + */ +LIBVLC_API libvlc_media_t * + libvlc_media_list_item_at_index( libvlc_media_list_t *p_ml, int i_pos ); +/** + * Find index position of List media instance in media list. + * Warning: the function will return the first matched position. + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + * \param p_md media instance + * \return position of media instance or -1 if media not found + */ +LIBVLC_API int + libvlc_media_list_index_of_item( libvlc_media_list_t *p_ml, + libvlc_media_t *p_md ); + +/** + * This indicates if this media list is read-only from a user point of view + * + * \param p_ml media list instance + * \retval true read-only + * \retval false read/write + */ +LIBVLC_API bool libvlc_media_list_is_readonly(libvlc_media_list_t *p_ml); + +/** + * Get lock on media list items + * + * \param p_ml a media list instance + */ +LIBVLC_API void + libvlc_media_list_lock( libvlc_media_list_t *p_ml ); + +/** + * Release lock on media list items + * The libvlc_media_list_lock should be held upon entering this function. + * + * \param p_ml a media list instance + */ +LIBVLC_API void + libvlc_media_list_unlock( libvlc_media_list_t *p_ml ); + +/** + * Get libvlc_event_manager from this media list instance. + * The p_event_manager is immutable, so you don't have to hold the lock + * + * \param p_ml a media list instance + * \return libvlc_event_manager + */ +LIBVLC_API libvlc_event_manager_t * + libvlc_media_list_event_manager( libvlc_media_list_t *p_ml ); + +/** @} media_list */ + +# ifdef __cplusplus +} +# endif + +#endif /* _LIBVLC_MEDIA_LIST_H */ diff --git a/Libs/vlc/libvlc_media_list_player.h b/Libs/vlc/libvlc_media_list_player.h new file mode 100644 index 000000000..aa287b460 --- /dev/null +++ b/Libs/vlc/libvlc_media_list_player.h @@ -0,0 +1,249 @@ +/***************************************************************************** + * libvlc_media_list_player.h: libvlc_media_list API + ***************************************************************************** + * Copyright (C) 1998-2008 VLC authors and VideoLAN + * + * Authors: Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef LIBVLC_MEDIA_LIST_PLAYER_H +#define LIBVLC_MEDIA_LIST_PLAYER_H 1 + +#include +#include + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct libvlc_instance_t libvlc_instance_t; +typedef struct libvlc_media_player_t libvlc_media_player_t; +typedef struct libvlc_media_list_t libvlc_media_list_t; +typedef struct libvlc_media_t libvlc_media_t; + +/** \defgroup libvlc_media_list_player LibVLC media list player + * \ingroup libvlc + * The LibVLC media list player plays a @ref libvlc_media_list_t list of media, + * in a certain order. + * This is required to especially support playlist files. + * The normal @ref libvlc_media_player_t LibVLC media player can only play a + * single media, and does not handle playlist files properly. + * @{ + * \file + * LibVLC media list player external API + */ + +typedef struct libvlc_media_list_player_t libvlc_media_list_player_t; + +/** + * Defines playback modes for playlist. + */ +typedef enum libvlc_playback_mode_t +{ + libvlc_playback_mode_default, + libvlc_playback_mode_loop, + libvlc_playback_mode_repeat +} libvlc_playback_mode_t; + +/** + * Create new media_list_player. + * + * \param p_instance libvlc instance + * \return media list player instance or NULL on error + * (it must be released by libvlc_media_list_player_release()) + */ +LIBVLC_API libvlc_media_list_player_t * + libvlc_media_list_player_new( libvlc_instance_t * p_instance ); + +/** + * Release a media_list_player after use + * Decrement the reference count of a media player object. If the + * reference count is 0, then libvlc_media_list_player_release() will + * release the media player object. If the media player object + * has been released, then it should not be used again. + * + * \param p_mlp media list player instance + */ +LIBVLC_API void + libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp ); + +/** + * Retain a reference to a media player list object. Use + * libvlc_media_list_player_release() to decrement reference count. + * + * \param p_mlp media player list object + * \return the same object + */ +LIBVLC_API libvlc_media_list_player_t * + libvlc_media_list_player_retain( libvlc_media_list_player_t *p_mlp ); + +/** + * Return the event manager of this media_list_player. + * + * \param p_mlp media list player instance + * \return the event manager + */ +LIBVLC_API libvlc_event_manager_t * + libvlc_media_list_player_event_manager(libvlc_media_list_player_t * p_mlp); + +/** + * Replace media player in media_list_player with this instance. + * + * \param p_mlp media list player instance + * \param p_mi media player instance + */ +LIBVLC_API void + libvlc_media_list_player_set_media_player( + libvlc_media_list_player_t * p_mlp, + libvlc_media_player_t * p_mi ); + +/** + * Get media player of the media_list_player instance. + * + * \param p_mlp media list player instance + * \return media player instance + * \note the caller is responsible for releasing the returned instance + with libvlc_media_list_player_set_media_player(). + */ +LIBVLC_API libvlc_media_player_t * + libvlc_media_list_player_get_media_player(libvlc_media_list_player_t * p_mlp); + +/** + * Set the media list associated with the player + * + * \param p_mlp media list player instance + * \param p_mlist list of media + */ +LIBVLC_API void + libvlc_media_list_player_set_media_list( + libvlc_media_list_player_t * p_mlp, + libvlc_media_list_t * p_mlist ); + +/** + * Play media list + * + * \param p_mlp media list player instance + */ +LIBVLC_API +void libvlc_media_list_player_play(libvlc_media_list_player_t * p_mlp); + +/** + * Toggle pause (or resume) media list + * + * \param p_mlp media list player instance + */ +LIBVLC_API +void libvlc_media_list_player_pause(libvlc_media_list_player_t * p_mlp); + +/** + * Pause or resume media list + * + * \param p_mlp media list player instance + * \param do_pause play/resume if zero, pause if non-zero + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API +void libvlc_media_list_player_set_pause(libvlc_media_list_player_t * p_mlp, + int do_pause); + +/** + * Is media list playing? + * + * \param p_mlp media list player instance + * + * \retval true playing + * \retval false not playing + */ +LIBVLC_API bool +libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp); + +/** + * Get current libvlc_state of media list player + * + * \param p_mlp media list player instance + * \return libvlc_state_t for media list player + */ +LIBVLC_API libvlc_state_t + libvlc_media_list_player_get_state( libvlc_media_list_player_t * p_mlp ); + +/** + * Play media list item at position index + * + * \param p_mlp media list player instance + * \param i_index index in media list to play + * \return 0 upon success -1 if the item wasn't found + */ +LIBVLC_API +int libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t * p_mlp, + int i_index); + +/** + * Play the given media item + * + * \param p_mlp media list player instance + * \param p_md the media instance + * \return 0 upon success, -1 if the media is not part of the media list + */ +LIBVLC_API +int libvlc_media_list_player_play_item(libvlc_media_list_player_t * p_mlp, + libvlc_media_t * p_md); + +/** + * Stop playing media list + * + * \param p_mlp media list player instance + */ +LIBVLC_API void + libvlc_media_list_player_stop_async( libvlc_media_list_player_t * p_mlp); + +/** + * Play next item from media list + * + * \param p_mlp media list player instance + * \return 0 upon success -1 if there is no next item + */ +LIBVLC_API +int libvlc_media_list_player_next(libvlc_media_list_player_t * p_mlp); + +/** + * Play previous item from media list + * + * \param p_mlp media list player instance + * \return 0 upon success -1 if there is no previous item + */ +LIBVLC_API +int libvlc_media_list_player_previous(libvlc_media_list_player_t * p_mlp); + + + +/** + * Sets the playback mode for the playlist + * + * \param p_mlp media list player instance + * \param e_mode playback mode specification + */ +LIBVLC_API +void libvlc_media_list_player_set_playback_mode(libvlc_media_list_player_t * p_mlp, + libvlc_playback_mode_t e_mode ); + +/** @} media_list_player */ + +# ifdef __cplusplus +} +# endif + +#endif /* LIBVLC_MEDIA_LIST_PLAYER_H */ diff --git a/Libs/vlc/libvlc_media_player.h b/Libs/vlc/libvlc_media_player.h new file mode 100644 index 000000000..982e70ad3 --- /dev/null +++ b/Libs/vlc/libvlc_media_player.h @@ -0,0 +1,3304 @@ +/***************************************************************************** + * libvlc_media_player.h: libvlc_media_player external API + ***************************************************************************** + * Copyright (C) 1998-2024 VLC authors and VideoLAN + * + * Authors: Clément Stenac + * Jean-Paul Saman + * Pierre d'Herbemont + * Maxime Chapelet + * Alexandre Janniaux + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_MEDIA_PLAYER_H +#define VLC_LIBVLC_MEDIA_PLAYER_H 1 + +/* Definitions of enum properties for video */ +#include "libvlc_video.h" + +# ifdef __cplusplus +extern "C" { +# else +# include +# endif + +typedef struct libvlc_video_viewpoint_t libvlc_video_viewpoint_t; +typedef enum libvlc_media_slave_type_t libvlc_media_slave_type_t; +typedef struct libvlc_media_t libvlc_media_t; +typedef struct libvlc_media_track_t libvlc_media_track_t; +typedef struct libvlc_media_tracklist_t libvlc_media_tracklist_t; +typedef enum libvlc_track_type_t libvlc_track_type_t; +typedef struct libvlc_renderer_item_t libvlc_renderer_item_t; +typedef enum libvlc_state_t libvlc_state_t; + +/** \defgroup libvlc_media_player LibVLC media player + * \ingroup libvlc + * A LibVLC media player plays one media (usually in a custom drawable). + * @{ + * \file + * LibVLC simple media player external API + */ + +typedef struct libvlc_media_player_t libvlc_media_player_t; + +/** + * Description for titles + */ +enum +{ + libvlc_title_menu = 0x01, + libvlc_title_interactive = 0x02 +}; + +typedef struct libvlc_title_description_t +{ + int64_t i_duration; /**< duration in milliseconds */ + char *psz_name; /**< title name */ + unsigned i_flags; /**< info if item was recognized as a menu, interactive or plain content by the demuxer */ +} libvlc_title_description_t; + +/** + * Description for chapters + */ +typedef struct libvlc_chapter_description_t +{ + int64_t i_time_offset; /**< time-offset of the chapter in milliseconds */ + int64_t i_duration; /**< duration of the chapter in milliseconds */ + char *psz_name; /**< chapter name */ +} libvlc_chapter_description_t; + +/** + * Description for audio output. It contains + * name, description and pointer to next record. + */ +typedef struct libvlc_audio_output_t +{ + char *psz_name; + char *psz_description; + struct libvlc_audio_output_t *p_next; + +} libvlc_audio_output_t; + +/** + * Description for audio output device. + */ +typedef struct libvlc_audio_output_device_t +{ + struct libvlc_audio_output_device_t *p_next; /**< Next entry in list */ + char *psz_device; /**< Device identifier string */ + char *psz_description; /**< User-friendly device description */ + /* More fields may be added here in later versions */ +} libvlc_audio_output_device_t; + +/** + * Marq options definition + */ +typedef enum libvlc_video_marquee_option_t { + libvlc_marquee_Enable = 0, + libvlc_marquee_Text, /** string argument */ + libvlc_marquee_Color, + libvlc_marquee_Opacity, + libvlc_marquee_Position, + libvlc_marquee_Refresh, + libvlc_marquee_Size, + libvlc_marquee_Timeout, + libvlc_marquee_X, + libvlc_marquee_Y +} libvlc_video_marquee_option_t; + +/** + * Navigation mode + */ +typedef enum libvlc_navigate_mode_t +{ + libvlc_navigate_activate = 0, + libvlc_navigate_up, + libvlc_navigate_down, + libvlc_navigate_left, + libvlc_navigate_right, + libvlc_navigate_popup +} libvlc_navigate_mode_t; + +/** + * Enumeration of values used to set position (e.g. of video title). + */ +typedef enum libvlc_position_t { + libvlc_position_disable=-1, + libvlc_position_center, + libvlc_position_left, + libvlc_position_right, + libvlc_position_top, + libvlc_position_top_left, + libvlc_position_top_right, + libvlc_position_bottom, + libvlc_position_bottom_left, + libvlc_position_bottom_right +} libvlc_position_t; + +/** + * Enumeration of values used to set the video fitting inside the display area. + */ +typedef enum libvlc_video_fit_mode_t { + libvlc_video_fit_none = 0, /**< Explicit zoom set by \ref libvlc_video_set_scale */ + libvlc_video_fit_smaller, /**< Fit inside / to smallest display dimension */ + libvlc_video_fit_larger, /**< Fit outside / to largest display dimension */ + libvlc_video_fit_width, /**< Fit to display width */ + libvlc_video_fit_height, /**< Fit to display height */ +} libvlc_video_fit_mode_t; + +/** + * Enumeration of teletext keys than can be passed via + * libvlc_video_set_teletext() + */ +typedef enum libvlc_teletext_key_t { + libvlc_teletext_key_red = 'r' << 16, + libvlc_teletext_key_green = 'g' << 16, + libvlc_teletext_key_yellow = 'y' << 16, + libvlc_teletext_key_blue = 'b' << 16, + libvlc_teletext_key_index = 'i' << 16, +} libvlc_teletext_key_t; + +/** + * A to B loop state + */ +typedef enum libvlc_abloop_t { + libvlc_abloop_none, + libvlc_abloop_a, + libvlc_abloop_b, +} libvlc_abloop_t; + +/** + * Opaque equalizer handle. + * + * Equalizer settings can be applied to a media player. + */ +typedef struct libvlc_equalizer_t libvlc_equalizer_t; + +/** + * Create an empty Media Player object + * + * \param p_libvlc_instance the libvlc instance in which the Media Player + * should be created. + * \return a new media player object, or NULL on error. + * It must be released by libvlc_media_player_release(). + */ +LIBVLC_API libvlc_media_player_t * libvlc_media_player_new( libvlc_instance_t *p_libvlc_instance ); + +/** + * Create a Media Player object from a Media + * + * \param inst LibVLC instance to create a media player with + * \param p_md the media. Afterwards the p_md can be safely + * destroyed. + * \return a new media player object, or NULL on error. + * It must be released by libvlc_media_player_release(). + */ +LIBVLC_API libvlc_media_player_t * libvlc_media_player_new_from_media( libvlc_instance_t *inst, libvlc_media_t *p_md ); + +/** + * Release a media_player after use + * Decrement the reference count of a media player object. If the + * reference count is 0, then libvlc_media_player_release() will + * release the media player object. If the media player object + * has been released, then it should not be used again. + * + * \param p_mi the Media Player to free + */ +LIBVLC_API void libvlc_media_player_release( libvlc_media_player_t *p_mi ); + +/** + * Retain a reference to a media player object. Use + * libvlc_media_player_release() to decrement reference count. + * + * \param p_mi media player object + * \return the same object + */ +LIBVLC_API libvlc_media_player_t *libvlc_media_player_retain( libvlc_media_player_t *p_mi ); + +/** + * Set the media that will be used by the media_player. If any, + * previous md will be released. + * + * \note The user should listen to the libvlc_MediaPlayerMediaChanged event, to + * know when the new media is actually used by the player (or to known that the + * older media is no longer used). + * + * \param p_mi the Media Player + * \param p_md the Media. Afterwards the p_md can be safely + * destroyed. + */ +LIBVLC_API void libvlc_media_player_set_media( libvlc_media_player_t *p_mi, + libvlc_media_t *p_md ); + +/** + * Get the media used by the media_player. + * + * \warning Calling this function just after libvlc_media_player_set_media() + * will return the media that was just set, but this media might not be + * currently used internally by the player. To detect such case, the user + * should listen to the libvlc_MediaPlayerMediaChanged event. + * + * \param p_mi the Media Player + * \return the media associated with p_mi, or NULL if no + * media is associated + */ +LIBVLC_API libvlc_media_t * libvlc_media_player_get_media( libvlc_media_player_t *p_mi ); + +/** + * Get the Event Manager from which the media player send event. + * + * \param p_mi the Media Player + * \return the event manager associated with p_mi + */ +LIBVLC_API libvlc_event_manager_t * libvlc_media_player_event_manager ( libvlc_media_player_t *p_mi ); + +/** + * is_playing + * + * \param p_mi the Media Player + * \retval true media player is playing + * \retval false media player is not playing + */ +LIBVLC_API bool libvlc_media_player_is_playing(libvlc_media_player_t *p_mi); + +/** + * Play + * + * \param p_mi the Media Player + * \return 0 if playback started (and was already started), or -1 on error. + */ +LIBVLC_API int libvlc_media_player_play ( libvlc_media_player_t *p_mi ); + +/** + * Pause or resume (no effect if there is no media) + * + * \param mp the Media Player + * \param do_pause play/resume if zero, pause if non-zero + * \version LibVLC 1.1.1 or later + */ +LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t *mp, + int do_pause ); + +/** + * Toggle pause (no effect if there is no media) + * + * \param p_mi the Media Player + */ +LIBVLC_API void libvlc_media_player_pause ( libvlc_media_player_t *p_mi ); + +/** + * Stop asynchronously + * + * \note This function is asynchronous. In case of success, the user should + * wait for the libvlc_MediaPlayerStopped event to know when the stop is + * finished. + * + * \param p_mi the Media Player + * \return 0 if the player is being stopped, -1 otherwise (no-op) + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int libvlc_media_player_stop_async ( libvlc_media_player_t *p_mi ); + +/** + * Set a renderer to the media player + * + * \note must be called before the first call of libvlc_media_player_play() to + * take effect. + * + * \see libvlc_renderer_discoverer_new + * + * \param p_mi the Media Player + * \param p_item an item discovered by libvlc_renderer_discoverer_start() + * \return 0 on success, -1 on error. + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi, + libvlc_renderer_item_t *p_item ); + +/** + * Enumeration of the Video color primaries. + */ +typedef enum libvlc_video_color_primaries_t { + libvlc_video_primaries_BT601_525 = 1, + libvlc_video_primaries_BT601_625 = 2, + libvlc_video_primaries_BT709 = 3, + libvlc_video_primaries_BT2020 = 4, + libvlc_video_primaries_DCI_P3 = 5, + libvlc_video_primaries_BT470_M = 6, +} libvlc_video_color_primaries_t; + +/** + * Enumeration of the Video color spaces. + */ +typedef enum libvlc_video_color_space_t { + libvlc_video_colorspace_BT601 = 1, + libvlc_video_colorspace_BT709 = 2, + libvlc_video_colorspace_BT2020 = 3, +} libvlc_video_color_space_t; + +/** + * Enumeration of the Video transfer functions. + */ +typedef enum libvlc_video_transfer_func_t { + libvlc_video_transfer_func_LINEAR = 1, + libvlc_video_transfer_func_SRGB = 2, + libvlc_video_transfer_func_BT470_BG = 3, + libvlc_video_transfer_func_BT470_M = 4, + libvlc_video_transfer_func_BT709 = 5, + libvlc_video_transfer_func_PQ = 6, + libvlc_video_transfer_func_SMPTE_240 = 7, + libvlc_video_transfer_func_HLG = 8, +} libvlc_video_transfer_func_t; + + +/** + * Callback prototype to allocate and lock a picture buffer. + * + * Whenever a new video frame needs to be decoded, the lock callback is + * invoked. Depending on the video chroma, one or three pixel planes of + * adequate dimensions must be returned via the second parameter. Those + * planes must be aligned on 32-bytes boundaries. + * + * \param[in] opaque private pointer as passed to libvlc_video_set_callbacks() + * \param[out] planes start address of the pixel planes (LibVLC allocates the array + * of void pointers, this callback must initialize the array) + * \return a private pointer for the display and unlock callbacks to identify + * the picture buffers + */ +typedef void *(*libvlc_video_lock_cb)(void *opaque, void **planes); + +/** + * Callback prototype to unlock a picture buffer. + * + * When the video frame decoding is complete, the unlock callback is invoked. + * This callback might not be needed at all. It is only an indication that the + * application can now read the pixel values if it needs to. + * + * \note A picture buffer is unlocked after the picture is decoded, + * but before the picture is displayed. + * + * \param[in] opaque private pointer as passed to libvlc_video_set_callbacks() + * \param[in] picture private pointer returned from the @ref libvlc_video_lock_cb + * callback + * \param[in] planes pixel planes as defined by the @ref libvlc_video_lock_cb + * callback (this parameter is only for convenience) + */ +typedef void (*libvlc_video_unlock_cb)(void *opaque, void *picture, + void *const *planes); + +/** + * Callback prototype to display a picture. + * + * When the video frame needs to be shown, as determined by the media playback + * clock, the display callback is invoked. + * + * \param[in] opaque private pointer as passed to libvlc_video_set_callbacks() + * \param[in] picture private pointer returned from the @ref libvlc_video_lock_cb + * callback + */ +typedef void (*libvlc_video_display_cb)(void *opaque, void *picture); + +/** + * Callback prototype to configure picture buffers format. + * This callback gets the format of the video as output by the video decoder + * and the chain of video filters (if any). It can opt to change any parameter + * as it needs. In that case, LibVLC will attempt to convert the video format + * (rescaling and chroma conversion) but these operations can be CPU intensive. + * + * \param[in,out] opaque pointer to the private pointer passed to + * libvlc_video_set_callbacks() + * \param[in,out] chroma pointer to the 4 bytes video format identifier + * \param[in,out] width pointer to the buffer width in pixels + * \param[in,out] height pointer to the buffer height in pixels + * \param[out] pitches table of scanline pitches in bytes for each pixel plane + * (the table is allocated by LibVLC) + * \param[out] lines table of scanlines count for each plane + * \return the number of picture buffers allocated, 0 indicates failure + * + * \version LibVLC 4.0.0 and later. + * \param[in] width pointer to display width - 1 in pixels + * \param[in] height pointer to display height - 1 in pixels + * + * \note + * For each pixels plane, the scanline pitch must be bigger than or equal to + * the number of bytes per pixel multiplied by the pixel width. + * Similarly, the number of scanlines must be bigger than of equal to + * the pixel height. + * Furthermore, we recommend that pitches and lines be multiple of 32 + * to not break assumptions that might be held by optimized code + * in the video decoders, video filters and/or video converters. + */ +typedef unsigned (*libvlc_video_format_cb)(void **opaque, char *chroma, + unsigned *width, unsigned *height, + unsigned *pitches, + unsigned *lines); + +/** + * Callback prototype to configure picture buffers format. + * + * \param[in] opaque private pointer as passed to libvlc_video_set_format_callbacks() + * (and possibly modified by @ref libvlc_video_format_cb) + */ +typedef void (*libvlc_video_cleanup_cb)(void *opaque); + + +/** + * Set callbacks and private data to render decoded video to a custom area + * in memory. + * Use libvlc_video_set_format() or libvlc_video_set_format_callbacks() + * to configure the decoded format. + * + * \warning Rendering video into custom memory buffers is considerably less + * efficient than rendering in a custom window as normal. + * + * For optimal performances, VLC media player renders into a custom window, and + * does not use this function and associated callbacks. It is highly + * recommended that other LibVLC-based application do likewise. + * To embed video in a window, use libvlc_media_player_set_xwindow() or + * equivalent depending on the operating system. + * + * If window embedding does not fit the application use case, then a custom + * LibVLC video output display plugin is required to maintain optimal video + * rendering performances. + * + * The following limitations affect performance: + * - Hardware video decoding acceleration will either be disabled completely, + * or require (relatively slow) copy from video/DSP memory to main memory. + * - Sub-pictures (subtitles, on-screen display, etc.) must be blent into the + * main picture by the CPU instead of the GPU. + * - Depending on the video format, pixel format conversion, picture scaling, + * cropping and/or picture re-orientation, must be performed by the CPU + * instead of the GPU. + * - Memory copying is required between LibVLC reference picture buffers and + * application buffers (between lock and unlock callbacks). + * + * \param mp the media player + * \param lock callback to lock video memory (must not be NULL) + * \param unlock callback to unlock video memory (or NULL if not needed) + * \param display callback to display video (or NULL if not needed) + * \param opaque private pointer for the three callbacks (as first parameter) + * \version LibVLC 1.1.1 or later + */ +LIBVLC_API +void libvlc_video_set_callbacks( libvlc_media_player_t *mp, + libvlc_video_lock_cb lock, + libvlc_video_unlock_cb unlock, + libvlc_video_display_cb display, + void *opaque ); + +/** + * Set decoded video chroma and dimensions. + * This only works in combination with libvlc_video_set_callbacks(), + * and is mutually exclusive with libvlc_video_set_format_callbacks(). + * + * \param mp the media player + * \param chroma a four-characters string identifying the chroma + * (e.g. "RV32" or "YUYV") + * \param width pixel width + * \param height pixel height + * \param pitch line pitch (in bytes) + * \version LibVLC 1.1.1 or later + * \bug All pixel planes are expected to have the same pitch. + * To use the YCbCr color space with chrominance subsampling, + * consider using libvlc_video_set_format_callbacks() instead. + */ +LIBVLC_API +void libvlc_video_set_format( libvlc_media_player_t *mp, const char *chroma, + unsigned width, unsigned height, + unsigned pitch ); + +/** + * Set decoded video chroma and dimensions. This only works in combination with + * libvlc_video_set_callbacks(). + * + * \param mp the media player + * \param setup callback to select the video format (cannot be NULL) + * \param cleanup callback to release any allocated resources (or NULL) + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API +void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp, + libvlc_video_format_cb setup, + libvlc_video_cleanup_cb cleanup ); + + +typedef struct libvlc_video_setup_device_cfg_t +{ + bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */ +} libvlc_video_setup_device_cfg_t; + +typedef struct libvlc_video_setup_device_info_t +{ + union { + struct { + void *device_context; /** ID3D11DeviceContext* */ + void *context_mutex; /** Windows Mutex HANDLE to protect ID3D11DeviceContext usage */ + } d3d11; + struct { + void *device; /** IDirect3D9* */ + int adapter; /** Adapter to use with the IDirect3D9* */ + } d3d9; + }; +} libvlc_video_setup_device_info_t; + +/** + * Callback prototype called to initialize user data. + * Setup the rendering environment. + * + * \param[in,out] opaque private pointer passed to the @a libvlc_video_set_output_callbacks() + * on input. The callback can change this value on output to be + * passed to all the other callbacks set on @a libvlc_video_set_output_callbacks(). + * \param[in] cfg requested configuration of the video device + * \param[out] out libvlc_video_setup_device_info_t* to fill + * \return true on success + * \version LibVLC 4.0.0 or later + * + * For \ref libvlc_video_engine_d3d9 the output must be a IDirect3D9*. + * A reference to this object is held until the \ref libvlc_video_output_cleanup_cb is called. + * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0. + * + * For \ref libvlc_video_engine_d3d11 the output must be a ID3D11DeviceContext*. + * A reference to this object is held until the \ref libvlc_video_output_cleanup_cb is called. + * The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled. + * + * If the ID3D11DeviceContext is used outside of the callbacks called by libvlc, the host + * MUST use a mutex to protect the access to the ID3D11DeviceContext of libvlc. This mutex + * value is set on d3d11.context_mutex. If the ID3D11DeviceContext is not used outside of + * the callbacks, the mutex d3d11.context_mutex may be NULL. + */ +typedef bool (*libvlc_video_output_setup_cb)(void **opaque, + const libvlc_video_setup_device_cfg_t *cfg, + libvlc_video_setup_device_info_t *out); + + +/** + * Callback prototype called to release user data + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \version LibVLC 4.0.0 or later + */ +typedef void (*libvlc_video_output_cleanup_cb)(void* opaque); + +typedef struct libvlc_video_render_cfg_t +{ + /** rendering video width in pixel */ + unsigned width; + /** rendering video height in pixel */ + unsigned height; + /** rendering video bit depth in bits per channel */ + unsigned bitdepth; + /** video is full range or studio/limited range */ + bool full_range; + /** video color space */ + libvlc_video_color_space_t colorspace; + /** video color primaries */ + libvlc_video_color_primaries_t primaries; + /** video transfer function */ + libvlc_video_transfer_func_t transfer; + /** device used for rendering, IDirect3DDevice9* for D3D9 */ + void *device; +} libvlc_video_render_cfg_t; + +typedef struct libvlc_video_output_cfg_t +{ + union { + /** The rendering DXGI_FORMAT for \ref libvlc_video_engine_d3d11. */ + int dxgi_format; + /** The rendering D3DFORMAT for \ref libvlc_video_engine_d3d9. */ + uint32_t d3d9_format; + /** The rendering GLint GL_RGBA or GL_RGB for + * \ref libvlc_video_engine_opengl and for + * \ref libvlc_video_engine_gles2. */ + int opengl_format; + /** currently unused */ + void *p_surface; + struct { + /** Pointer to an ANativeWindow, used for video rendering */ + void *video; + /** Pointer to an ANativeWindow, used for subtitles rendering, if + * blending subtitles into the video surface is not possible (when + * using MediaCodec with direct hw rendering) */ + void *subtitle; + } anw; + }; + /** Video is full range or studio/limited range. */ + bool full_range; + /** video color space */ + libvlc_video_color_space_t colorspace; + /** video color primaries */ + libvlc_video_color_primaries_t primaries; + /** video transfer function */ + libvlc_video_transfer_func_t transfer; + /** video surface orientation */ + libvlc_video_orient_t orientation; +} libvlc_video_output_cfg_t; + +/** + * Callback prototype called on video size changes. + * Update the rendering output setup. + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \param[in] cfg configuration of the video that will be rendered + * \param[out] output configuration describing with how the rendering is setup + * \version LibVLC 4.0.0 or later + * + * \note the configuration device for Direct3D9 is the IDirect3DDevice9 that VLC + * uses to render. The host must set a Render target and call Present() + * when it needs the drawing from VLC to be done. This object is not valid + * anymore after Cleanup is called. + * Tone mapping, range and color conversion will be done depending on the + * values set in the output structure. It can be ignored in the \ref + * libvlc_video_engine_anw case. + */ +typedef bool (*libvlc_video_update_output_cb)(void* opaque, const libvlc_video_render_cfg_t *cfg, + libvlc_video_output_cfg_t *output ); + + +/** + * Callback prototype called after performing drawing calls. + * + * This callback is called outside of libvlc_video_makeCurrent_cb current/not-current + * calls. + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \version LibVLC 4.0.0 or later + */ +typedef void (*libvlc_video_swap_cb)(void* opaque); + +/** + * Callback prototype to set up the OpenGL context for rendering. + * Tell the host the rendering is about to start/has finished. + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \param[in] enter true to set the context as current, false to unset it + * \return true on success + * \version LibVLC 4.0.0 or later + * + * On Direct3D11 the following may change on the provided ID3D11DeviceContext* + * between \p enter being true and \p enter being false: + * - IASetPrimitiveTopology() + * - IASetInputLayout() + * - IASetVertexBuffers() + * - IASetIndexBuffer() + * - VSSetConstantBuffers() + * - VSSetShader() + * - PSSetSamplers() + * - PSSetConstantBuffers() + * - PSSetShaderResources() + * - PSSetShader() + * - RSSetViewports() + * - DrawIndexed() + */ +typedef bool (*libvlc_video_makeCurrent_cb)(void* opaque, bool enter); + +/** + * Callback prototype to load opengl functions + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \param fct_name name of the opengl function to load + * \return a pointer to the named OpenGL function the NULL otherwise + * \version LibVLC 4.0.0 or later + */ +typedef void* (*libvlc_video_getProcAddress_cb)(void* opaque, const char* fct_name); + +typedef struct libvlc_video_frame_hdr10_metadata_t +{ + /* similar to SMPTE ST 2086 mastering display color volume */ + uint16_t RedPrimary[2]; + uint16_t GreenPrimary[2]; + uint16_t BluePrimary[2]; + uint16_t WhitePoint[2]; + unsigned int MaxMasteringLuminance; + unsigned int MinMasteringLuminance; + uint16_t MaxContentLightLevel; + uint16_t MaxFrameAverageLightLevel; +} libvlc_video_frame_hdr10_metadata_t; + +typedef enum libvlc_video_metadata_type_t { + libvlc_video_metadata_frame_hdr10, /**< libvlc_video_frame_hdr10_metadata_t */ +} libvlc_video_metadata_type_t; + +/** + * Callback prototype to receive metadata before rendering. + * + * \param[in] opaque private pointer passed to the @a libvlc_video_set_output_callbacks() + * \param[in] type type of data passed in metadata + * \param[in] metadata the type of metadata + * \version LibVLC 4.0.0 or later + */ +typedef void (*libvlc_video_frameMetadata_cb)(void* opaque, libvlc_video_metadata_type_t type, const void *metadata); + +/** + * Enumeration of the Video engine to be used on output. + * can be passed to @a libvlc_video_set_output_callbacks + */ +typedef enum libvlc_video_engine_t { + /** Disable rendering engine */ + libvlc_video_engine_disable, + libvlc_video_engine_opengl, + libvlc_video_engine_gles2, + /** Direct3D11 rendering engine */ + libvlc_video_engine_d3d11, + /** Direct3D9 rendering engine */ + libvlc_video_engine_d3d9, + + /** + * Android ANativeWindow. It can be set in \ref libvlc_video_output_cfg_t + * from the \ref libvlc_video_update_output_cb callback. The ANativeWindow + * can be created via: + * - 'ANativeWindow_fromSurface': from a JAVA SurfaceView + * - 'AImageReader_getWindow()': from an 'AImageReader' created with the + * following arguments: \verbatim + AImageReader_newWithUsage(1, 1 AIMAGE_FORMAT_PRIVATE, + AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, + maxImages, &reader); + \endverbatim + * The width and height from \ref libvlc_video_render_cfg_t should be + * ignored as the video size is overridden by the producer (MediaCodec or + * EGL vout). + */ + libvlc_video_engine_anw, +} libvlc_video_engine_t; + + +/** Callback type that can be called to request a render size changes. + * + * libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb. + * + * \param report_opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN] + * \param width new rendering width requested. [IN] + * \param height new rendering height requested. [IN] + */ +typedef void( *libvlc_video_output_resize_cb )( void *report_opaque, unsigned width, unsigned height ); + + +/** + * Enumeration of the different mouse buttons that can be reported for user interaction + * can be passed to \ref libvlc_video_output_mouse_press_cb and \ref libvlc_video_output_mouse_release_cb. + */ +typedef enum libvlc_video_output_mouse_button_t { + libvlc_video_output_mouse_button_left = 0, + libvlc_video_output_mouse_button_middle = 1, + libvlc_video_output_mouse_button_right = 2 +} libvlc_video_output_mouse_button_t; + + +/** Callback type that can be called to notify the mouse position when hovering the render surface. + * + * libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb. + * + * The position (0,0) denotes the top left corner, bottom right corner position + * is (width,height) as reported by \ref libvlc_video_output_resize_cb. + * + * \param opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN] + * \param x horizontal mouse position in \ref libvlc_video_output_resize_cb coordinates. [IN] + * \param y vertical mouse position in \ref libvlc_video_output_resize_cb coordinates. [IN] + */ +typedef void (*libvlc_video_output_mouse_move_cb)(void *opaque, int x, int y); + +/** Callback type that can be called to notify when a mouse button is pressed in the rendering surface. + * + * libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb. + * + * The button event will be reported at the last position provided by \ref libvlc_video_output_mouse_move_cb + * + * \param opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN] + * \param button represent the button pressed, see \ref libvlc_video_output_mouse_button_t for available buttons. [IN] + */ +typedef void (*libvlc_video_output_mouse_press_cb)(void *opaque, libvlc_video_output_mouse_button_t button); + +/** Callback type that can be called to notify when a mouse button is released in the rendering surface. + * + * libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb. + * + * The button event will be reported at the last position provided by \ref libvlc_video_output_mouse_move_cb. + * + * \param opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN] + * \param button represent the button released, see \ref libvlc_video_output_mouse_button_t for available buttons. [IN] + */ +typedef void (*libvlc_video_output_mouse_release_cb)(void *opaque, libvlc_video_output_mouse_button_t button); + +/** Set the callback to call when the host app resizes the rendering area. + * + * This allows text rendering and aspect ratio to be handled properly when the host + * rendering size changes and to provide mouse. + * + * It may be called before the \ref libvlc_video_output_setup_cb callback. + * + * \warning These callbacks cannot be called concurrently, the caller is responsible for serialization + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \param[in] report_size_change callback which must be called when the host size changes. + * The callback is valid until another call to \ref libvlc_video_output_set_window_cb + * is done. This may be called from any thread. + * \param[in] report_mouse_move callback which must be called when the mouse position change on the video surface. + * The coordinates are relative to the size reported through the \p report_size_change. + * This may be called from any thread. + * \param[in] report_mouse_pressed callback which must be called when a mouse button is pressed on the video surface, + * The position of the event is the last position reported by the report_mouse_move callback. This may be + * called from any thread. + * \param[in] report_mouse_released callback which must be called when a mouse button is released on the video surface, + * The position of the event is the last position reported by the report_mouse_move callback. This may be + * called from any thread. + * \param[in] report_opaque private pointer to pass to the \p report_size_change callback. + */ +typedef void( *libvlc_video_output_set_window_cb )( void *opaque, + libvlc_video_output_resize_cb report_size_change, + libvlc_video_output_mouse_move_cb report_mouse_move, + libvlc_video_output_mouse_press_cb report_mouse_pressed, + libvlc_video_output_mouse_release_cb report_mouse_released, + void *report_opaque ); + +/** Tell the host the rendering for the given plane is about to start + * + * \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() + * \param plane number of the rendering plane to select + * \param output handle of the rendering output for the given plane + * \return true on success + * \version LibVLC 4.0.0 or later + * + * \note This is only used with \ref libvlc_video_engine_d3d11. + * + * The output parameter receives the ID3D11RenderTargetView* to use for rendering + * the plane. + * + * If this callback is not used (set to NULL in @a libvlc_video_set_output_callbacks()) + * OMSetRenderTargets has to be set during the @a libvlc_video_makeCurrent_cb() + * entering call. + * + * The number of planes depend on the DXGI_FORMAT returned during the + * @a libvlc_video_update_output_cb() call. It's usually one plane except for + * semi-planar formats like DXGI_FORMAT_NV12 or DXGI_FORMAT_P010. + * + * This callback is called between libvlc_video_makeCurrent_cb current/not-current + * calls. + */ +typedef bool( *libvlc_video_output_select_plane_cb )( void *opaque, size_t plane, void *output ); + +/** + * Set callbacks and data to render decoded video to a custom texture + * + * \warning VLC will perform video rendering in its own thread and at its own rate, + * You need to provide your own synchronisation mechanism. + * + * \param mp the media player + * \param engine the GPU engine to use + * \param setup_cb callback called to initialize user data + * \param cleanup_cb callback called to clean up user data + * \param window_cb callback called to setup the window + * \param update_output_cb callback to get the rendering format of the host (cannot be NULL) + * \param swap_cb callback called after rendering a video frame (can only be + * NULL when using \ref libvlc_video_engine_anw) + * \param makeCurrent_cb callback called to enter/leave the rendering context + * (can only be NULL when using \ref libvlc_video_engine_anw) + * \param getProcAddress_cb opengl function loading callback (cannot be NULL + * for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2) + * \param metadata_cb callback to provide frame metadata (D3D11 only) + * \param select_plane_cb callback to select different D3D11 rendering targets + * \param opaque private pointer passed to callbacks + * + * \note the \p setup_cb and \p cleanup_cb may be called more than once per + * playback. + * + * \retval true engine selected and callbacks set + * \retval false engine type unknown, callbacks not set + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API +bool libvlc_video_set_output_callbacks( libvlc_media_player_t *mp, + libvlc_video_engine_t engine, + libvlc_video_output_setup_cb setup_cb, + libvlc_video_output_cleanup_cb cleanup_cb, + libvlc_video_output_set_window_cb window_cb, + libvlc_video_update_output_cb update_output_cb, + libvlc_video_swap_cb swap_cb, + libvlc_video_makeCurrent_cb makeCurrent_cb, + libvlc_video_getProcAddress_cb getProcAddress_cb, + libvlc_video_frameMetadata_cb metadata_cb, + libvlc_video_output_select_plane_cb select_plane_cb, + void* opaque ); + +/** + * Helper to setup output_callbacks for \ref libvlc_video_engine_anw + */ +static inline bool +libvlc_video_set_anw_callbacks( libvlc_media_player_t *mp, + libvlc_video_output_setup_cb setup_cb, + libvlc_video_output_cleanup_cb cleanup_cb, + libvlc_video_update_output_cb update_output_cb, + void *opaque ) +{ + return libvlc_video_set_output_callbacks( mp, libvlc_video_engine_anw, + setup_cb, cleanup_cb, NULL, + update_output_cb, NULL, NULL, + NULL, NULL, NULL, opaque ); +} + +/** + * Set the handler where the media player should display its video output. + * + * The drawable is an `NSObject` that require responding to two selectors + * like in this protocol: + * + * @code{.m} + * @protocol VLCDrawable + * - (void)addSubview:(VLCView *)view; + * - (CGRect)bounds; + * @end + * @endcode + * + * In this protocol `VLCView` type can either be a `UIView` or a `NSView` type + * class. + * VLCDrawable protocol conformance isn't mandatory but a drawable must respond + * to both `addSubview:` and `bounds` selectors. + * + * Additionally, a drawable can also conform to the `VLCPictureInPictureDrawable` + * protocol to allow picture in picture support : + * + * @code{.m} + * @protocol VLCPictureInPictureMediaControlling + * - (void)play; + * - (void)pause; + * - (void)seekBy:(int64_t)offset completion:(dispatch_block_t)completion;; + * - (int64_t)mediaLength; + * - (int64_t)mediaTime; + * - (BOOL)isMediaSeekable; + * - (BOOL)isMediaPlaying; + * @end + * + * @protocol VLCPictureInPictureWindowControlling + * - (void)startPictureInPicture; + * - (void)stopPictureInPicture; + * - (void)invalidatePlaybackState; + * @end + * + * @protocol VLCPictureInPictureDrawable + * - (id) mediaController; + * - (void (^)(id)) pictureInPictureReady; + * @end + * @endcode + * + * Be aware that full `VLCPictureInPictureDrawable` conformance is mandatory to + * enable picture in picture support and that time values in + * `VLCPictureInPictureMediaControlling` methods are expressed in milliseconds. + * + * If you want to use it along with Qt see the QMacCocoaViewContainer. Then + * the following code should work: + * @code{.mm} + * { + * NSView *video = [[NSView alloc] init]; + * QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); + * libvlc_media_player_set_nsobject(mp, video); + * [video release]; + * } + * @endcode + * + * You can find a live example in VLCVideoView in VLCKit.framework. + * + * \param p_mi the Media Player + * \param drawable the drawable that is either an NSView, a UIView or any + * NSObject responding to `addSubview:` and `bounds` selectors + */ +LIBVLC_API void libvlc_media_player_set_nsobject ( libvlc_media_player_t *p_mi, void * drawable ); + +/** + * Get the NSView handler previously set with libvlc_media_player_set_nsobject(). + * + * \param p_mi the Media Player + * \return the NSView handler or 0 if none where set + */ +LIBVLC_API void * libvlc_media_player_get_nsobject ( libvlc_media_player_t *p_mi ); + +/** + * Set an X Window System drawable where the media player should render its + * video output. The call takes effect when the playback starts. If it is + * already started, it might need to be stopped before changes apply. + * If LibVLC was built without X11 output support, then this function has no + * effects. + * + * By default, LibVLC will capture input events on the video rendering area. + * Use libvlc_video_set_mouse_input() and libvlc_video_set_key_input() to + * disable that and deliver events to the parent window / to the application + * instead. By design, the X11 protocol delivers input events to only one + * recipient. + * + * \warning + * The application must call the XInitThreads() function from Xlib before + * libvlc_new(), and before any call to XOpenDisplay() directly or via any + * other library. Failure to call XInitThreads() will seriously impede LibVLC + * performance. Calling XOpenDisplay() before XInitThreads() will eventually + * crash the process. That is a limitation of Xlib. + * + * \param p_mi media player + * \param drawable X11 window ID + * + * \note + * The specified identifier must correspond to an existing Input/Output class + * X11 window. Pixmaps are not currently supported. The default X11 + * server is assumed, i.e. that specified in the DISPLAY environment variable. + * + * \warning + * LibVLC can deal with invalid X11 handle errors, however some display drivers + * (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle + * must remain valid until playback is stopped, otherwise the process may + * abort or crash. + * + * \bug + * No more than one window handle per media player instance can be specified. + * If the media has multiple simultaneously active video tracks, extra tracks + * will be rendered into external windows beyond the control of the + * application. + */ +LIBVLC_API void libvlc_media_player_set_xwindow(libvlc_media_player_t *p_mi, + uint32_t drawable); + +/** + * Get the X Window System window identifier previously set with + * libvlc_media_player_set_xwindow(). Note that this will return the identifier + * even if VLC is not currently using it (for instance if it is playing an + * audio-only input). + * + * \param p_mi the Media Player + * \return an X window ID, or 0 if none where set. + */ +LIBVLC_API uint32_t libvlc_media_player_get_xwindow ( libvlc_media_player_t *p_mi ); + +/** + * Set a Win32/Win64 API window handle (HWND) where the media player should + * render its video output. If LibVLC was built without Win32/Win64 API output + * support, then this has no effects. + * + * \warning the HWND must have the WS_CLIPCHILDREN set in its style. + * + * \param p_mi the Media Player + * \param drawable windows handle of the drawable + */ +LIBVLC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t *p_mi, void *drawable ); + +/** + * Get the Windows API window handle (HWND) previously set with + * libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC + * is not currently outputting any video to it. + * + * \param p_mi the Media Player + * \return a window handle or NULL if there are none. + */ +LIBVLC_API void *libvlc_media_player_get_hwnd ( libvlc_media_player_t *p_mi ); + +/** + * Set the android context. + * + * \version LibVLC 3.0.0 and later. + * + * \param p_mi the media player + * \param p_awindow_handler org.videolan.libvlc.AWindow jobject owned by the + * org.videolan.libvlc.MediaPlayer class from the libvlc-android project. + */ +LIBVLC_API void libvlc_media_player_set_android_context( libvlc_media_player_t *p_mi, + void *p_awindow_handler ); + +/** + * Callback prototype for audio playback. + * + * The LibVLC media player decodes and post-processes the audio signal + * asynchronously (in an internal thread). Whenever audio samples are ready + * to be queued to the output, this callback is invoked. + * + * The number of samples provided per invocation may depend on the file format, + * the audio coding algorithm, the decoder plug-in, the post-processing + * filters and timing. Application must not assume a certain number of samples. + * + * The exact format of audio samples is determined by libvlc_audio_set_format() + * or libvlc_audio_set_format_callbacks() as is the channels layout. + * + * Note that the number of samples is per channel. For instance, if the audio + * track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds + * of audio signal - regardless of the number of audio channels. + * + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + * \param[in] samples pointer to a table of audio samples to play back + * \param count number of audio samples to play back + * \param pts expected play time stamp (see libvlc_delay()) + */ +typedef void (*libvlc_audio_play_cb)(void *data, const void *samples, + unsigned count, int64_t pts); + +/** + * Callback prototype for audio pause. + * + * LibVLC invokes this callback to pause audio playback. + * + * \note The pause callback is never called if the audio is already paused. + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + * \param pts time stamp of the pause request (should be elapsed already) + */ +typedef void (*libvlc_audio_pause_cb)(void *data, int64_t pts); + +/** + * Callback prototype for audio resumption. + * + * LibVLC invokes this callback to resume audio playback after it was + * previously paused. + * + * \note The resume callback is never called if the audio is not paused. + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + * \param pts time stamp of the resumption request (should be elapsed already) + */ +typedef void (*libvlc_audio_resume_cb)(void *data, int64_t pts); + +/** + * Callback prototype for audio buffer flush. + * + * LibVLC invokes this callback if it needs to discard all pending buffers and + * stop playback as soon as possible. This typically occurs when the media is + * stopped. + * + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + */ +typedef void (*libvlc_audio_flush_cb)(void *data, int64_t pts); + +/** + * Callback prototype for audio buffer drain. + * + * LibVLC may invoke this callback when the decoded audio track is ending. + * There will be no further decoded samples for the track, but playback should + * nevertheless continue until all already pending buffers are rendered. + * + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + */ +typedef void (*libvlc_audio_drain_cb)(void *data); + +/** + * Callback prototype for audio volume change. + * \param[in] data data pointer as passed to libvlc_audio_set_callbacks() + * \param volume software volume (1. = nominal, 0. = mute) + * \param mute muted flag + */ +typedef void (*libvlc_audio_set_volume_cb)(void *data, + float volume, bool mute); + +/** + * Sets callbacks and private data for decoded audio. + * + * Use libvlc_audio_set_format() or libvlc_audio_set_format_callbacks() + * to configure the decoded audio format. + * + * \note The audio callbacks override any other audio output mechanism. + * If the callbacks are set, LibVLC will not output audio in any way. + * + * \param mp the media player + * \param play callback to play audio samples (must not be NULL) + * \param pause callback to pause playback (or NULL to ignore) + * \param resume callback to resume playback (or NULL to ignore) + * \param flush callback to flush audio buffers (or NULL to ignore) + * \param drain callback to drain audio buffers (or NULL to ignore) + * \param opaque private pointer for the audio callbacks (as first parameter) + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API +void libvlc_audio_set_callbacks( libvlc_media_player_t *mp, + libvlc_audio_play_cb play, + libvlc_audio_pause_cb pause, + libvlc_audio_resume_cb resume, + libvlc_audio_flush_cb flush, + libvlc_audio_drain_cb drain, + void *opaque ); + +/** + * Set callbacks and private data for decoded audio. This only works in + * combination with libvlc_audio_set_callbacks(). + * Use libvlc_audio_set_format() or libvlc_audio_set_format_callbacks() + * to configure the decoded audio format. + * + * \param mp the media player + * \param set_volume callback to apply audio volume, + * or NULL to apply volume in software + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API +void libvlc_audio_set_volume_callback( libvlc_media_player_t *mp, + libvlc_audio_set_volume_cb set_volume ); + +/** + * Callback prototype to setup the audio playback. + * + * This is called when the media player needs to create a new audio output. + * \param[in,out] opaque pointer to the data pointer passed to + * libvlc_audio_set_callbacks() + * \param[in,out] format 4 bytes sample format + * \param[in,out] rate sample rate + * \param[in,out] channels channels count + * \return 0 on success, anything else to skip audio playback + */ +typedef int (*libvlc_audio_setup_cb)(void **opaque, char *format, unsigned *rate, + unsigned *channels); + +/** + * Callback prototype for audio playback cleanup. + * + * This is called when the media player no longer needs an audio output. + * \param[in] opaque data pointer as passed to libvlc_audio_set_callbacks() + */ +typedef void (*libvlc_audio_cleanup_cb)(void *opaque); + +/** + * Sets decoded audio format via callbacks. + * + * This only works in combination with libvlc_audio_set_callbacks(). + * + * \param mp the media player + * \param setup callback to select the audio format (cannot be NULL) + * \param cleanup callback to release any allocated resources (or NULL) + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API +void libvlc_audio_set_format_callbacks( libvlc_media_player_t *mp, + libvlc_audio_setup_cb setup, + libvlc_audio_cleanup_cb cleanup ); + +/** + * Sets a fixed decoded audio format. + * + * This only works in combination with libvlc_audio_set_callbacks(), + * and is mutually exclusive with libvlc_audio_set_format_callbacks(). + * + * The supported formats are: + * - "S16N" for signed 16-bit PCM + * - "S32N" for signed 32-bit PCM + * - "FL32" for single precision IEEE 754 + * + * All supported formats use the native endianness. + * If there are more than one channel, samples are interleaved. + * + * \param mp the media player + * \param format a four-characters string identifying the sample format + * \param rate sample rate (expressed in Hz) + * \param channels channels count + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API +void libvlc_audio_set_format( libvlc_media_player_t *mp, const char *format, + unsigned rate, unsigned channels ); + +/** \bug This might go away ... to be replaced by a broader system */ + +/** + * Get the current movie length (in ms). + * + * \param p_mi the Media Player + * \return the movie length (in ms), or -1 if there is no media. + */ +LIBVLC_API libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t *p_mi ); + +/** + * Get the current movie time (in ms). + * + * \param p_mi the Media Player + * \return the movie time (in ms), or -1 if there is no media. + */ +LIBVLC_API libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi ); + +/** + * Set the movie time (in ms). + * + * This has no effect if no media is being played. + * Not all formats and protocols support this. + * + * \param p_mi the Media Player + * \param i_time the movie time (in ms). + * \param b_fast prefer fast seeking or precise seeking + * \return 0 on success, -1 on error + */ +LIBVLC_API int libvlc_media_player_set_time( libvlc_media_player_t *p_mi, + libvlc_time_t i_time, bool b_fast ); + +/** + * Jump the movie time (in ms). + * + * This will trigger a precise and relative seek (from the current time). + * This has no effect if no media is being played. + * Not all formats and protocols support this. + * + * \param p_mi the Media Player + * \param i_time the movie time (in ms). + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API int libvlc_media_player_jump_time( libvlc_media_player_t *p_mi, + libvlc_time_t i_time ); + +/** + * Get movie position as percentage between 0.0 and 1.0. + * + * \param p_mi the Media Player + * \return movie position, or -1. in case of error + */ +LIBVLC_API double libvlc_media_player_get_position( libvlc_media_player_t *p_mi ); + +/** + * Set movie position as percentage between 0.0 and 1.0. + * This has no effect if playback is not enabled. + * This might not work depending on the underlying input format and protocol. + * + * \param p_mi the Media Player + * \param b_fast prefer fast seeking or precise seeking + * \param f_pos the position + * \return 0 on success, -1 on error + */ +LIBVLC_API int libvlc_media_player_set_position( libvlc_media_player_t *p_mi, + double f_pos, bool b_fast ); + +/** + * Enable A to B loop for the current media by setting the start time and end + * time + * + * The B time must be higher than the A time. + * + * \param p_mi the Media Player + * \param a_time start time for the loop (in ms) + * \param b_time end time for the loop (in ms) + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API int +libvlc_media_player_set_abloop_time( libvlc_media_player_t *p_mi, + libvlc_time_t a_time, libvlc_time_t b_time ); + +/** + * Enable A to B loop for the current media by setting the start position and + * end position + * + * The B position must be higher than the A position. + * + * \param p_mi the Media Player + * \param a_pos start position for the loop + * \param b_pos end position for the loop + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API int +libvlc_media_player_set_abloop_position( libvlc_media_player_t *p_mi, + double a_pos, double b_pos ); + +/** + * Reset/remove the A to B loop for the current media + * + * \param p_mi the Media Player + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API int +libvlc_media_player_reset_abloop( libvlc_media_player_t *p_mi ); + +/** + * Get the A to B loop status + * + * @note If the returned status is VLC_PLAYER_ABLOOP_A, then a_time and a_pos + * will be valid. If the returned status is VLC_PLAYER_ABLOOP_B, then all + * output parameters are valid. If the returned status is + * VLC_PLAYER_ABLOOP_NONE, then all output parameters are invalid. + * + * @see vlc_player_cbs.on_atobloop_changed + * + * \param p_mi the Media Player + * \param a_time A time (in ms) or -1 (if the media doesn't have valid times) + * \param a_pos A position + * \param b_time B time (in ms) or -1 (if the media doesn't have valid times) + * \param b_pos B position + * \return A to B loop status + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API libvlc_abloop_t +libvlc_media_player_get_abloop( libvlc_media_player_t *p_mi, + libvlc_time_t *a_time, double *a_pos, + libvlc_time_t *b_time, double *b_pos ); +/** + * Set movie chapter (if applicable). + * + * \param p_mi the Media Player + * \param i_chapter chapter number to play + */ +LIBVLC_API void libvlc_media_player_set_chapter( libvlc_media_player_t *p_mi, int i_chapter ); + +/** + * Get movie chapter. + * + * \param p_mi the Media Player + * \return chapter number currently playing, or -1 if there is no media. + */ +LIBVLC_API int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi ); + +/** + * Get movie chapter count + * + * \param p_mi the Media Player + * \return number of chapters in movie, or -1. + */ +LIBVLC_API int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi ); + +/** + * Get title chapter count + * + * \param p_mi the Media Player + * \param i_title title + * \return number of chapters in title, or -1 + */ +LIBVLC_API int libvlc_media_player_get_chapter_count_for_title( + libvlc_media_player_t *p_mi, int i_title ); + +/** + * Set movie title + * + * \param p_mi the Media Player + * \param i_title title number to play + */ +LIBVLC_API void libvlc_media_player_set_title( libvlc_media_player_t *p_mi, int i_title ); + +/** + * Get movie title + * + * \param p_mi the Media Player + * \return title number currently playing, or -1 + */ +LIBVLC_API int libvlc_media_player_get_title( libvlc_media_player_t *p_mi ); + +/** + * Get movie title count + * + * \param p_mi the Media Player + * \return title number count, or -1 + */ +LIBVLC_API int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi ); + +/** + * Set previous chapter (if applicable) + * + * \param p_mi the Media Player + */ +LIBVLC_API void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi ); + +/** + * Set next chapter (if applicable) + * + * \param p_mi the Media Player + */ +LIBVLC_API void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi ); + +/** + * Get the requested movie play rate. + * @warning Depending on the underlying media, the requested rate may be + * different from the real playback rate. + * + * \param p_mi the Media Player + * \return movie play rate + */ +LIBVLC_API float libvlc_media_player_get_rate( libvlc_media_player_t *p_mi ); + +/** + * Set movie play rate + * + * \param p_mi the Media Player + * \param rate movie play rate to set + * \return -1 if an error was detected, 0 otherwise (but even then, it might + * not actually work depending on the underlying media protocol) + */ +LIBVLC_API int libvlc_media_player_set_rate( libvlc_media_player_t *p_mi, float rate ); + +/** + * Get current movie state + * + * \param p_mi the Media Player + * \return the current state of the media player (playing, paused, ...) \see libvlc_state_t + */ +LIBVLC_API libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi ); + +/** + * How many video outputs does this media player have? + * + * \param p_mi the media player + * \return the number of video outputs + */ +LIBVLC_API unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi ); + +/** + * Is this media player seekable? + * + * \param p_mi the media player + * \retval true media player can seek + * \retval false media player cannot seek + */ +LIBVLC_API bool libvlc_media_player_is_seekable(libvlc_media_player_t *p_mi); + +/** + * Can this media player be paused? + * + * \param p_mi the media player + * \retval true media player can be paused + * \retval false media player cannot be paused + */ +LIBVLC_API bool libvlc_media_player_can_pause(libvlc_media_player_t *p_mi); + +/** + * Check if the current program is scrambled + * + * \param p_mi the media player + * \retval true current program is scrambled + * \retval false current program is not scrambled + * + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API bool libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi ); + +/** + * Display the next frame (if supported) + * + * \param p_mi the media player + */ +LIBVLC_API void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi ); + +/** + * Navigate through DVD Menu + * + * \param p_mi the Media Player + * \param navigate the Navigation mode + * \version libVLC 2.0.0 or later + */ +LIBVLC_API void libvlc_media_player_navigate( libvlc_media_player_t* p_mi, + unsigned navigate ); + +/** + * Set if, and how, the video title will be shown when media is played. + * + * \param p_mi the media player + * \param position position at which to display the title, or libvlc_position_disable to prevent the title from being displayed + * \param timeout title display timeout in milliseconds (ignored if libvlc_position_disable) + * \version libVLC 2.1.0 or later + */ +LIBVLC_API void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, libvlc_position_t position, unsigned int timeout ); + +/** + * Get the track list for one type + * + * \version LibVLC 4.0.0 and later. + * + * \note You need to call libvlc_media_parse_request() or play the media + * at least once before calling this function. Not doing this will result in + * an empty list. + * + * \note This track list is a snapshot of the current tracks when this function + * is called. If a track is updated after this call, the user will need to call + * this function again to get the updated track. + * + * + * The track list can be used to get track information and to select specific + * tracks. + * + * \param p_mi the media player + * \param type type of the track list to request + * \param selected filter only selected tracks if true (return all tracks, even + * selected ones if false) + * + * \return a valid libvlc_media_tracklist_t or NULL in case of error, if there + * is no track for a category, the returned list will have a size of 0, delete + * with libvlc_media_tracklist_delete() + */ +LIBVLC_API libvlc_media_tracklist_t * +libvlc_media_player_get_tracklist( libvlc_media_player_t *p_mi, + libvlc_track_type_t type, bool selected ); + +/** + * Get the selected track for one type + * + * \version LibVLC 4.0.0 and later. + * + * \warning More than one tracks can be selected for one type. In that case, + * libvlc_media_player_get_tracklist() should be used. + * + * \param p_mi the media player + * \param type type of the selected track + * + * \return a valid track or NULL if there is no selected tracks for this type, + * release it with libvlc_media_track_release(). + */ +LIBVLC_API libvlc_media_track_t * +libvlc_media_player_get_selected_track( libvlc_media_player_t *p_mi, + libvlc_track_type_t type ); + +/* + * Get a track from a track id + * + * \version LibVLC 4.0.0 and later. + * + * This function can be used to get the last updated information of a track. + * + * \param p_mi the media player + * \param psz_id valid string representing a track id (cf. psz_id from \ref + * libvlc_media_track_t) + * + * \return a valid track or NULL if there is currently no tracks identified by + * the string id, release it with libvlc_media_track_release(). + */ +LIBVLC_API libvlc_media_track_t * +libvlc_media_player_get_track_from_id( libvlc_media_player_t *p_mi, + const char *psz_id ); + + +/** + * Select a track + * + * This will unselected the current track. + * + * \version LibVLC 4.0.0 and later. + * + * \note Use libvlc_media_player_select_tracks() for multiple selection + * + * \warning Only use a \ref libvlc_media_track_t retrieved with \ref libvlc_media_player_get_tracklist + * + * \param p_mi the media player + * \param track track to select, can't be NULL + */ +LIBVLC_API void +libvlc_media_player_select_track( libvlc_media_player_t *p_mi, + const libvlc_media_track_t *track ); + +/** + * Unselect all tracks for a given type + * + * \version LibVLC 4.0.0 and later. + * + * \param p_mi the media player + * \param type type to unselect + */ +LIBVLC_API void +libvlc_media_player_unselect_track_type( libvlc_media_player_t *p_mi, + libvlc_track_type_t type ); + +/** + * Select multiple tracks for one type + * + * \version LibVLC 4.0.0 and later. + * + * \note The internal track list can change between the calls of + * libvlc_media_player_get_tracklist() and + * libvlc_media_player_set_tracks(). If a track selection change but the + * track is not present anymore, the player will just ignore it. + * + * \note selecting multiple audio tracks is currently not supported. + * + * \warning Only use a \ref libvlc_media_track_t retrieved with \ref libvlc_media_player_get_tracklist + * + * \param p_mi the media player + * \param type type of the selected track + * \param tracks pointer to the track array, or NULL if track_count is 0 + * \param track_count number of tracks in the track array + */ +LIBVLC_API void +libvlc_media_player_select_tracks( libvlc_media_player_t *p_mi, + libvlc_track_type_t type, + const libvlc_media_track_t **tracks, + size_t track_count ); + +/** + * Select tracks by their string identifier + * + * \version LibVLC 4.0.0 and later. + * + * This function can be used pre-select a list of tracks before starting the + * player. It has only effect for the current media. It can also be used when + * the player is already started. + * + * 'str_ids' can contain more than one track id, delimited with ','. "" or any + * invalid track id will cause the player to unselect all tracks of that + * category. NULL will disable the preference for newer tracks without + * unselecting any current tracks. + * + * Example: + * - (libvlc_track_video, "video/1,video/2") will select these 2 video tracks. + * If there is only one video track with the id "video/0", no tracks will be + * selected. + * - (libvlc_track_type_t, "${slave_url_md5sum}/spu/0) will select one spu + * added by an input slave with the corresponding url. + * + * \note The string identifier of a track can be found via psz_id from \ref + * libvlc_media_track_t + * + * \note selecting multiple audio tracks is currently not supported. + * + * \warning Only use a \ref libvlc_media_track_t id retrieved with \ref libvlc_media_player_get_tracklist + * + * \param p_mi the media player + * \param type type to select + * \param psz_ids list of string identifier or NULL + */ +LIBVLC_API void +libvlc_media_player_select_tracks_by_ids( libvlc_media_player_t *p_mi, + libvlc_track_type_t type, + const char *psz_ids ); + +/** + * Add a slave to the current media player. + * + * \note If the player is playing, the slave will be added directly. This call + * will also update the slave list of the attached libvlc_media_t. + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_slaves_add + * + * \param p_mi the media player + * \param i_type subtitle or audio + * \param psz_uri Uri of the slave (should contain a valid scheme). + * \param b_select True if this slave should be selected when it's loaded + * + * \return 0 on success, -1 on error. + */ +LIBVLC_API +int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi, + libvlc_media_slave_type_t i_type, + const char *psz_uri, bool b_select ); + +typedef struct libvlc_player_program_t +{ + /** Id used for libvlc_media_player_select_program() */ + int i_group_id; + /** Program name, always valid */ + char *psz_name; + /** True if the program is selected */ + bool b_selected; + /** True if the program is scrambled */ + bool b_scrambled; +} libvlc_player_program_t; + +/** + * Opaque struct containing a list of program + */ +typedef struct libvlc_player_programlist_t libvlc_player_programlist_t; + +/** + * Delete a program struct + * + * \version LibVLC 4.0.0 and later. + * + * \param program returned by libvlc_media_player_get_selected_program() or + * libvlc_media_player_get_program_from_id() + * + */ +LIBVLC_API void +libvlc_player_program_delete( libvlc_player_program_t *program ); + +/** + * Get the number of programs in a programlist + * + * \version LibVLC 4.0.0 and later. + * + * \param list valid programlist + * + * \return number of programs, or 0 if the list is empty + */ +LIBVLC_API size_t +libvlc_player_programlist_count( const libvlc_player_programlist_t *list ); + +/** + * Get a program at a specific index + * + * \warning The behaviour is undefined if the index is not valid. + * + * \version LibVLC 4.0.0 and later. + * + * \param list valid programlist + * \param index valid index in the range [0; count[ + * + * \return a valid program (can't be NULL if libvlc_player_programlist_count() + * returned a valid count) + */ +LIBVLC_API libvlc_player_program_t * +libvlc_player_programlist_at( libvlc_player_programlist_t *list, size_t index ); + +/** + * Release a programlist + * + * \note program structs from the list are also deleted. + * + * \version LibVLC 4.0.0 and later. + * + * \see libvlc_media_player_get_programlist + * + * \param list valid programlist + */ +LIBVLC_API void +libvlc_player_programlist_delete( libvlc_player_programlist_t *list ); + +/** + * Select program with a given program id. + * + * \note program ids are sent via the libvlc_MediaPlayerProgramAdded event or + * can be fetch via libvlc_media_player_get_programlist() + * + * \version LibVLC 4.0.0 or later + * + * \param p_mi opaque media player handle + * \param i_group_id program id + */ +LIBVLC_API void libvlc_media_player_select_program_id( libvlc_media_player_t *p_mi, int i_group_id); + +/** + * Get the selected program + * + * \version LibVLC 4.0.0 or later + * + * \param p_mi opaque media player handle + * + * \return a valid program struct or NULL if no programs are selected. The + * program need to be freed with libvlc_player_program_delete(). + */ +LIBVLC_API libvlc_player_program_t * +libvlc_media_player_get_selected_program( libvlc_media_player_t *p_mi); + +/** + * Get a program struct from a program id + * + * \version LibVLC 4.0.0 or later + * + * \param p_mi opaque media player handle + * \param i_group_id program id + * + * \return a valid program struct or NULL if the i_group_id is not found. The + * program need to be freed with libvlc_player_program_delete(). + */ +LIBVLC_API libvlc_player_program_t * +libvlc_media_player_get_program_from_id( libvlc_media_player_t *p_mi, int i_group_id ); + +/** + * Get the program list + * + * \version LibVLC 4.0.0 and later. + * \note This program list is a snapshot of the current programs when this + * function is called. If a program is updated after this call, the user will + * need to call this function again to get the updated program. + * + * The program list can be used to get program information and to select + * specific programs. + * + * \param p_mi the media player + * + * \return a valid libvlc_media_programlist_t or NULL in case of error or empty + * list, delete with libvlc_media_programlist_delete() + */ +LIBVLC_API libvlc_player_programlist_t * +libvlc_media_player_get_programlist( libvlc_media_player_t *p_mi ); + + +/** \defgroup libvlc_video LibVLC video controls + * @{ + */ + +/** + * Toggle fullscreen status on non-embedded video outputs. + * + * @warning The same limitations applies to this function + * as to libvlc_set_fullscreen(). + * + * \param p_mi the media player + */ +LIBVLC_API void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi ); + +/** + * Enable or disable fullscreen. + * + * @warning With most window managers, only a top-level windows can be in + * full-screen mode. Hence, this function will not operate properly if + * libvlc_media_player_set_xwindow() was used to embed the video in a + * non-top-level window. In that case, the embedding window must be reparented + * to the root window before fullscreen mode is enabled. You will want + * to reparent it back to its normal parent when disabling fullscreen. + * + * \note This setting applies to any and all current or future active video + * tracks and windows for the given media player. The choice of fullscreen + * output for each window is left to the operating system. + * + * \param p_mi the media player + * \param b_fullscreen boolean for fullscreen status + */ +LIBVLC_API void libvlc_set_fullscreen(libvlc_media_player_t *p_mi, bool b_fullscreen); + +/** + * Get current fullscreen status. + * + * \param p_mi the media player + * \return the fullscreen status (boolean) + * + * \retval false media player is windowed + * \retval true media player is in fullscreen mode + */ +LIBVLC_API bool libvlc_get_fullscreen( libvlc_media_player_t *p_mi ); + +/** + * Enable or disable key press events handling, according to the LibVLC hotkeys + * configuration. By default and for historical reasons, keyboard events are + * handled by the LibVLC video widget. + * + * \note On X11, there can be only one subscriber for key press and mouse + * click events per window. If your application has subscribed to those events + * for the X window ID of the video widget, then LibVLC will not be able to + * handle key presses and mouse clicks in any case. + * + * \warning This function is only implemented for X11 and Win32 at the moment. + * + * \param p_mi the media player + * \param on true to handle key press events, false to ignore them. + */ +LIBVLC_API +void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on ); + +/** + * Enable or disable mouse click events handling. By default, those events are + * handled. This is needed for DVD menus to work, as well as a few video + * filters such as "puzzle". + * + * \see libvlc_video_set_key_input(). + * + * \warning This function is only implemented for X11 and Win32 at the moment. + * + * \param p_mi the media player + * \param on true to handle mouse click events, false to ignore them. + */ +LIBVLC_API +void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on ); + +/** + * Get the pixel dimensions of a video. + * + * \param p_mi media player + * \param num number of the video (starting from, and most commonly 0) + * \param[out] px pointer to get the pixel width + * \param[out] py pointer to get the pixel height + * \return 0 on success, -1 if the specified video does not exist + */ +LIBVLC_API +int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num, + unsigned *px, unsigned *py ); + +/** + * Get the mouse pointer coordinates over a video. + * Coordinates are expressed in terms of the decoded video resolution, + * not in terms of pixels on the screen/viewport (to get the latter, + * you can query your windowing system directly). + * + * Either of the coordinates may be negative or larger than the corresponding + * dimension of the video, if the cursor is outside the rendering area. + * + * @warning The coordinates may be out-of-date if the pointer is not located + * on the video rendering area. LibVLC does not track the pointer if it is + * outside of the video widget. + * + * @note LibVLC does not support multiple pointers (it does of course support + * multiple input devices sharing the same pointer) at the moment. + * + * \param p_mi media player + * \param num number of the video (starting from, and most commonly 0) + * \param[out] px pointer to get the abscissa + * \param[out] py pointer to get the ordinate + * \return 0 on success, -1 if the specified video does not exist + */ +LIBVLC_API +int libvlc_video_get_cursor( libvlc_media_player_t *p_mi, unsigned num, + int *px, int *py ); + +/** + * Get the current video scaling factor. + * See also libvlc_video_set_scale(). + * + * \param p_mi the media player + * \return the currently configured zoom factor, or 0. if the video is set + * to fit to the output window/drawable automatically. + */ +LIBVLC_API float libvlc_video_get_scale( libvlc_media_player_t *p_mi ); + +/** + * Set the video scaling factor. That is the ratio of the number of pixels on + * screen to the number of pixels in the original decoded video in each + * dimension. Zero is a special value; it will adjust the video to the output + * window/drawable (in windowed mode) or the entire screen. + * + * Note that not all video outputs support scaling. + * + * \param p_mi the media player + * \param f_factor the scaling factor, or zero + */ +LIBVLC_API void libvlc_video_set_scale( libvlc_media_player_t *p_mi, float f_factor ); + +/** + * Get current video aspect ratio. + * + * \param p_mi the media player + * \return the video aspect ratio or NULL if unspecified + * (the result must be released with free() or libvlc_free()). + */ +LIBVLC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi ); + +/** + * Set new video aspect ratio. + * + * \param p_mi the media player + * \param psz_aspect new video aspect-ratio or NULL to reset to source aspect ratio + * \note Invalid aspect ratios are ignored. + */ +LIBVLC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, const char *psz_aspect ); + +/** + * Get current video display fit mode. + * + * \version LibVLC 4.0.0 or later + * + * \param p_mi the media player + * \return the video display fit mode. + */ +LIBVLC_API libvlc_video_fit_mode_t libvlc_video_get_display_fit( libvlc_media_player_t *p_mi ); + +/** + * Set new video display fit. + * + * \version LibVLC 4.0.0 or later + * + * \param p_mi the media player + * \param fit new display fit mode + * \note Invalid fit mode are ignored. + */ +LIBVLC_API void libvlc_video_set_display_fit( libvlc_media_player_t *p_mi, libvlc_video_fit_mode_t fit ); + +/** + * Create a video viewpoint structure. + * + * \version LibVLC 3.0.0 and later + * + * \return video viewpoint or NULL + * (the result must be released with free()). + */ +LIBVLC_API libvlc_video_viewpoint_t *libvlc_video_new_viewpoint(void); + +/** + * Update the video viewpoint information. + * + * \note It is safe to call this function before the media player is started. + * + * \version LibVLC 3.0.0 and later + * + * \param p_mi the media player + * \param p_viewpoint video viewpoint allocated via libvlc_video_new_viewpoint() + * \param b_absolute if true replace the old viewpoint with the new one. If + * false, increase/decrease it. + * \return -1 in case of error, 0 otherwise + * + * \note the values are set asynchronously, it will be used by the next frame displayed. + */ +LIBVLC_API int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi, + const libvlc_video_viewpoint_t *p_viewpoint, + bool b_absolute); + +/** + * Video stereo modes + */ +typedef enum libvlc_video_stereo_mode_t { + libvlc_VideoStereoAuto = 0, + libvlc_VideoStereoStereo, + libvlc_VideoStereoLeftEye, + libvlc_VideoStereoRightEye, + libvlc_VideoStereoSideBySide, +} libvlc_video_stereo_mode_t; + +/** + * Get current video stereo mode. + * + * \param p_mi the media player + * \return the video stereo mode. + */ +LIBVLC_API libvlc_video_stereo_mode_t libvlc_video_get_video_stereo_mode( + libvlc_media_player_t *p_mi ); + +/** + * Set new video stereo mode. + * + * \param p_mi the media player + * \param i_mode new video stereo mode + */ +LIBVLC_API void libvlc_video_set_video_stereo_mode( libvlc_media_player_t *p_mi, + const libvlc_video_stereo_mode_t i_mode ); + +/** + * Get the current subtitle delay. Positive values means subtitles are being + * displayed later, negative values earlier. + * + * \param p_mi media player + * \return time (in microseconds) the display of subtitles is being delayed + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi ); + +/** + * Get the current subtitle text scale + * + * The scale factor is expressed as a percentage of the default size, where + * 1.0 represents 100 percent. + * + * \param p_mi media player + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API float libvlc_video_get_spu_text_scale( libvlc_media_player_t *p_mi ); + +/** + * Set the subtitle text scale. + * + * The scale factor is expressed as a percentage of the default size, where + * 1.0 represents 100 percent. + * + * A value of 0.5 would result in text half the normal size, and a value of 2.0 + * would result in text twice the normal size. + * + * The minimum acceptable value for the scale factor is 0.1. + * + * The maximum is 5.0 (five times normal size). + * + * \param p_mi media player + * \param f_scale scale factor in the range [0.1;5.0] (default: 1.0) + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_video_set_spu_text_scale( libvlc_media_player_t *p_mi, float f_scale ); + +/** + * Set the subtitle delay. This affects the timing of when the subtitle will + * be displayed. Positive values result in subtitles being displayed later, + * while negative values will result in subtitles being displayed earlier. + * + * The subtitle delay will be reset to zero each time the media changes. + * + * \param p_mi media player + * \param i_delay time (in microseconds) the display of subtitles should be delayed + * \return 0 on success, -1 on error + * \version LibVLC 2.0.0 or later + */ +LIBVLC_API int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi, int64_t i_delay ); + +/** + * Get the full description of available titles + * + * \version LibVLC 3.0.0 and later. + * + * \param p_mi the media player + * \param[out] titles address to store an allocated array of title descriptions + * descriptions (must be freed with libvlc_title_descriptions_release() + * by the caller) + * + * \return the number of titles (-1 on error) + */ +LIBVLC_API int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi, + libvlc_title_description_t ***titles ); + +/** + * Release a title description + * + * \version LibVLC 3.0.0 and later + * + * \param p_titles title description array to release + * \param i_count number of title descriptions to release + */ +LIBVLC_API + void libvlc_title_descriptions_release( libvlc_title_description_t **p_titles, + unsigned i_count ); + +/** + * Get the full description of available chapters + * + * \version LibVLC 3.0.0 and later. + * + * \param p_mi the media player + * \param i_chapters_of_title index of the title to query for chapters (uses current title if set to -1) + * \param[out] pp_chapters address to store an allocated array of chapter descriptions + * descriptions (must be freed with libvlc_chapter_descriptions_release() + * by the caller) + * + * \return the number of chapters (-1 on error) + */ +LIBVLC_API int libvlc_media_player_get_full_chapter_descriptions( libvlc_media_player_t *p_mi, + int i_chapters_of_title, + libvlc_chapter_description_t *** pp_chapters ); + +/** + * Release a chapter description + * + * \version LibVLC 3.0.0 and later + * + * \param p_chapters chapter description array to release + * \param i_count number of chapter descriptions to release + */ +LIBVLC_API +void libvlc_chapter_descriptions_release( libvlc_chapter_description_t **p_chapters, + unsigned i_count ); + +/** + * Set/unset the video crop ratio. + * + * This function forces a crop ratio on any and all video tracks rendered by + * the media player. If the display aspect ratio of a video does not match the + * crop ratio, either the top and bottom, or the left and right of the video + * will be cut out to fit the crop ratio. + * + * For instance, a ratio of 1:1 will force the video to a square shape. + * + * To disable video crop, set a crop ratio with zero as denominator. + * + * A call to this function overrides any previous call to any of + * libvlc_video_set_crop_ratio(), libvlc_video_set_crop_border() and/or + * libvlc_video_set_crop_window(). + * + * \see libvlc_video_set_aspect_ratio() + * + * \param mp the media player + * \param num crop ratio numerator (ignored if denominator is 0) + * \param den crop ratio denominator (or 0 to unset the crop ratio) + * + * \version LibVLC 4.0.0 and later + */ +LIBVLC_API +void libvlc_video_set_crop_ratio(libvlc_media_player_t *mp, + unsigned num, unsigned den); + +/** + * Set the video crop window. + * + * This function selects a sub-rectangle of video to show. Any pixels outside + * the rectangle will not be shown. + * + * To unset the video crop window, use libvlc_video_set_crop_ratio() or + * libvlc_video_set_crop_border(). + * + * A call to this function overrides any previous call to any of + * libvlc_video_set_crop_ratio(), libvlc_video_set_crop_border() and/or + * libvlc_video_set_crop_window(). + * + * \param mp the media player + * \param x abscissa (i.e. leftmost sample column offset) of the crop window + * \param y ordinate (i.e. topmost sample row offset) of the crop window + * \param width sample width of the crop window (cannot be zero) + * \param height sample height of the crop window (cannot be zero) + * + * \version LibVLC 4.0.0 and later + */ +LIBVLC_API +void libvlc_video_set_crop_window(libvlc_media_player_t *mp, + unsigned x, unsigned y, + unsigned width, unsigned height); + +/** + * Set the video crop borders. + * + * This function selects the size of video edges to be cropped out. + * + * To unset the video crop borders, set all borders to zero. + * + * A call to this function overrides any previous call to any of + * libvlc_video_set_crop_ratio(), libvlc_video_set_crop_border() and/or + * libvlc_video_set_crop_window(). + * + * \param mp the media player + * \param left number of sample columns to crop on the left + * \param right number of sample columns to crop on the right + * \param top number of sample rows to crop on the top + * \param bottom number of sample rows to corp on the bottom + * + * \version LibVLC 4.0.0 and later + */ +LIBVLC_API +void libvlc_video_set_crop_border(libvlc_media_player_t *mp, + unsigned left, unsigned right, + unsigned top, unsigned bottom); + +/** + * Get current teletext page requested or 0 if it's disabled. + * + * Teletext is disabled by default, call libvlc_video_set_teletext() to enable + * it. + * + * \param p_mi the media player + * \return the current teletext page requested. + */ +LIBVLC_API int libvlc_video_get_teletext( libvlc_media_player_t *p_mi ); + +/** + * Set new teletext page to retrieve. + * + * This function can also be used to send a teletext key. + * + * \param p_mi the media player + * \param i_page teletex page number requested. This value can be 0 to disable + * teletext, a number in the range ]0;1000[ to show the requested page, or a + * \ref libvlc_teletext_key_t. 100 is the default teletext page. + */ +LIBVLC_API void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page ); + +/** + * Set teletext background transparency. + * + * \param p_mi the media player + * \param transparent whether background should be transparent. + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_video_set_teletext_transparency( libvlc_media_player_t *p_mi, bool transparent ); + +/** + * Get teletext background transparency. + * + * \param p_mi the media player + * \retval true teletext has transparent background + * \retval false teletext has opaque background + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API bool libvlc_video_get_teletext_transparency( libvlc_media_player_t *p_mi ); + +/** + * Take a snapshot of the current video window. + * + * If i_width AND i_height is 0, original size is used. + * If i_width XOR i_height is 0, original aspect-ratio is preserved. + * + * \param p_mi media player instance + * \param num number of video output (typically 0 for the first/only one) + * \param psz_filepath the path of a file or a folder to save the screenshot into + * \param i_width the snapshot's width + * \param i_height the snapshot's height + * \return 0 on success, -1 if the video was not found + */ +LIBVLC_API +int libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num, + const char *psz_filepath, unsigned int i_width, + unsigned int i_height ); + +/** + * Enable or disable deinterlace filter + * + * \param p_mi libvlc media player + * \param deinterlace state -1: auto (default), 0: disabled, 1: enabled + * \param psz_mode type of deinterlace filter, NULL for current/default filter + * \version LibVLC 4.0.0 and later + */ +LIBVLC_API void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, + int deinterlace, + const char *psz_mode ); + +/** + * Get an integer marquee option value + * + * \param p_mi libvlc media player + * \param option marq option to get \see libvlc_video_marquee_option_t + */ +LIBVLC_API int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi, + unsigned option ); + +/** + * Enable, disable or set an integer marquee option + * + * Setting libvlc_marquee_Enable has the side effect of enabling (arg !0) + * or disabling (arg 0) the marq filter. + * + * \param p_mi libvlc media player + * \param option marq option to set \see libvlc_video_marquee_option_t + * \param i_val marq option value + */ +LIBVLC_API void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi, + unsigned option, int i_val ); + +/** + * Set a marquee string option + * + * \param p_mi libvlc media player + * \param option marq option to set \see libvlc_video_marquee_option_t + * \param psz_text marq option value + */ +LIBVLC_API void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi, + unsigned option, const char *psz_text ); + +/** option values for libvlc_video_{get,set}_logo_{int,string} */ +enum libvlc_video_logo_option_t { + libvlc_logo_enable, + libvlc_logo_file, /**< string argument, "file,d,t;file,d,t;..." */ + libvlc_logo_x, + libvlc_logo_y, + libvlc_logo_delay, + libvlc_logo_repeat, + libvlc_logo_opacity, + libvlc_logo_position +}; + +/** + * Get integer logo option. + * + * \param p_mi libvlc media player instance + * \param option logo option to get, values of libvlc_video_logo_option_t + */ +LIBVLC_API int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi, + unsigned option ); + +/** + * Set logo option as integer. Options that take a different type value + * are ignored. + * Passing libvlc_logo_enable as option value has the side effect of + * starting (arg !0) or stopping (arg 0) the logo filter. + * + * \param p_mi libvlc media player instance + * \param option logo option to set, values of libvlc_video_logo_option_t + * \param value logo option value + */ +LIBVLC_API void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi, + unsigned option, int value ); + +/** + * Set logo option as string. Options that take a different type value + * are ignored. + * + * \param p_mi libvlc media player instance + * \param option logo option to set, values of libvlc_video_logo_option_t + * \param psz_value logo option value + */ +LIBVLC_API void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi, + unsigned option, const char *psz_value ); + + +/** option values for libvlc_video_{get,set}_adjust_{int,float,bool} */ +enum libvlc_video_adjust_option_t { + libvlc_adjust_Enable = 0, + libvlc_adjust_Contrast, + libvlc_adjust_Brightness, + libvlc_adjust_Hue, + libvlc_adjust_Saturation, + libvlc_adjust_Gamma +}; + +/** + * Get integer adjust option. + * + * \param p_mi libvlc media player instance + * \param option adjust option to get, values of libvlc_video_adjust_option_t + * \version LibVLC 1.1.1 and later. + */ +LIBVLC_API int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi, + unsigned option ); + +/** + * Set adjust option as integer. Options that take a different type value + * are ignored. + * Passing libvlc_adjust_enable as option value has the side effect of + * starting (arg !0) or stopping (arg 0) the adjust filter. + * + * \param p_mi libvlc media player instance + * \param option adjust option to set, values of libvlc_video_adjust_option_t + * \param value adjust option value + * \version LibVLC 1.1.1 and later. + */ +LIBVLC_API void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi, + unsigned option, int value ); + +/** + * Get float adjust option. + * + * \param p_mi libvlc media player instance + * \param option adjust option to get, values of libvlc_video_adjust_option_t + * \version LibVLC 1.1.1 and later. + */ +LIBVLC_API float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi, + unsigned option ); + +/** + * Set adjust option as float. Options that take a different type value + * are ignored. + * + * \param p_mi libvlc media player instance + * \param option adjust option to set, values of libvlc_video_adjust_option_t + * \param value adjust option value + * \version LibVLC 1.1.1 and later. + */ +LIBVLC_API void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi, + unsigned option, float value ); +/** + * Change the projection mode used for rendering the source. + * + * This changes how the source is mapped to the output w.r.t. 360 playback. + * + * \param p_mi libvlc media player instance + * \param projection_mode the considered projection mode for the source + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API void +libvlc_video_set_projection_mode(libvlc_media_player_t *player, + libvlc_video_projection_t projection_mode); + +/** + * Remove previously set projection mode. + * + * Remove the effects from previous call to libvlc_video_set_projection_mode. + * + * \param p_mi libvlc media player instance + * \version LibVLC 4.0.0 and later. + */ +LIBVLC_API void +libvlc_video_unset_projection_mode(libvlc_media_player_t *player); + +/** @} video */ + +/** \defgroup libvlc_audio LibVLC audio controls + * @{ + */ + +/** + * Audio stereo modes + */ +typedef enum libvlc_audio_output_stereomode_t { + libvlc_AudioStereoMode_Unset = 0, + libvlc_AudioStereoMode_Stereo = 1, + libvlc_AudioStereoMode_RStereo = 2, + libvlc_AudioStereoMode_Left = 3, + libvlc_AudioStereoMode_Right = 4, + libvlc_AudioStereoMode_Dolbys = 5, + libvlc_AudioStereoMode_Mono = 7, +} libvlc_audio_output_stereomode_t; + +/** + * Audio mix modes + */ +typedef enum libvlc_audio_output_mixmode_t { + libvlc_AudioMixMode_Unset = 0, + libvlc_AudioMixMode_Stereo = 1, + libvlc_AudioMixMode_Binaural = 2, + libvlc_AudioMixMode_4_0 = 3, + libvlc_AudioMixMode_5_1 = 4, + libvlc_AudioMixMode_7_1 = 5, +} libvlc_audio_output_mixmode_t; + +/** + * Gets the list of available audio output modules. + * + * \param p_instance libvlc instance + * \return list of available audio outputs. It must be freed with +* \see libvlc_audio_output_list_release \see libvlc_audio_output_t . + * In case of error, NULL is returned. + */ +LIBVLC_API libvlc_audio_output_t * +libvlc_audio_output_list_get( libvlc_instance_t *p_instance ); + +/** + * Frees the list of available audio output modules. + * + * \param p_list list with audio outputs for release + */ +LIBVLC_API +void libvlc_audio_output_list_release( libvlc_audio_output_t *p_list ); + +/** + * Selects an audio output module. + * \note Any change will take be effect only after playback is stopped and + * restarted. Audio output cannot be changed while playing. + * + * \param p_mi media player + * \param psz_name name of audio output, + * use psz_name of \see libvlc_audio_output_t + * \return 0 if function succeeded, -1 on error + */ +LIBVLC_API int libvlc_audio_output_set( libvlc_media_player_t *p_mi, + const char *psz_name ); + +/** + * Gets a list of potential audio output devices. + * + * See also libvlc_audio_output_device_set(). + * + * \note Not all audio outputs support enumerating devices. + * The audio output may be functional even if the list is empty (NULL). + * + * \note The list may not be exhaustive. + * + * \warning Some audio output devices in the list might not actually work in + * some circumstances. By default, it is recommended to not specify any + * explicit audio device. + * + * \param mp media player + * \return A NULL-terminated linked list of potential audio output devices. + * It must be freed with libvlc_audio_output_device_list_release() + * \version LibVLC 2.2.0 or later. + */ +LIBVLC_API libvlc_audio_output_device_t * +libvlc_audio_output_device_enum( libvlc_media_player_t *mp ); + +#if defined (__GNUC__) && !defined (__clang__) +__attribute__((unused)) +__attribute__((noinline)) +__attribute__((error("Use libvlc_audio_output_device_enum() instead"))) +static libvlc_audio_output_device_t * +libvlc_audio_output_device_list_get( libvlc_instance_t *p_instance, + const char *aout ) +{ + (void) p_instance; (void) aout; + return NULL; +} +#endif + +/** + * Frees a list of available audio output devices. + * + * \param p_list list with audio outputs for release + * \version LibVLC 2.1.0 or later. + */ +LIBVLC_API void libvlc_audio_output_device_list_release( + libvlc_audio_output_device_t *p_list ); + +/** + * Configures an explicit audio output device. + * + * A list of adequate potential device strings can be obtained with + * libvlc_audio_output_device_enum(). + * + * \note This function does not select the specified audio output plugin. + * libvlc_audio_output_set() is used for that purpose. + * + * \warning The syntax for the device parameter depends on the audio output. + * + * Some audio output modules require further parameters (e.g. a channels map + * in the case of ALSA). + * + * \version This function originally expected three parameters. + * The middle parameter was removed from LibVLC 4.0 onward. + * + * \param mp media player + * \param device_id device identifier string + * (see \ref libvlc_audio_output_device_t::psz_device) + * + * \return If the change of device was requested successfully, zero is returned + * (the actual change is asynchronous and not guaranteed to succeed). + * On error, a non-zero value is returned. + */ +LIBVLC_API int libvlc_audio_output_device_set( libvlc_media_player_t *mp, + const char *device_id ); + +/** + * Get the current audio output device identifier. + * + * This complements libvlc_audio_output_device_set(). + * + * \warning The initial value for the current audio output device identifier + * may not be set or may be some unknown value. A LibVLC application should + * compare this value against the known device identifiers (e.g. those that + * were previously retrieved by a call to libvlc_audio_output_device_enum) to + * find the current audio output device. + * + * It is possible that the selected audio output device changes (an external + * change) without a call to libvlc_audio_output_device_set. That may make this + * method unsuitable to use if a LibVLC application is attempting to track + * dynamic audio device changes as they happen. + * + * \param mp media player + * \return the current audio output device identifier + * NULL if no device is selected or in case of error + * (the result must be released with free()). + * \version LibVLC 3.0.0 or later. + */ +LIBVLC_API char *libvlc_audio_output_device_get( libvlc_media_player_t *mp ); + +/** + * Toggle mute status. + * + * \param p_mi media player + * \warning Toggling mute atomically is not always possible: On some platforms, + * other processes can mute the VLC audio playback stream asynchronously. Thus, + * there is a small race condition where toggling will not work. + * See also the limitations of libvlc_audio_set_mute(). + */ +LIBVLC_API void libvlc_audio_toggle_mute( libvlc_media_player_t *p_mi ); + +/** + * Get current mute status. + * + * \param p_mi media player + * \return the mute status (boolean) if defined, -1 if undefined/unapplicable + */ +LIBVLC_API int libvlc_audio_get_mute( libvlc_media_player_t *p_mi ); + +/** + * Set mute status. + * + * \param p_mi media player + * \param status If status is true then mute, otherwise unmute + * \warning This function does not always work. If there are no active audio + * playback stream, the mute status might not be available. If digital + * pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also + * some audio output plugins do not support muting at all. + * \note To force silent playback, disable all audio tracks. This is more + * efficient and reliable than mute. + */ +LIBVLC_API void libvlc_audio_set_mute( libvlc_media_player_t *p_mi, int status ); + +/** + * Get current software audio volume. + * + * \param p_mi media player + * \return the software volume in percents + * (0 = mute, 100 = nominal / 0dB) + */ +LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi ); + +/** + * Set current software audio volume. + * + * \param p_mi media player + * \param i_volume the volume in percents (0 = mute, 100 = 0dB) + * \return 0 if the volume was set, -1 if it was out of range + */ +LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume ); + +/** + * Get current audio stereo-mode. + * + * \param p_mi media player + * \return the audio stereo-mode, \see libvlc_audio_output_stereomode_t + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API libvlc_audio_output_stereomode_t libvlc_audio_get_stereomode( libvlc_media_player_t *p_mi ); + +/** + * Set current audio stereo-mode. + * + * \param p_mi media player + * \param mode the audio stereo-mode, \see libvlc_audio_output_stereomode_t + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int libvlc_audio_set_stereomode( libvlc_media_player_t *p_mi, + libvlc_audio_output_stereomode_t mode ); + +/** + * Get current audio mix-mode. + * + * \param p_mi media player + * \return the audio mix-mode, \see libvlc_audio_output_mixmode_t + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API libvlc_audio_output_mixmode_t libvlc_audio_get_mixmode( libvlc_media_player_t *p_mi ); + +/** + * Set current audio mix-mode. + * + * By default (::libvlc_AudioMixMode_Unset), the audio output will keep its + * original channel configuration (play stereo as stereo, or 5.1 as 5.1). Yet, + * the OS and Audio API might refuse a channel configuration and asks VLC to + * adapt (Stereo played as 5.1 or vice-versa). + * + * This function allows to force a channel configuration, it will only work if + * the OS and Audio API accept this configuration (otherwise, it won't have any + * effects). Here are some examples: + * - Play multi-channels (5.1, 7.1...) as stereo (::libvlc_AudioMixMode_Stereo) + * - Play Stereo or 5.1 as 7.1 (::libvlc_AudioMixMode_7_1) + * - Play multi-channels as stereo with a binaural effect + * (::libvlc_AudioMixMode_Binaural). It might be selected automatically if the + * OS and Audio API can detect if a headphone is plugged. + * + * \param p_mi media player + * \param mode the audio mix-mode, \see libvlc_audio_output_mixmode_t + * \return 0 on success, -1 on error + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int libvlc_audio_set_mixmode( libvlc_media_player_t *p_mi, + libvlc_audio_output_mixmode_t mode ); + + +/** + * Get current audio delay. + * + * \param p_mi media player + * \return the audio delay (microseconds) + * \version LibVLC 1.1.1 or later + */ +LIBVLC_API int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi ); + +/** + * Set current audio delay. The audio delay will be reset to zero each time the media changes. + * + * \param p_mi media player + * \param i_delay the audio delay (microseconds) + * \return 0 on success, -1 on error + * \version LibVLC 1.1.1 or later + */ +LIBVLC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay ); + +/** + * Get the number of equalizer presets. + * + * \return number of presets + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API unsigned libvlc_audio_equalizer_get_preset_count( void ); + +/** + * Get the name of a particular equalizer preset. + * + * This name can be used, for example, to prepare a preset label or menu in a user + * interface. + * + * \param u_index index of the preset, counting from zero + * \return preset name, or NULL if there is no such preset + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API const char *libvlc_audio_equalizer_get_preset_name( unsigned u_index ); + +/** + * Get the number of distinct frequency bands for an equalizer. + * + * \return number of frequency bands + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API unsigned libvlc_audio_equalizer_get_band_count( void ); + +/** + * Get a particular equalizer band frequency. + * + * This value can be used, for example, to create a label for an equalizer band control + * in a user interface. + * + * \param u_index index of the band, counting from zero + * \return equalizer band frequency (Hz), or -1 if there is no such band + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API float libvlc_audio_equalizer_get_band_frequency( unsigned u_index ); + +/** + * Create a new default equalizer, with all frequency values zeroed. + * + * The new equalizer can subsequently be applied to a media player by invoking + * libvlc_media_player_set_equalizer(). + * + * The returned handle should be freed via libvlc_audio_equalizer_release() when + * it is no longer needed. + * + * \return opaque equalizer handle, or NULL on error + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API libvlc_equalizer_t *libvlc_audio_equalizer_new( void ); + +/** + * Create a new equalizer, with initial frequency values copied from an existing + * preset. + * + * The new equalizer can subsequently be applied to a media player by invoking + * libvlc_media_player_set_equalizer(). + * + * The returned handle should be freed via libvlc_audio_equalizer_release() when + * it is no longer needed. + * + * \param u_index index of the preset, counting from zero + * \return opaque equalizer handle, or NULL on error + * (it must be released with libvlc_audio_equalizer_release()) + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API libvlc_equalizer_t *libvlc_audio_equalizer_new_from_preset( unsigned u_index ); + +/** + * Release a previously created equalizer instance. + * + * The equalizer was previously created by using libvlc_audio_equalizer_new() or + * libvlc_audio_equalizer_new_from_preset(). + * + * It is safe to invoke this method with a NULL p_equalizer parameter for no effect. + * + * \param p_equalizer opaque equalizer handle, or NULL + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API void libvlc_audio_equalizer_release( libvlc_equalizer_t *p_equalizer ); + +/** + * Set a new pre-amplification value for an equalizer. + * + * The new equalizer settings are subsequently applied to a media player by invoking + * libvlc_media_player_set_equalizer(). + * + * The supplied amplification value will be clamped to the -20.0 to +20.0 range. + * + * \param p_equalizer valid equalizer handle, must not be NULL + * \param f_preamp preamp value (-20.0 to 20.0 Hz) + * \return zero on success, -1 on error + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API int libvlc_audio_equalizer_set_preamp( libvlc_equalizer_t *p_equalizer, float f_preamp ); + +/** + * Get the current pre-amplification value from an equalizer. + * + * \param p_equalizer valid equalizer handle, must not be NULL + * \return preamp value (Hz) + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API float libvlc_audio_equalizer_get_preamp( libvlc_equalizer_t *p_equalizer ); + +/** + * Set a new amplification value for a particular equalizer frequency band. + * + * The new equalizer settings are subsequently applied to a media player by invoking + * libvlc_media_player_set_equalizer(). + * + * The supplied amplification value will be clamped to the -20.0 to +20.0 range. + * + * \param p_equalizer valid equalizer handle, must not be NULL + * \param f_amp amplification value (-20.0 to 20.0 Hz) + * \param u_band index, counting from zero, of the frequency band to set + * \return zero on success, -1 on error + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API int libvlc_audio_equalizer_set_amp_at_index( libvlc_equalizer_t *p_equalizer, float f_amp, unsigned u_band ); + +/** + * Get the amplification value for a particular equalizer frequency band. + * + * \param p_equalizer valid equalizer handle, must not be NULL + * \param u_band index, counting from zero, of the frequency band to get + * \return amplification value (Hz); NaN if there is no such frequency band + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API float libvlc_audio_equalizer_get_amp_at_index( libvlc_equalizer_t *p_equalizer, unsigned u_band ); + +/** + * Apply new equalizer settings to a media player. + * + * The equalizer is first created by invoking libvlc_audio_equalizer_new() or + * libvlc_audio_equalizer_new_from_preset(). + * + * It is possible to apply new equalizer settings to a media player whether the media + * player is currently playing media or not. + * + * Invoking this method will immediately apply the new equalizer settings to the audio + * output of the currently playing media if there is any. + * + * If there is no currently playing media, the new equalizer settings will be applied + * later if and when new media is played. + * + * Equalizer settings will automatically be applied to subsequently played media. + * + * To disable the equalizer for a media player invoke this method passing NULL for the + * p_equalizer parameter. + * + * The media player does not keep a reference to the supplied equalizer so it is safe + * for an application to release the equalizer reference any time after this method + * returns. + * + * \param p_mi opaque media player handle + * \param p_equalizer opaque equalizer handle, or NULL to disable the equalizer for this media player + * \return zero on success, -1 on error + * \version LibVLC 2.2.0 or later + */ +LIBVLC_API int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equalizer_t *p_equalizer ); + +/** + * Media player roles. + * + * \version LibVLC 3.0.0 and later. + * + * See \ref libvlc_media_player_set_role() + */ +typedef enum libvlc_media_player_role { + libvlc_role_None = 0, /**< Don't use a media player role */ + libvlc_role_Music, /**< Music (or radio) playback */ + libvlc_role_Video, /**< Video playback */ + libvlc_role_Communication, /**< Speech, real-time communication */ + libvlc_role_Game, /**< Video game */ + libvlc_role_Notification, /**< User interaction feedback */ + libvlc_role_Animation, /**< Embedded animation (e.g. in web page) */ + libvlc_role_Production, /**< Audio editing/production */ + libvlc_role_Accessibility, /**< Accessibility */ + libvlc_role_Test /** Testing */ +#define libvlc_role_Last libvlc_role_Test +} libvlc_media_player_role_t; + +/** + * Gets the media role. + * + * \version LibVLC 3.0.0 and later. + * + * \param p_mi media player + * \return the media player role (\ref libvlc_media_player_role_t) + */ +LIBVLC_API int libvlc_media_player_get_role(libvlc_media_player_t *p_mi); + +/** + * Sets the media role. + * + * \param p_mi media player + * \param role the media player role (\ref libvlc_media_player_role_t) + * \return 0 on success, -1 on error + */ +LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *p_mi, + unsigned role); + +/** + * Start/stop recording + * + * \note The user should listen to the libvlc_MediaPlayerRecordChanged event, + * to monitor the recording state. + * + * \version LibVLC 4.0.0 and later. + * + * \param p_mi media player + * \param enable true to start recording, false to stop + * \param dir_path path of the recording directory or NULL (use default path), + * has only an effect when first enabling recording. + */ +LIBVLC_API void libvlc_media_player_record(libvlc_media_player_t *p_mi, + bool enable, const char *dir_path); + +/** @} audio */ + +/** \defgroup libvlc_media_player_watch_time LibVLC media player time watch API + * @{ + */ + +/** + * Media Player timer point + * + * \note ts and system_date values should not be used directly by the user. + * libvlc_media_player_time_point_interpolate() will read these values and + * return an interpolated ts. + * + * @see libvlc_media_player_watch_time_on_update + */ +typedef struct libvlc_media_player_time_point_t +{ + /** Position in the range [0.0f;1.0] */ + double position; + /** Rate of the player */ + double rate; + /** Valid time, in us >= 0 or -1 */ + int64_t ts_us; + /** Valid length, in us >= 1 or 0 */ + int64_t length_us; + /** + * System date, in us, of this record (always valid). + * Based on libvlc_clock(). This date can be in the future or in the past. + * The special value of INT64_MAX mean that the clock was paused when this + * point was updated. In that case, + * libvlc_media_player_time_point_interpolate() will return the current + * ts/pos of this point (there is nothing to interpolate). + * */ + int64_t system_date_us; +} libvlc_media_player_time_point_t; + +/** + * Callback prototype that notify when the player state or time changed. + * + * Get notified when the time is updated by the input or output source. The + * input source is the 'demux' or the 'access_demux'. The output source are + * audio and video outputs: an update is received each time a video frame is + * displayed or an audio sample is written. The delay between each updates may + * depend on the input and source type (it can be every 5ms, 30ms, 1s or + * 10s...). Users of this timer may need to update the position at a higher + * frequency from their own mainloop via + * libvlc_media_player_time_point_interpolate(). + * + * \warning It is forbidden to call any Media Player functions from here. + * + * \param value always valid, the time corresponding to the state + * \param data opaque pointer set by libvlc_media_player_watch_time() + */ +typedef void (*libvlc_media_player_watch_time_on_update)( + const libvlc_media_player_time_point_t *value, void *data); + +/** + * Callback prototype that notify when the timer is paused. + * + * This event is sent when the player is paused or stopping. The player + * user should stop its "interpolate" timer. + * + * \note libvlc_media_player_watch_time_on_update() can be called when paused + * for those 2 reasons: + * - playback is resumed (libvlc_media_player_time_point_t.system_date is valid) + * - a track, likely video (next-frame) is outputted when paused + * (libvlc_media_player_time_point_t.system_date = INT64_MAX) + * + * \warning It is forbidden to call any Media Player functions from here. + * + * \param system_date_us system date, in us, of this event, only valid (> 0) + * when paused. It can be used to interpolate the last updated point to this + * date in order to get the last paused ts/position. + * \param data opaque pointer set by libvlc_media_player_watch_time() + */ +typedef void (*libvlc_media_player_watch_time_on_paused)( + int64_t system_date_us, void *data); + +/** + * Callback prototype that notify when the player is seeking or finished + * seeking + * + * \warning It is forbidden to call any Media Player functions from here. + * + * \note It is not possible to receive points via on_update() while seeking. + * + * \param value point of the seek request or NULL when seeking is finished + * \param data opaque pointer set by libvlc_media_player_watch_time() + */ +typedef void (*libvlc_media_player_watch_time_on_seek)( + const libvlc_media_player_time_point_t *value, void *data); + +/** + * Watch for times updates + * + * \warning Only one watcher can be registered at a time. Calling this function + * a second time (if libvlc_media_player_unwatch_time() was not called + * in-between) will fail. + * + * \param p_mi the media player + * \param min_period_us corresponds to the minimum period, in us, between each + * updates, use it to avoid flood from too many source updates, set it to 0 to + * receive all updates. + * \param on_update callback to listen to update events (must not be NULL) + * \param on_paused callback to listen to paused events (can be NULL) + * \param on_seek callback to listen to seek events (can be NULL) + * \param cbs_data opaque pointer used by the callbacks + * \return 0 on success, -1 on error (allocation error, or if already watching) + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int +libvlc_media_player_watch_time(libvlc_media_player_t *p_mi, + int64_t min_period_us, + libvlc_media_player_watch_time_on_update on_update, + libvlc_media_player_watch_time_on_paused on_paused, + libvlc_media_player_watch_time_on_seek on_seek, + void *cbs_data); + +/** + * Unwatch time updates + * + * \param p_mi the media player + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void +libvlc_media_player_unwatch_time(libvlc_media_player_t *p_mi); + +/** + * Interpolate a timer value to now + + * \param point time update obtained via the + * libvlc_media_player_watch_time_on_update() callback + * \param system_now_us current system date, in us, returned by libvlc_clock() + * \param out_ts_us pointer where to set the interpolated ts, in us + * \param out_pos pointer where to set the interpolated position + * \return 0 in case of success, -1 if the interpolated ts is negative (could + * happen during the buffering step) + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int +libvlc_media_player_time_point_interpolate(const libvlc_media_player_time_point_t *point, + int64_t system_now_us, + int64_t *out_ts_us, double *out_pos); + +/** + * Get the date of the next interval + * + * Can be used to setup an UI timer in order to update some widgets at specific + * interval. A next_interval of VLC_TICK_FROM_SEC(1) can be used to update a + * time widget when the media reaches a new second. + * + * \note The media time doesn't necessarily correspond to the system time, that + * is why this function is needed and uses the rate of the current point. + * + * \param point time update obtained via the + * libvlc_media_player_watch_time_on_update() + * \param system_now_us same system date used by + * libvlc_media_player_time_point_interpolate() + * \param interpolated_ts_us ts returned by + * libvlc_media_player_time_point_interpolate() + * \param next_interval_us next interval, in us + * \return the absolute system date, in us, of the next interval, + * use libvlc_delay() to get a relative delay. + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API int64_t +libvlc_media_player_time_point_get_next_date(const libvlc_media_player_time_point_t *point, + int64_t system_now_us, + int64_t interpolated_ts_us, + int64_t next_interval_us); + +/** @} libvlc_media_player_watch_time */ + +/** \defgroup libvlc_media_player_concurrency LibVLC media player concurrency API + * @{ + */ + +/** + * Lock the media_player internal lock + + * The lock is recursive, so it's safe to use it multiple times from the same + * thread. You must call libvlc_media_player_unlock() the same number of times + * you called libvlc_media_player_lock(). + * + * Locking is not mandatory before calling a libvlc_media_player_t function + * since they will automatically hold the lock internally. + * + * This lock can be used to synchronise user variables that interact with the + * libvlc_media_player_t or can be used to call several functions together. + * + * \param mp media player object + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_media_player_lock( libvlc_media_player_t *mp ); + +/** + * Unlock the media_player internal lock + * + * \see libvlc_media_player_lock + * + * \param mp media player object locked using /ref libvlc_media_player_lock + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_media_player_unlock( libvlc_media_player_t *mp ); + +/** + * Wait for an event to be signalled + * + * \note this is equivalent to pthread_cond_wait() with the + * libvlc_media_player_t internal mutex and condition variable. This function + * may spuriously wake up even without libvlc_media_player_signal() being + * called. + * + * \warning this function must not be called from any libvlc callbacks and + * events. The lock should be held only one time before waiting. + * + * \param mp media player object locked using /ref libvlc_media_player_lock + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_media_player_wait( libvlc_media_player_t *mp ); + +/** + * Signal all threads waiting for a signalling event + * + * \note this is equivalent to pthread_cond_broadcast() with the + * libvlc_media_player_t internal condition variable. + * + * \param mp media player object locked using /ref libvlc_media_player_lock + * \version LibVLC 4.0.0 or later + */ +LIBVLC_API void libvlc_media_player_signal( libvlc_media_player_t *mp ); + +/** @} libvlc_media_player_concurrency */ + +/** @} media_player */ + +# ifdef __cplusplus +} +# endif + +#endif /* VLC_LIBVLC_MEDIA_PLAYER_H */ diff --git a/Libs/vlc/libvlc_media_track.h b/Libs/vlc/libvlc_media_track.h new file mode 100644 index 000000000..d44c12e5e --- /dev/null +++ b/Libs/vlc/libvlc_media_track.h @@ -0,0 +1,212 @@ +/***************************************************************************** + * libvlc_media_track.h: libvlc external API + ***************************************************************************** + * Copyright (C) 1998-2020 VLC authors and VideoLAN + * + * Authors: Clément Stenac + * Jean-Paul Saman + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_MEDIA_TRACK_H +#define VLC_LIBVLC_MEDIA_TRACK_H 1 + +# include "libvlc_video.h" + +# ifdef __cplusplus +extern "C" { +# else +# include +# endif + +/** \defgroup libvlc_media_track LibVLC media track + * \ingroup libvlc + * @ref libvlc_media_track_t is an abstract representation of a media track. + * @{ + * \file + * LibVLC media track + */ + +typedef enum libvlc_track_type_t +{ + libvlc_track_unknown = -1, + libvlc_track_audio = 0, + libvlc_track_video = 1, + libvlc_track_text = 2 +} libvlc_track_type_t; + +typedef struct libvlc_audio_track_t +{ + unsigned i_channels; + unsigned i_rate; +} libvlc_audio_track_t; + +/** + * Viewpoint + * + * \warning allocate using libvlc_video_new_viewpoint() + */ +typedef struct libvlc_video_viewpoint_t +{ + float f_yaw; /**< view point yaw in degrees ]-180;180] */ + float f_pitch; /**< view point pitch in degrees ]-90;90] */ + float f_roll; /**< view point roll in degrees ]-180;180] */ + float f_field_of_view; /**< field of view in degrees ]0;180[ (default 80.)*/ +} libvlc_video_viewpoint_t; + +typedef struct libvlc_video_track_t +{ + unsigned i_height; + unsigned i_width; + unsigned i_sar_num; + unsigned i_sar_den; + unsigned i_frame_rate_num; + unsigned i_frame_rate_den; + + libvlc_video_orient_t i_orientation; + libvlc_video_projection_t i_projection; + libvlc_video_viewpoint_t pose; /**< Initial view point */ + libvlc_video_multiview_t i_multiview; +} libvlc_video_track_t; + +typedef struct libvlc_subtitle_track_t +{ + char *psz_encoding; +} libvlc_subtitle_track_t; + +typedef struct libvlc_media_track_t +{ + /* Codec fourcc */ + uint32_t i_codec; + uint32_t i_original_fourcc; + int i_id; /* DEPRECATED: use psz_id */ + libvlc_track_type_t i_type; + + /* Codec specific */ + int i_profile; + int i_level; + + union { + libvlc_audio_track_t *audio; + libvlc_video_track_t *video; + libvlc_subtitle_track_t *subtitle; + }; + + unsigned int i_bitrate; + char *psz_language; + char *psz_description; + + /** String identifier of track, can be used to save the track preference + * from an other LibVLC run */ + const char *psz_id; + /** A string identifier is stable when it is certified to be the same + * across different playback instances for the same track. */ + bool id_stable; + /** Name of the track, only valid when the track is fetch from a + * media_player */ + char *psz_name; + /** true if the track is selected, only valid when the track is fetch from + * a media_player */ + bool selected; + +} libvlc_media_track_t; + +/** + * Opaque struct containing a list of tracks + */ +typedef struct libvlc_media_tracklist_t libvlc_media_tracklist_t; + +/** + * Get the number of tracks in a tracklist + * + * \version LibVLC 4.0.0 and later. + * + * \param list valid tracklist + * + * \return number of tracks, or 0 if the list is empty + */ +LIBVLC_API size_t +libvlc_media_tracklist_count( const libvlc_media_tracklist_t *list ); + +/** + * Get a track at a specific index + * + * \warning The behaviour is undefined if the index is not valid. + * + * \version LibVLC 4.0.0 and later. + * + * \param list valid tracklist + * \param index valid index in the range [0; count[ + * + * \return a valid track (can't be NULL if libvlc_media_tracklist_count() + * returned a valid count) + */ +LIBVLC_API libvlc_media_track_t * +libvlc_media_tracklist_at( libvlc_media_tracklist_t *list, size_t index ); + +/** + * Release a tracklist + * + * \version LibVLC 4.0.0 and later. + * + * \see libvlc_media_get_tracklist + * \see libvlc_media_player_get_tracklist + * + * \param list valid tracklist + */ +LIBVLC_API void +libvlc_media_tracklist_delete( libvlc_media_tracklist_t *list ); + + +/** + * Hold a single track reference + * + * \version LibVLC 4.0.0 and later. + * + * This function can be used to hold a track from a tracklist. In that case, + * the track can outlive its tracklist. + * + * \param track valid track + * \return the same track, need to be released with libvlc_media_track_release() + */ +LIBVLC_API libvlc_media_track_t * +libvlc_media_track_hold( libvlc_media_track_t *track ); + +/** + * Release a single track + * + * \version LibVLC 4.0.0 and later. + * + * \warning Tracks from a tracklist are released alongside the list with + * libvlc_media_tracklist_delete(). + * + * \note You only need to release tracks previously held with + * libvlc_media_track_hold() or returned by + * libvlc_media_player_get_selected_track() and + * libvlc_media_player_get_track_from_id() + * + * \param track valid track + */ +LIBVLC_API void +libvlc_media_track_release( libvlc_media_track_t *track ); +/** @}*/ + +# ifdef __cplusplus +} +# endif + +#endif /* VLC_LIBVLC_MEDIA_TRACK_H */ diff --git a/Libs/vlc/libvlc_picture.h b/Libs/vlc/libvlc_picture.h new file mode 100644 index 000000000..24e1d565d --- /dev/null +++ b/Libs/vlc/libvlc_picture.h @@ -0,0 +1,151 @@ +/***************************************************************************** + * libvlc_picture.h: libvlc external API + ***************************************************************************** + * Copyright (C) 2018 VLC authors and VideoLAN + * + * Authors: Hugo Beauzée-Luyssen + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_PICTURE_H +#define VLC_LIBVLC_PICTURE_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct libvlc_picture_t libvlc_picture_t; +typedef struct libvlc_picture_list_t libvlc_picture_list_t; + +typedef enum libvlc_picture_type_t +{ + libvlc_picture_Argb, + libvlc_picture_Png, + libvlc_picture_Jpg, + libvlc_picture_WebP, +} libvlc_picture_type_t; + +/** + * Increment the reference count of this picture. + * + * \see libvlc_picture_release() + * \param pic A picture object + * \return the same object + */ +LIBVLC_API libvlc_picture_t * +libvlc_picture_retain( libvlc_picture_t* pic ); + +/** + * Decrement the reference count of this picture. + * When the reference count reaches 0, the picture will be released. + * The picture must not be accessed after calling this function. + * + * \see libvlc_picture_retain + * \param pic A picture object + */ +LIBVLC_API void +libvlc_picture_release( libvlc_picture_t* pic ); + +/** + * Saves this picture to a file. The image format is the same as the one + * returned by \link libvlc_picture_type \endlink + * + * \param pic A picture object + * \param path The path to the generated file + * \return 0 in case of success, -1 otherwise + */ +LIBVLC_API int +libvlc_picture_save( const libvlc_picture_t* pic, const char* path ); + +/** + * Returns the image internal buffer, including potential padding. + * The libvlc_picture_t owns the returned buffer, which must not be modified nor + * freed. + * + * \param pic A picture object + * \param size A pointer to a size_t that will hold the size of the buffer [required] + * \return A pointer to the internal buffer. + */ +LIBVLC_API const unsigned char* +libvlc_picture_get_buffer( const libvlc_picture_t* pic, size_t *size ); + +/** + * Returns the picture type + * + * \param pic A picture object + * \see libvlc_picture_type_t + */ +LIBVLC_API libvlc_picture_type_t +libvlc_picture_type( const libvlc_picture_t* pic ); + +/** + * Returns the image stride, ie. the number of bytes per line. + * This can only be called on images of type libvlc_picture_Argb + * + * \param pic A picture object + */ +LIBVLC_API unsigned int +libvlc_picture_get_stride( const libvlc_picture_t* pic ); + +/** + * Returns the width of the image in pixels + * + * \param pic A picture object + */ +LIBVLC_API unsigned int +libvlc_picture_get_width( const libvlc_picture_t* pic ); + +/** + * Returns the height of the image in pixels + * + * \param pic A picture object + */ +LIBVLC_API unsigned int +libvlc_picture_get_height( const libvlc_picture_t* pic ); + +/** + * Returns the time at which this picture was generated, in milliseconds + * \param pic A picture object + */ +LIBVLC_API libvlc_time_t +libvlc_picture_get_time( const libvlc_picture_t* pic ); + +/** + * Returns the number of pictures in the list + */ +LIBVLC_API size_t libvlc_picture_list_count( const libvlc_picture_list_t* list ); + +/** + * Returns the picture at the provided index. + * + * If the index is out of bound, the result is undefined. + */ +LIBVLC_API libvlc_picture_t* libvlc_picture_list_at( const libvlc_picture_list_t* list, + size_t index ); + +/** + * Destroys a picture list and releases the pictures it contains + * \param list The list to destroy + * + * Calling this function with a NULL list is safe and will return immediately + */ +LIBVLC_API void libvlc_picture_list_destroy( libvlc_picture_list_t* list ); + +# ifdef __cplusplus +} +# endif + +#endif // VLC_LIBVLC_PICTURE_H diff --git a/Libs/vlc/libvlc_renderer_discoverer.h b/Libs/vlc/libvlc_renderer_discoverer.h new file mode 100644 index 000000000..e63a8c9c2 --- /dev/null +++ b/Libs/vlc/libvlc_renderer_discoverer.h @@ -0,0 +1,255 @@ +/***************************************************************************** + * libvlc_renderer_discoverer.h: libvlc external API + ***************************************************************************** + * Copyright © 2016 VLC authors and VideoLAN + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_LIBVLC_RENDERER_DISCOVERER_H +#define VLC_LIBVLC_RENDERER_DISCOVERER_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +/** + * @defgroup libvlc_renderer_discoverer LibVLC renderer discoverer + * @ingroup libvlc + * LibVLC renderer discoverer finds available renderers available on the local + * network + * @{ + * @file + * LibVLC renderer discoverer external API + */ + +typedef struct libvlc_renderer_discoverer_t libvlc_renderer_discoverer_t; + +/** + * Renderer discoverer description + * + * \see libvlc_renderer_discoverer_list_get() + */ +typedef struct libvlc_rd_description_t +{ + char *psz_name; + char *psz_longname; +} libvlc_rd_description_t; + +/** The renderer can render audio */ +#define LIBVLC_RENDERER_CAN_AUDIO 0x0001 +/** The renderer can render video */ +#define LIBVLC_RENDERER_CAN_VIDEO 0x0002 + +/** + * Renderer item + * + * This struct is passed by a @ref libvlc_event_t when a new renderer is added + * or deleted. + * + * An item is valid until the @ref libvlc_RendererDiscovererItemDeleted event + * is called with the same pointer. + * + * \see libvlc_renderer_discoverer_event_manager() + */ +typedef struct libvlc_renderer_item_t libvlc_renderer_item_t; + + +/** + * Hold a renderer item, i.e. creates a new reference + * + * This functions need to called from the libvlc_RendererDiscovererItemAdded + * callback if the libvlc user wants to use this item after. (for display or + * for passing it to the mediaplayer for example). + * + * \version LibVLC 3.0.0 or later + * + * \return the current item + */ +LIBVLC_API libvlc_renderer_item_t * +libvlc_renderer_item_hold(libvlc_renderer_item_t *p_item); + +/** + * Releases a renderer item, i.e. decrements its reference counter + * + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API void +libvlc_renderer_item_release(libvlc_renderer_item_t *p_item); + +/** + * Get the human readable name of a renderer item + * + * \version LibVLC 3.0.0 or later + * + * \return the name of the item (can't be NULL, must *not* be freed) + */ +LIBVLC_API const char * +libvlc_renderer_item_name(const libvlc_renderer_item_t *p_item); + +/** + * Get the type (not translated) of a renderer item. For now, the type can only + * be "chromecast" ("upnp", "airplay" may come later). + * + * \version LibVLC 3.0.0 or later + * + * \return the type of the item (can't be NULL, must *not* be freed) + */ +LIBVLC_API const char * +libvlc_renderer_item_type(const libvlc_renderer_item_t *p_item); + +/** + * Get the icon uri of a renderer item + * + * \version LibVLC 3.0.0 or later + * + * \return the uri of the item's icon (can be NULL, must *not* be freed) + */ +LIBVLC_API const char * +libvlc_renderer_item_icon_uri(const libvlc_renderer_item_t *p_item); + +/** + * Get the flags of a renderer item + * + * \see LIBVLC_RENDERER_CAN_AUDIO + * \see LIBVLC_RENDERER_CAN_VIDEO + * + * \version LibVLC 3.0.0 or later + * + * \return bitwise flag: capabilities of the renderer, see + */ +LIBVLC_API int +libvlc_renderer_item_flags(const libvlc_renderer_item_t *p_item); + +/** + * Create a renderer discoverer object by name + * + * After this object is created, you should attach to events in order to be + * notified of the discoverer events. + * + * You need to call libvlc_renderer_discoverer_start() in order to start the + * discovery. + * + * \see libvlc_renderer_discoverer_event_manager() + * \see libvlc_renderer_discoverer_start() + * + * \version LibVLC 3.0.0 or later + * + * \param p_inst libvlc instance + * \param psz_name service name; use libvlc_renderer_discoverer_list_get() to + * get a list of the discoverer names available in this libVLC instance + * \return media discover object or NULL in case of error + */ +LIBVLC_API libvlc_renderer_discoverer_t * +libvlc_renderer_discoverer_new( libvlc_instance_t *p_inst, + const char *psz_name ); + +/** + * Release a renderer discoverer object + * + * \version LibVLC 3.0.0 or later + * + * \param p_rd renderer discoverer object + */ +LIBVLC_API void +libvlc_renderer_discoverer_release( libvlc_renderer_discoverer_t *p_rd ); + +/** + * Start renderer discovery + * + * To stop it, call libvlc_renderer_discoverer_stop() or + * libvlc_renderer_discoverer_release() directly. + * + * \see libvlc_renderer_discoverer_stop() + * + * \version LibVLC 3.0.0 or later + * + * \param p_rd renderer discoverer object + * \return -1 in case of error, 0 otherwise + */ +LIBVLC_API int +libvlc_renderer_discoverer_start( libvlc_renderer_discoverer_t *p_rd ); + +/** + * Stop renderer discovery. + * + * \see libvlc_renderer_discoverer_start() + * + * \version LibVLC 3.0.0 or later + * + * \param p_rd renderer discoverer object + */ +LIBVLC_API void +libvlc_renderer_discoverer_stop( libvlc_renderer_discoverer_t *p_rd ); + +/** + * Get the event manager of the renderer discoverer + * + * The possible events to attach are @ref libvlc_RendererDiscovererItemAdded + * and @ref libvlc_RendererDiscovererItemDeleted. + * + * The @ref libvlc_renderer_item_t struct passed to event callbacks is owned by + * VLC, users should take care of holding/releasing this struct for their + * internal usage. + * + * \see libvlc_event_t.u.renderer_discoverer_item_added.item + * \see libvlc_event_t.u.renderer_discoverer_item_removed.item + * + * \version LibVLC 3.0.0 or later + * + * \return a valid event manager (can't fail) + */ +LIBVLC_API libvlc_event_manager_t * +libvlc_renderer_discoverer_event_manager( libvlc_renderer_discoverer_t *p_rd ); + +/** + * Get media discoverer services + * + * \see libvlc_renderer_list_release() + * + * \version LibVLC 3.0.0 and later + * + * \param p_inst libvlc instance + * \param ppp_services address to store an allocated array of renderer + * discoverer services (must be freed with libvlc_renderer_list_release() by + * the caller) [OUT] + * + * \return the number of media discoverer services (0 on error) + */ +LIBVLC_API size_t +libvlc_renderer_discoverer_list_get( libvlc_instance_t *p_inst, + libvlc_rd_description_t ***ppp_services ); + +/** + * Release an array of media discoverer services + * + * \see libvlc_renderer_discoverer_list_get() + * + * \version LibVLC 3.0.0 and later + * + * \param pp_services array to release + * \param i_count number of elements in the array + */ +LIBVLC_API void +libvlc_renderer_discoverer_list_release( libvlc_rd_description_t **pp_services, + size_t i_count ); + +/** @} */ + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/Libs/vlc/libvlc_version.h b/Libs/vlc/libvlc_version.h new file mode 100644 index 000000000..a7fd2cddf --- /dev/null +++ b/Libs/vlc/libvlc_version.h @@ -0,0 +1,79 @@ +/***************************************************************************** + * libvlc_version.h + ***************************************************************************** + * Copyright (C) 2010 Rémi Denis-Courmont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +/** + * \file + * This file defines version macros for LibVLC. + * Those macros are primilarly intended for conditional (pre)compilation. + * To get the run-time LibVLC version, use libvlc_get_version() instead + * (the run-time version may be more recent than build-time one, thanks to + * backward binary compatibility). + * + * \version This header file is available in LibVLC 1.1.4 and higher. + */ + +#ifndef LIBVLC_VERSION_H +# define LIBVLC_VERSION_H 1 + +/** LibVLC major version number */ +# define LIBVLC_VERSION_MAJOR (4) + +/** LibVLC minor version number */ +# define LIBVLC_VERSION_MINOR (0) + +/** LibVLC revision */ +# define LIBVLC_VERSION_REVISION (0) + +# define LIBVLC_VERSION_EXTRA (0) + +/** Makes a single integer from a LibVLC version numbers */ +# define LIBVLC_VERSION(maj,min,rev,extra) \ + ((maj << 24) | (min << 16) | (rev << 8) | (extra)) + +/** LibVLC full version as a single integer (for comparison) */ +# define LIBVLC_VERSION_INT \ + LIBVLC_VERSION(LIBVLC_VERSION_MAJOR, LIBVLC_VERSION_MINOR, \ + LIBVLC_VERSION_REVISION, LIBVLC_VERSION_EXTRA) + + +/** LibVLC ABI major version number, updated when incompatible changes are added */ +# define LIBVLC_ABI_VERSION_MAJOR (12) + +/** LibVLC ABI minor version number, updated when compatible changes are added */ +# define LIBVLC_ABI_VERSION_MINOR (0) + +/** LibVLC ABI micro version number, updated with new releases */ +# define LIBVLC_ABI_VERSION_MICRO (0) + +/** LibVLC full ABI version combining the major VLC version and the .so version: + * - A 0xFF000000 mask gives the VLC major version, + * - A 0x00FF0000 mask gives the LibVLC major ABI version, + * - A 0x0000FF00 mask gives the LibVLC minor ABI version, + * - A 0x000000FF mask gives the LibVLC ABI revision. + * + * LibVLC is considered compatible with your code if the VLC major and LibVLC + * major values are equal and the minor ABI version is equal or higher than the + * value you compiled with. + */ +# define LIBVLC_ABI_VERSION_INT \ + LIBVLC_VERSION(LIBVLC_VERSION_MAJOR, LIBVLC_ABI_VERSION_MAJOR, \ + LIBVLC_ABI_VERSION_MINOR, LIBVLC_ABI_VERSION_MICRO ) + +#endif diff --git a/Libs/vlc/libvlc_video.h b/Libs/vlc/libvlc_video.h new file mode 100644 index 000000000..afe2b45a7 --- /dev/null +++ b/Libs/vlc/libvlc_video.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * libvlc_video.h: libvlc video-related enumerations + ***************************************************************************** + * Copyright (C) 1998-2010 VLC authors and VideoLAN + * Copyright (C) 2023 Videolabs + * + * Authors: Filippo Carone + * Pierre d'Herbemont + * Alexandre Janniaux + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ +#ifndef VLC_LIBVLC_VIDEO_H +#define VLC_LIBVLC_VIDEO_H 1 + +# ifdef __cplusplus +extern "C"{ +# endif + +typedef enum libvlc_video_orient_t +{ + libvlc_video_orient_top_left, /**< Normal. Top line represents top, left column left. */ + libvlc_video_orient_top_right, /**< Flipped horizontally */ + libvlc_video_orient_bottom_left, /**< Flipped vertically */ + libvlc_video_orient_bottom_right, /**< Rotated 180 degrees */ + libvlc_video_orient_left_top, /**< Transposed */ + libvlc_video_orient_left_bottom, /**< Rotated 90 degrees clockwise (or 270 anti-clockwise) */ + libvlc_video_orient_right_top, /**< Rotated 90 degrees anti-clockwise */ + libvlc_video_orient_right_bottom /**< Anti-transposed */ +} libvlc_video_orient_t; + +typedef enum libvlc_video_projection_t +{ + libvlc_video_projection_rectangular, + libvlc_video_projection_equirectangular, /**< 360 spherical */ + + libvlc_video_projection_cubemap_layout_standard = 0x100, +} libvlc_video_projection_t; + +typedef enum libvlc_video_multiview_t +{ + libvlc_video_multiview_2d, /**< No stereoscopy: 2D picture. */ + libvlc_video_multiview_stereo_sbs, /**< Side-by-side */ + libvlc_video_multiview_stereo_tb, /**< Top-bottom */ + libvlc_video_multiview_stereo_row, /**< Row sequential */ + libvlc_video_multiview_stereo_col, /**< Column sequential */ + libvlc_video_multiview_stereo_frame, /**< Frame sequential */ + libvlc_video_multiview_stereo_checkerboard, /**< Checkerboard pattern */ +} libvlc_video_multiview_t; + +# ifdef __cplusplus +} // extern "C" +# endif + +#endif diff --git a/Libs/vlc/vlc.h b/Libs/vlc/vlc.h new file mode 100644 index 000000000..1413d9b1b --- /dev/null +++ b/Libs/vlc/vlc.h @@ -0,0 +1,55 @@ +/***************************************************************************** + * vlc.h: global header for libvlc + ***************************************************************************** + * Copyright (C) 1998-2008 VLC authors and VideoLAN + * + * Authors: Vincent Seguin + * Samuel Hocevar + * Gildas Bazin + * Derk-Jan Hartman + * Pierre d'Herbemont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_VLC_H +#define VLC_VLC_H 1 + +/** + * \file + * This file defines libvlc new external API + */ + +# ifdef __cplusplus +extern "C" { +# endif + +#include "libvlc.h" +#include "libvlc_renderer_discoverer.h" +#include "libvlc_picture.h" +#include "libvlc_media.h" +#include "libvlc_media_player.h" +#include "libvlc_media_list.h" +#include "libvlc_media_list_player.h" +#include "libvlc_media_discoverer.h" +#include "libvlc_events.h" +#include "libvlc_dialog.h" +#include "libvlc_version.h" + +# ifdef __cplusplus +} +# endif + +#endif /* _VLC_VLC_H */ diff --git a/Libs/vlc/x64/libvlc.dll b/Libs/vlc/x64/libvlc.dll new file mode 100644 index 000000000..f66e2b5a4 Binary files /dev/null and b/Libs/vlc/x64/libvlc.dll differ diff --git a/Libs/vlc/x64/libvlc.lib b/Libs/vlc/x64/libvlc.lib new file mode 100644 index 000000000..82b19b1a3 Binary files /dev/null and b/Libs/vlc/x64/libvlc.lib differ diff --git a/Libs/vlc/x64/libvlccore.dll b/Libs/vlc/x64/libvlccore.dll new file mode 100644 index 000000000..908e7993a Binary files /dev/null and b/Libs/vlc/x64/libvlccore.dll differ diff --git a/Libs/vlc/x64/libvlccore.lib b/Libs/vlc/x64/libvlccore.lib new file mode 100644 index 000000000..b55ef51a8 Binary files /dev/null and b/Libs/vlc/x64/libvlccore.lib differ diff --git a/Libs/vlc/x86/libvlc.dll b/Libs/vlc/x86/libvlc.dll new file mode 100644 index 000000000..64da662b0 Binary files /dev/null and b/Libs/vlc/x86/libvlc.dll differ diff --git a/Libs/vlc/x86/libvlc.lib b/Libs/vlc/x86/libvlc.lib new file mode 100644 index 000000000..c401996fe Binary files /dev/null and b/Libs/vlc/x86/libvlc.lib differ diff --git a/Libs/vlc/x86/libvlccore.dll b/Libs/vlc/x86/libvlccore.dll new file mode 100644 index 000000000..c887a6732 Binary files /dev/null and b/Libs/vlc/x86/libvlccore.dll differ diff --git a/Libs/vlc/x86/libvlccore.lib b/Libs/vlc/x86/libvlccore.lib new file mode 100644 index 000000000..768877b13 Binary files /dev/null and b/Libs/vlc/x86/libvlccore.lib differ diff --git a/README.md b/README.md index 5ad28cfa3..cbc224c3e 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,42 @@ -# TombEngine +# Tomb Engine ![Logo](https://github.com/MontyTRC89/TombEngine/blob/7c50d26ca898c74978336d41e16ce3ce0c8ecacd/TEN%20logo.png) -TombEngine (TEN) is an open-source, custom level engine which aims to abolish limits and fix bugs of the classic Tomb Raider games, introduce new features while refining old ones, and provide user-friendly level creation process. Current support includes: -- Lua (as the native scripting language) -- Many objects from the original series (1-5) -- Support for high framerate, antialiasing, mipmapping and SSAO -- Full diagonal geometry support -- Uncapped map size +*Tomb Engine* (*TEN*) is an open-source custom level engine which aims to abolish limits and fix bugs of the classic Tomb Raider games. It aims to introduce new features, refine old ones, and provide a user-friendly level creation process. Current support includes: +- *Lua* as the native scripting language. +- Many objects from the original series (1-5). +- Support for high framerate, antialiasing, mipmapping, and SSAO. +- Full diagonal geometry support. +- Uncapped map size. - A streamlined player control scheme. -If you would like to participate in TEN discussion with other TEN devs whether it is contributing, bugs or general discussion, then join this discord server: https://discord.gg/h5tUYFmres +*Tomb Engine* is used in conjunction with *Tomb Editor*. The repository can be found [here](https://github.com/MontyTRC89/Tomb-Editor). -Tomb Engine should be used in conjuction with Tomb Editor. Tomb Editor is also open source written in C#, you can find the repository here: https://github.com/MontyTRC89/Tomb-Editor - -# Compiling TombEngine -To compile TEN, ensure you have installed: -- Microsoft Visual Studio -- Tomb Editor (if you would like to create and test levels) +# Compiling *Tomb Engine* +To compile *TEN*, ensure you have installed: +- *Microsoft Visual Studio* +- *Tomb Editor* (for level creation and testing) Steps: -1) Clone the repository to your GitHub Desktop -2) Open TombEngine.sln -4) Compile the solution -5) Once compiled, create a separate folder to serve as your main TEN directory (or create test TEN project using TombIDE) -6) Copy everything inside the Build folder to the main TEN directory -7) Ensure you have the necessary level data and texture files as well -8) In the case Windows warns about missing DLLs, (bass.dll, etc.) copy the missing DLL files found inside the Libs folder to your main TEN directory. +1) Clone the repository to your GitHub Desktop. +2) Open `TombEngine.sln`. +4) Compile the solution. +5) Once compiled, create a separate folder to serve as your main *TEN* directory (or create a test *TEN* project using *TombIDE*) +6) Copy everything inside the `Build` folder to the main *TEN* directory. +7) Ensure you have the necessary level data and texture files. +8) In case Windows warns about missing DLLs (bass.dll, etc.), copy the missing DLL files found inside the `Libs` folder to your main `TEN` directory. -Visual Studio may also warn about NuGet packages. To fix: -1) Delete the Packages folder -2) Go back to Microsoft Visual Studio -3) Right-click on the TombEngine solution in the Solution Explorer tab and select "Restore NuGet Packages" -4) If it doesn't help, manually install `directxtk_desktop_2019` and `Microsoft.XAudio2.Redist` packages via NuGet Package Manager +*Visual Studio* may warn about NuGet packages. To fix: +1) Delete the `Packages` folder. +2) Go back to *Microsoft Visual Studio*. +3) Right-click on the *TEN* solution in the *Solution Explorer* tab and select "Restore NuGet Packages". +4) If it doesn't help, manually install `directxtk_desktop_2019` and `Microsoft.XAudio2.Redist` packages via NuGet Package Manager. -Once done, you should be able to build a level with TombEditor and run it in TEN. +Once done, you should be able to build a level with *Tomb Editor* and run it in *TEN*. + +# Contributions +Contributions are welcome. If you would like to participate in development to any degree, whether that be through suggestions, bug reports, or code, join our [Discord server](https://discord.gg/h5tUYFmres). # Disclaimer -This is a community project which is not affiliated with Core Design, Eidos Interactive, or Embracer Group AB. Tomb Raider is a registered trademark of Embracer Group AB. TombEngine is not be sold. The code is open-source to encourage contributions and to be used for study purposes. We are not responsible for illegal uses of this source code. This source code is released as-is and continues to be maintained by non-paid contributors in their free time. +Tomb Engine uses modified MIT license for non-commercial use only. For more information, see [license](LICENSE). Tomb Engine is unaffiliated with Core Design, Eidos Interactive, or Embracer Group AB. *Tomb Raider* is a registered trademark of Embracer Group AB. Tomb Engine source code is open to encourage contributions and for study purposes. Tomb Engine team is not responsible for illegal use of this source code alone or in combination with third-party assets or components. This source code is released as-is and continues to be maintained by non-paid contributors in their free time. diff --git a/Scripts/Engine/CustomBar.lua b/Scripts/Engine/CustomBar.lua new file mode 100644 index 000000000..a0404199f --- /dev/null +++ b/Scripts/Engine/CustomBar.lua @@ -0,0 +1,951 @@ +------ +-- This module provides functions for creating and managing custom progress bars. It stores bar definitions and configurations in `LevelVars.Engine.CustomBars`, enabling seamless state management. +-- Each bar is independently controlled through its associated functions. +-- +-- Example usage: +-- +-- local CustomBar = require("Engine.CustomBar") +-- +-- -- Create a table with all the bar properties +-- local barData = { +-- barName = "water", +-- startValue = 0, +-- maxValue = 1000, +-- objectIdBg = TEN.Objects.ObjID.CUSTOM_BAR_GRAPHIC, +-- spriteIdBg = 0, +-- colorBg = TEN.Color(255,255,255), +-- posBg = TEN.Vec2(20, 20), +-- rotBg = 0, +-- scaleBg = TEN.Vec2(19.05, 19.1), +-- alignModeBg = TEN.View.AlignMode.CENTER_LEFT, +-- scaleModeBg = TEN.View.ScaleMode.FIT, +-- blendModeBg = TEN.Effects.BlendID.ALPHABLEND, +-- objectIdBar = TEN.Objects.ObjID.CUSTOM_BAR_GRAPHIC, +-- spriteIdBar = 1, +-- colorBar = TEN.Color(255,0,0), +-- posBar = TEN.Vec2(20.15, 20), +-- rot = 0, +-- scaleBar = TEN.Vec2(18.7, 18.48), +-- alignMode = TEN.View.AlignMode.CENTER_LEFT, +-- scaleMode = TEN.View.ScaleMode.FIT, +-- blendMode = TEN.Effects.BlendID.ALPHABLEND, +-- text = "Water Bar", +-- textPos = TEN.Vec2(20, 15), +-- textOptions = {TEN.Strings.DisplayStringOption.SHADOW,TEN.Strings.DisplayStringOption.CENTER}, +-- textScale = 1, +-- textColor = TEN.Color(255,0,0), +-- hideText = false, +-- alphaBlendSpeed = 50, +-- blink = false, +-- blinkLimit = 0.25 +-- } +-- +-- -- This function creates the bar. +-- CustomBar.Create(barData) +-- +-- -- This method gets the bar with name "water" and stores it in variable bar. +-- local bar = CustomBar.Get("water") +-- -- This method displays the bar +-- bar:SetVisibility(true) +-- -- This method sets the bar value to 1000 over 5 seconds. +-- bar:SetBarValue(1000,5) +-- +-- @luautil CustomBar + + +local CustomBar = {} + +CustomBar.__index = CustomBar + +LevelFuncs.Engine.CustomBar = {} +LevelVars.Engine.CustomBars = {bars = {}, enemiesHpBar = {status = nil}} + +--- +-- Creates a custom progress bar with extensive configuration options. +-- @tparam table barData The table that contains all the bar data. Refer to table setup for barData. +-- +-- @treturn CustomBar The custombar in its hidden state +-- +CustomBar.Create = function (barData) + + local dataName = barData.barName .. "_bar_data" + local self = {name = dataName} + + if LevelVars.Engine.CustomBars.bars[dataName] then + print("Warning: a customBar with name " .. dataName .. " already exists; overwriting it with a new one...") + end +--- +-- Table setup for creating custom bar. +-- @table barData +-- @tfield string barName Unique identifier for the bar. +-- @tfield float startValue Initial value of the bar. +-- @tfield float maxValue Maximum value of the bar. +-- @tfield Objects.ObjID objectIdBg Object ID for the bar's background sprite. +-- @tfield number spriteIdBg SpriteID from the specified object for the bar's background. +-- @tfield Color colorBg Color of bar's background. +-- @tfield Vec2 posBg X,Y position of the bar's background in screen percent (0-100). +-- @tfield float rotBg rotation of the bar's background. sprite (0-360). +-- @tfield Vec2 scaleBg X,Y Scaling factor for the bar's background sprite. +-- @tfield View.AlignMode alignModeBg Alignment for the bar's background. +-- @tfield View.ScaleMode scaleModeBg Scaling for the bar's background. +-- @tfield Effects.BlendID blendModeBg Blending modes for the bar's background. +-- @tfield Objects.ObjID objectIdBar Object ID for the bar sprite. +-- @tfield number spriteIdBar SpriteID from the specified object for the bar. +-- @tfield Color colorBar Color of the bar. +-- @tfield Vec2 posBar X,Y position of the bar in screen percent (0-100). +-- @tfield float rot rotation of the bar's sprite (0-360). +-- @tfield Vec2 scaleBar X,Y Scaling factor for the bar's sprite. +-- @tfield View.AlignMode alignMode Alignment for the bar. +-- @tfield View.ScaleMode scaleMode Scaling for the bar. +-- @tfield Effects.BlendID blendMode Blending modes for the bar. +-- @tfield string text Text to display on the bar. +-- @tfield Vec2 textPos X,Y position of the text. +-- @tfield Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +-- @tfield number textScale Scale factor for the text. +-- @tfield Color textColor Color of the text. +-- @tfield bool hideText Whether to hide the text. +-- @tfield number alphaBlendSpeed Speed of alpha blending for bar visibility (0-255). +-- @tfield bool blink Whether the bar blinks. +-- @tfield number blinkLimit % Limit below which bar starts blinking (0-1). + + LevelVars.Engine.CustomBars.bars[dataName] = {} + LevelVars.Engine.CustomBars.bars[dataName].name = dataName + LevelVars.Engine.CustomBars.bars[dataName].fixedInterval = 1/30 + LevelVars.Engine.CustomBars.bars[dataName].progress = barData.startValue / barData.maxValue -- Set initial progress from start value + LevelVars.Engine.CustomBars.bars[dataName].objectIdBg = barData.objectIdBg + LevelVars.Engine.CustomBars.bars[dataName].spriteIdBg = barData.spriteIdBg + LevelVars.Engine.CustomBars.bars[dataName].colorBg = barData.colorBg + LevelVars.Engine.CustomBars.bars[dataName].posBg = barData.posBg + LevelVars.Engine.CustomBars.bars[dataName].scaleBg = barData.scaleBg + LevelVars.Engine.CustomBars.bars[dataName].rotBg = barData.rotBg + LevelVars.Engine.CustomBars.bars[dataName].alignModeBg = barData.alignModeBg + LevelVars.Engine.CustomBars.bars[dataName].scaleModeBg = barData.scaleModeBg + LevelVars.Engine.CustomBars.bars[dataName].blendModeBg = barData.blendModeBg + LevelVars.Engine.CustomBars.bars[dataName].objectIdBar = barData.objectIdBar + LevelVars.Engine.CustomBars.bars[dataName].spriteIdBar = barData.spriteIdBar + LevelVars.Engine.CustomBars.bars[dataName].colorBar = barData.colorBar + LevelVars.Engine.CustomBars.bars[dataName].posBar = barData.posBar + LevelVars.Engine.CustomBars.bars[dataName].scaleBar = barData.scaleBar + LevelVars.Engine.CustomBars.bars[dataName].rot = barData.rot + LevelVars.Engine.CustomBars.bars[dataName].alignMode = barData.alignMode + LevelVars.Engine.CustomBars.bars[dataName].scaleMode = barData.scaleMode + LevelVars.Engine.CustomBars.bars[dataName].blendMode = barData.blendMode + LevelVars.Engine.CustomBars.bars[dataName].oldValue = barData.startValue -- stores the current bar value + LevelVars.Engine.CustomBars.bars[dataName].targetValue = barData.startValue -- target value to reach + LevelVars.Engine.CustomBars.bars[dataName].maxValue = barData.maxValue + LevelVars.Engine.CustomBars.bars[dataName].text = barData.text + LevelVars.Engine.CustomBars.bars[dataName].textPos = barData.textPos + LevelVars.Engine.CustomBars.bars[dataName].textOptions = barData.textOptions + LevelVars.Engine.CustomBars.bars[dataName].textScale = barData.textScale + LevelVars.Engine.CustomBars.bars[dataName].textColor = barData.textColor + LevelVars.Engine.CustomBars.bars[dataName].hideText = barData.hideText -- required to hide bar text + LevelVars.Engine.CustomBars.bars[dataName].visible = false + LevelVars.Engine.CustomBars.bars[dataName].currentAlpha = 0 + LevelVars.Engine.CustomBars.bars[dataName].targetAlpha = 0 + LevelVars.Engine.CustomBars.bars[dataName].alphaBlendSpeed = barData.alphaBlendSpeed + LevelVars.Engine.CustomBars.bars[dataName].blink = barData.blink + LevelVars.Engine.CustomBars.bars[dataName].blinkLimit = barData.blinkLimit + LevelVars.Engine.CustomBars.bars[dataName].blinkSpeed = 8 + LevelVars.Engine.CustomBars.bars[dataName].showBar = nil --required to hide bar when enemy is not targeted + LevelVars.Engine.CustomBars.bars[dataName].object = nil + LevelVars.Engine.CustomBars.bars[dataName].getActionType = nil + LevelVars.Engine.CustomBars.bars[dataName].currentTimer = 0 + return setmetatable(self, CustomBar) +end + +--- +-- Creates a bar tied to Players's attributes (Health, Air, Stamina). +-- @tparam table playerBarData The table that contains all the player bar data. Refer to table setup for playerBarData. +-- @treturn CustomBar Player attribute bar. + +CustomBar.CreatePlayerBar = function (playerBarData) + + local barName = "Player" .. playerBarData.getActionType + local dataName = barName .. "_bar_data" + + if playerBarData.getActionType >= 1 and playerBarData.getActionType <= 3 then + local startValue = playerBarData.getActionType == 1 and Lara:GetHP() or + (playerBarData.getActionType == 2 and Lara:GetAir() or + (playerBarData.getActionType == 3 and Lara:GetStamina())) + local maxValue = playerBarData.getActionType == 1 and 1000 or (playerBarData.getActionType == 2 and 1800 or (playerBarData.getActionType == 3 and 120)) + +--- +-- Table setup for creating custom player attribute bar. +-- @table playerBarData +-- @tfield number getActionType Determines the bar type: 1: Health, 2: Air, 3: Stamina. +-- @tfield Objects.ObjID objectIdBg Object ID for the bar's background sprite. +-- @tfield number spriteIdBg SpriteID from the specified object for the bar's background. +-- @tfield Color colorBg Color of bar's background. +-- @tfield Vec2 posBg X,Y position of the bar's background in screen percent (0-100). +-- @tfield number rotBg rotation of the bar's background. sprite (0-360). +-- @tfield Vec2 scaleBg X,Y Scaling factor for the bar's background sprite. +-- @tfield View.AlignMode alignModeBg Alignment for the bar's background. +-- @tfield View.ScaleMode scaleModeBg Scaling for the bar's background. +-- @tfield Effects.BlendID blendModeBg Blending modes for the bar's background. +-- @tfield Objects.ObjID objectIdBar Object ID for the bar sprite. +-- @tfield number spriteIdBar SpriteID from the specified object for the bar. +-- @tfield Color colorBar Color of the bar. +-- @tfield Vec2 posBar X,Y position of the bar in screen percent (0-100). +-- @tfield number rot rotation of the bar's sprite (0-360). +-- @tfield Vec2 scaleBar X,Y Scaling factor for the bar's sprite. +-- @tfield View.AlignMode alignMode Alignment for the bar. +-- @tfield View.ScaleMode scaleMode Scaling for the bar. +-- @tfield Effects.BlendID blendMode Blending modes for the bar. +-- @tfield number alphaBlendSpeed Speed of alpha blending for bar visibility (0-255). +-- @tfield bool showBar Option to always show the bar. If set to false, the bars will automatically hide when they stop updating. +-- @tfield bool blink Whether the bar blinks. +-- @tfield number blinkLimit % Limit below which bar starts blinking (0-1). + + local playerBar = { + barName = barName, + startValue = startValue, + maxValue = maxValue, + objectIdBg = playerBarData.objectIdBg, + spriteIdBg = playerBarData.spriteIdBg, + colorBg = playerBarData.colorBg, + posBg = playerBarData.posBg, + rotBg = playerBarData.rotBg, + scaleBg = playerBarData.scaleBg, + alignModeBg = playerBarData.alignModeBg, + scaleModeBg = playerBarData.scaleModeBg, + blendModeBg = playerBarData.blendModeBg, + objectIdBar = playerBarData.objectIdBar, + spriteIdBar = playerBarData.spriteIdBar, + colorBar = playerBarData.colorBar, + posBar = playerBarData.posBar, + rot = playerBarData.rot, + scaleBar = playerBarData.scaleBar, + alignMode = playerBarData.alignMode, + scaleMode = playerBarData.scaleMode, + blendMode = playerBarData.blendMode, + text = "BLANK", + textPos = TEN.Vec2(0,0), + textOptions = {}, + textScale = 0, + textColor = TEN.Color(0,0,0), + hideText = true, + alphaBlendSpeed = playerBarData.alphaBlendSpeed, + blink = playerBarData.blink, + blinkLimit = playerBarData.blinkLimit, + } + + CustomBar.Create(playerBar) + + end + + LevelVars.Engine.CustomBars.bars[dataName].getActionType = playerBarData.getActionType + LevelVars.Engine.CustomBars.bars[dataName].showBar = playerBarData.showBar + LevelVars.Engine.CustomBars.bars[dataName].visible = true + LevelVars.Engine.CustomBars.bars[dataName].targetAlpha = 255 + +end + +--- +-- Creates a custom health bar for a specific enemy (like a boss). Ensure this function is called before Lara aims at the enemy if using generic enemy HP bars as well. +-- Also be sure to call this function after increasing the HP of the enemy via LUA. +-- @tparam table enemyBarData The table that contains all the enemy bar data. Refer to table setup for enemyBarData. +-- @treturn CustomBar Enemy health bar. +CustomBar.CreateEnemyHpBar = function (enemyBarData) + + local dataName = enemyBarData.barName .. "_bar_data" + local enemyHP = TEN.Objects.GetMoveableByName(enemyBarData.object):GetHP() + +--- +-- Table setup for creating a specific enemy health bar. +-- @table enemyBarData +-- @tfield string barName Unique identifier for the bar. +-- @tfield Objects.ObjID objectIdBg Object ID for the bar's background sprite. +-- @tfield number spriteIdBg SpriteID from the specified object for the bar's background. +-- @tfield Color colorBg Color of bar's background. +-- @tfield Vec2 posBg X,Y position of the bar's background in screen percent (0-100). +-- @tfield number rotBg rotation of the bar's background. sprite (0-360). +-- @tfield Vec2 scaleBg X,Y Scaling factor for the bar's background sprite. +-- @tfield View.AlignMode alignModeBg Alignment for the bar's background. +-- @tfield View.ScaleMode scaleModeBg Scaling for the bar's background. +-- @tfield Effects.BlendID blendModeBg Blending modes for the bar's background. +-- @tfield Objects.ObjID objectIdBar Object ID for the bar sprite. +-- @tfield number spriteIdBar SpriteID from the specified object for the bar. +-- @tfield Color colorBar Color of the bar. +-- @tfield Vec2 posBar X,Y position of the bar in screen percent (0-100). +-- @tfield number rot rotation of the bar's sprite (0-360). +-- @tfield Vec2 scaleBar X,Y Scaling factor for the bar's sprite. +-- @tfield View.AlignMode alignMode Alignment for the bar. +-- @tfield View.ScaleMode scaleMode Scaling for the bar. +-- @tfield Effects.BlendID blendMode Blending modes for the bar. +-- @tfield string text Text to display for the enemy. +-- @tfield Vec2 textPos X,Y position of the text. +-- @tfield Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +-- @tfield number textScale Scale factor for the text. +-- @tfield Color textColor Color of the text. +-- @tfield bool hideText Whether to hide the text. +-- @tfield number alphaBlendSpeed Speed of alpha blending for bar visibility (0-255). +-- @tfield string object Enemy name set in Editor for which to create HP for. +-- @tfield bool showBar Option to always show the bar whether the enemy is current target or not. Useful for boss health bars. +-- @tfield bool blink Whether the bar blinks. +-- @tfield number blinkLimit %Limit below which bar starts blinking (0-1). + + local enemyBar = { + barName = enemyBarData.barName, + startValue = enemyHP, + maxValue = enemyHP, + objectIdBg = enemyBarData.objectIdBg, + spriteIdBg = enemyBarData.spriteIdBg, + colorBg = enemyBarData.colorBg, + posBg = enemyBarData.posBg, + rotBg = enemyBarData.rotBg, + scaleBg = enemyBarData.scaleBg, + alignModeBg = enemyBarData.alignModeBg, + scaleModeBg = enemyBarData.scaleModeBg, + blendModeBg = enemyBarData.blendModeBg, + objectIdBar = enemyBarData.objectIdBar, + spriteIdBar = enemyBarData.spriteIdBar, + colorBar = enemyBarData.colorBar, + posBar = enemyBarData.posBar, + rot = enemyBarData.rot, + scaleBar = enemyBarData.scaleBar, + alignMode = enemyBarData.alignMode, + scaleMode = enemyBarData.scaleMode, + blendMode = enemyBarData.blendMode, + text = enemyBarData.text, + textPos = enemyBarData.textPos, + textOptions = enemyBarData.textOptions, + textScale = enemyBarData.textScale, + textColor = enemyBarData.textColor, + hideText = enemyBarData.hideText, + alphaBlendSpeed = enemyBarData.alphaBlendSpeed, + blink = enemyBarData.blink, + blinkLimit = enemyBarData.blinkLimit + } + + CustomBar.Create(enemyBar) + + LevelVars.Engine.CustomBars.bars[dataName].showBar = enemyBarData.showBar + LevelVars.Engine.CustomBars.bars[dataName].object = enemyBarData.object + LevelVars.Engine.CustomBars.bars[dataName].getActionType = 0 + LevelVars.Engine.CustomBars.bars[dataName].visible = true + LevelVars.Engine.CustomBars.bars[dataName].fixedInterval = 1/3 + LevelVars.Engine.CustomBars.bars[dataName].currentAlpha = 0 + LevelVars.Engine.CustomBars.bars[dataName].targetAlpha = 255 + +end + +--- +-- Creates health bars for all enemies. A new bar is generated whenever Lara targets an enemy. If the "hide text" option is disabled, the enemy's name (as set in the editor) is displayed. +-- Multiple enemies can share the same name by appending _number to the name in the editor. If adjusting an enemy's max HP, ensure this is done before Lara targets the enemy. +-- To create health bars for specific enemies, use CustomBar.CreateEnemyHpBar, ensuring the bar is created prior to targeting. +-- @tparam table enemiesBarData The table that contains all the enemies bar data. Refer to table setup for enemiesBarData. +-- @treturn CustomBar Enemy health bars. + +CustomBar.SetEnemiesHpGenericBar = function (enemiesBarData) + + if LevelVars.Engine.CustomBars.enemiesHpBar.objectIdBg then + print("Warning: Overwriting enemy HP bar definitions") + end + +--- +-- Table setup for creating health bars for all enemies. +-- @table enemiesBarData +-- @tfield Objects.ObjID objectIdBg Object ID for the bar's background sprite. +-- @tfield number spriteIdBg SpriteID from the specified object for the bar's background. +-- @tfield Color colorBg Color of bar's background. +-- @tfield Vec2 posBg X,Y position of the bar's background in screen percent (0-100). +-- @tfield number rotBg rotation of the bar's background. sprite (0-360). +-- @tfield Vec2 scaleBg X,Y Scaling factor for the bar's background sprite. +-- @tfield View.AlignMode alignModeBg Alignment for the bar's background. +-- @tfield View.ScaleMode scaleModeBg Scaling for the bar's background. +-- @tfield Effects.BlendID blendModeBg Blending modes for the bar's background. +-- @tfield Objects.ObjID objectIdBar Object ID for the bar sprite. +-- @tfield number spriteIdBar SpriteID from the specified object for the bar. +-- @tfield Color colorBar Color of the bar. +-- @tfield Vec2 posBar X,Y position of the bar in screen percent (0-100). +-- @tfield number rot rotation of the bar's sprite (0-360). +-- @tfield Vec2 scaleBar X,Y Scaling factor for the bar's sprite. +-- @tfield View.AlignMode alignMode Alignment for the bar. +-- @tfield View.ScaleMode scaleMode Scaling for the bar. +-- @tfield Effects.BlendID blendMode Blending modes for the bar. +-- @tfield number textPos X position of the text. +-- @tfield Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT +-- @tfield number textScale Scale factor for the text. +-- @tfield Color textColor Color of the text. +-- @tfield bool hideText Whether to hide the enemy name text. +-- @tfield number alphaBlendSpeed Speed of alpha blending for bar visibility (0-255). +-- @tfield bool blink Whether the bar blinks. +-- @tfield number blinkLimit %Limit below which bar starts blinking (0-1). + + LevelVars.Engine.CustomBars.enemiesHpBar.objectIdBg = enemiesBarData.objectIdBg + LevelVars.Engine.CustomBars.enemiesHpBar.spriteIdBg = enemiesBarData.spriteIdBg + LevelVars.Engine.CustomBars.enemiesHpBar.colorBg = enemiesBarData.colorBg + LevelVars.Engine.CustomBars.enemiesHpBar.posBg = enemiesBarData.posBg + LevelVars.Engine.CustomBars.enemiesHpBar.scaleBg = enemiesBarData.scaleBg + LevelVars.Engine.CustomBars.enemiesHpBar.rotBg = enemiesBarData.rotBg + LevelVars.Engine.CustomBars.enemiesHpBar.alignModeBg = enemiesBarData.alignModeBg + LevelVars.Engine.CustomBars.enemiesHpBar.scaleModeBg = enemiesBarData.scaleModeBg + LevelVars.Engine.CustomBars.enemiesHpBar.blendModeBg = enemiesBarData.blendModeBg + LevelVars.Engine.CustomBars.enemiesHpBar.objectIdBar = enemiesBarData.objectIdBar + LevelVars.Engine.CustomBars.enemiesHpBar.spriteIdBar = enemiesBarData.spriteIdBar + LevelVars.Engine.CustomBars.enemiesHpBar.colorBar = enemiesBarData.colorBar + LevelVars.Engine.CustomBars.enemiesHpBar.posBar = enemiesBarData.posBar + LevelVars.Engine.CustomBars.enemiesHpBar.scaleBar = enemiesBarData.scaleBar + LevelVars.Engine.CustomBars.enemiesHpBar.rot = enemiesBarData.rot + LevelVars.Engine.CustomBars.enemiesHpBar.alignMode = enemiesBarData.alignMode + LevelVars.Engine.CustomBars.enemiesHpBar.scaleMode = enemiesBarData.scaleMode + LevelVars.Engine.CustomBars.enemiesHpBar.blendMode = enemiesBarData.blendMode + LevelVars.Engine.CustomBars.enemiesHpBar.textPos = enemiesBarData.textPos + LevelVars.Engine.CustomBars.enemiesHpBar.textOptions = enemiesBarData.textOptions + LevelVars.Engine.CustomBars.enemiesHpBar.textScale = enemiesBarData.textScale + LevelVars.Engine.CustomBars.enemiesHpBar.textColor = enemiesBarData.textColor + LevelVars.Engine.CustomBars.enemiesHpBar.hideText = enemiesBarData.hideText + LevelVars.Engine.CustomBars.enemiesHpBar.alphaBlendSpeed = enemiesBarData.alphaBlendSpeed + LevelVars.Engine.CustomBars.enemiesHpBar.blink = enemiesBarData.blink + LevelVars.Engine.CustomBars.enemiesHpBar.blinkLimit = enemiesBarData.blinkLimit + + + LevelVars.Engine.CustomBars.enemiesHpBar.status = true + +end + +--- The function retrieves an existing bar instance by its unique identifier (barName). This function is useful when you need to access or manipulate a bar that has already been created. +-- @string barName The unique identifier assigned to the bar when it was created using CustomBar.New +CustomBar.Get = function(barName) + local dataName = barName .. "_bar_data" + if LevelVars.Engine.CustomBars.bars[dataName] then + local self = {name = dataName} + return setmetatable(self, CustomBar) + end +end + +--- The function removes a custom bar and its associated data from the system. It ensures that the bar is no longer tracked or accessible in the LevelVars.Engine.CustomBars.bars table. +-- @string barName The name of the custom bar to be deleted. +CustomBar.Delete = function (barName) + local dataName = barName .. "_bar_data" + if LevelVars.Engine.CustomBars.bars[dataName] then + LevelVars.Engine.CustomBars.bars[dataName] = nil + end +end + +--- The function sets the value of a custom bar over a specified time period. +-- @number value The new target to which the bar's current value should transition. (Must be a non-negative number; between 0 and the bar's maxValue. +-- @number time The time (in seconds) over which the bar's value should transition to the target value. +function CustomBar:SetBarValue(value, time) + if LevelVars.Engine.CustomBars.bars[self.name] then + if type(value) =="number" and value >= 0 then + local currentValue = LevelVars.Engine.CustomBars.bars[self.name].oldValue + local maxValue = LevelVars.Engine.CustomBars.bars[self.name].maxValue + local newTargetValue = math.max(0, math.min(maxValue, value)) + LevelVars.Engine.CustomBars.bars[self.name].targetValue = newTargetValue + LevelVars.Engine.CustomBars.bars[self.name].fixedInterval = (newTargetValue - currentValue) / (time * 30) + end + end +end + +--- The function adjusts the bar's value relative to its current or target value over a specified time span. +-- @number value The relative value to add (positive or negative) to the current bar value. +-- @number time The duration (in seconds) over which the change should occur. +function CustomBar:ChangeBarValueOverTimespan(value, time) + -- Check if bar data and timer exist + if LevelVars.Engine.CustomBars.bars[self.name] then + + -- Get the current target value or old value if no target value exists + local currentValue = LevelVars.Engine.CustomBars.bars[self.name].oldValue + local maxValue = LevelVars.Engine.CustomBars.bars[self.name].maxValue + local currentTarget = LevelVars.Engine.CustomBars.bars[self.name].targetValue or currentValue + + -- Calculate new target value by adding the relative 'value' and clamp between 0 and 1000 + local newTargetValue = math.max(0, math.min(maxValue, currentTarget + value)) + + -- Set the new target value + LevelVars.Engine.CustomBars.bars[self.name].targetValue = newTargetValue + + -- Calculate total frames based on time and FPS (30 FPS) + local totalFrames = time * 30 + + -- Calculate the fixed interval for the entire transition + LevelVars.Engine.CustomBars.bars[self.name].fixedInterval = (newTargetValue - currentValue) / totalFrames + end +end + +--- The function controls the visibility of a custom bar. +-- @bool visible true: Makes the bar visible.; false: Hides the bar. +function CustomBar:SetVisibility(visible) + --the visible variable is a boolean + if LevelVars.Engine.CustomBars.bars[self.name] then + if visible and type(visible) == "boolean" then + LevelVars.Engine.CustomBars.bars[self.name].targetAlpha = 255 + LevelVars.Engine.CustomBars.bars[self.name].visible = true + else + LevelVars.Engine.CustomBars.bars[self.name].targetAlpha = 0 + end + end +end + +--- The function checks whether a custom bar is currently visible. +-- @treturn bool true if the bar is visible and false if it is not. +function CustomBar:IsVisible() + + if LevelVars.Engine.CustomBars.bars[self.name] then + if LevelVars.Engine.CustomBars.bars[self.name].visible then + return true + else + return false + end + end +end + +--- The function retrieves the current value of a custom bar. +-- @treturn float returns the current value of a custom bar. +function CustomBar:GetValue() + + if LevelVars.Engine.CustomBars.bars[self.name] then + return LevelVars.Engine.CustomBars.bars[self.name].oldValue + end +end + +--- The function deletes all custom bars. +CustomBar.DeleteAllBars = function () + for _, customBar in pairs (LevelVars.Engine.CustomBars.bars) do + LevelVars.Engine.CustomBars.bars[customBar.name] = nil + end +end + +--- This function prevents the creation of new health bars for enemies when set to false. However, it does not affect the health bars that have already been created. +-- @bool value Specifies whether new health bars for enemies should be created. +CustomBar.ShowEnemiesHpGenericBar = function(value) + if type(value) == "boolean" then + LevelVars.Engine.CustomBars.enemiesHpBar.status = value + end +end + +--- The function deletes all the enemy health bars excluding those created by CustomBar.CreateEnemyHpBar. +CustomBar.DeleteExistingHpGenericBars = function () + for _, customBar in pairs (LevelVars.Engine.CustomBars.bars) do + if customBar.getActionType == 4 then + LevelVars.Engine.CustomBars.bars[customBar.name] = nil + end + end +end + +--- Sets the custom bar background sprite position. +-- @tparam Vec2 pos X,Y position of the bar's background in screen percent (0-100). +-- +function CustomBar:SetBackgroundPosition(pos) + if pos and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].posBg = pos + end +end + +--- Sets the custom bar background sprite rotation. +-- @tparam number rot rotation of the bar's background. sprite (0-360). +-- +function CustomBar:SetBackgroundRotation(rot) + if rot and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].rotBg = rot + end +end + +-- Sets the custom bar background sprite color. +-- @tparam Color color Color of bar's background. +-- +function CustomBar:SetBackgroundColor(color) + if color and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].colorBg = color + end +end + +--- +-- Sets the custom bar background sprite scale. +-- @tparam Vec2 scale X,Y Scaling factor for the bar's background sprite. +-- +function CustomBar:SetBackgroundScale(scale) + if scale and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].scaleBg = scale + end +end + +--- +-- Sets the custom bar background sprite slot and sprite ID. +-- @tparam Objects.ObjID slot Object ID for the bar's background sprite. +-- @tparam number id SpriteID from the specified object for the bar's background. +-- +function CustomBar:SetBackgroundSpriteSlot(slot, id) + if slot and id and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].objectIdBg = slot + LevelVars.Engine.CustomBars.bars[self.name].spriteIdBg = id + end +end + +--- +-- Sets the custom bar background sprite align mode. +-- @tparam View.AlignMode alignMode Alignment for the bar's background. +-- +function CustomBar:SetBackgroundAlignMode(alignMode) + if alignMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].alignModeBg = alignMode + end +end +--- +-- Sets the custom bar background sprite scale mode. +-- @tparam View.ScaleMode scaleMode Scaling for the bar's background. +-- +function CustomBar:SetBackgroundScaleMode(scaleMode) + if scaleMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].scaleModeBg = scaleMode + end +end +--- +-- Sets the custom bar background sprite blend mode. +-- @tparam Effects.BlendID blendMode Blending modes for the bar's background. +-- +function CustomBar:SetBackgroundBlendMode(blendMode) + if blendMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].blendModeBg = blendMode + end +end + +--- +-- Sets the custom bar sprite position. +-- @tparam Vec2 pos X,Y position of the bar in screen percent (0-100). +-- +function CustomBar:SetBarPosition(pos) + if pos and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].posBar = pos + end +end +--- +-- Sets the custom bar sprite rotation. +-- @tparam number rot rotation of the bar's sprite (0-360). +-- +function CustomBar:SetBarRotation(rot) + if rot and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].rot = rot + end +end +--- +-- Sets the custom bar sprite color. +-- @tparam Color color Color of the bar. +-- +function CustomBar:SetBarColor(color) + if color and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].colorBar = color + end +end +--- +-- Sets the custom bar sprite scale. +-- @tparam Vec2 scale X,Y Scaling factor for the bar's sprite. +-- +function CustomBar:SetBarScale(scale) + if scale and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].scaleBar = scale + end +end +--- +-- Sets the custom bar sprite slot and sprite ID. +-- @tparam Objects.ObjID slot Object ID for the bar sprite. +-- @tparam number id SpriteID from the specified object for the bar. +-- +function CustomBar:SetBarSpriteSlot(slot, id) + if slot and id and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].objectIdBar = slot + LevelVars.Engine.CustomBars.bars[self.name].spriteIdBar = id + end +end +--- +-- Sets the custom bar sprite alignment mode. +-- @tparam View.AlignMode alignMode Alignment for the bar. +-- +function CustomBar:SetBarAlignMode(alignMode) + if alignMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].alignMode = alignMode + end +end +--- +-- Sets the custom bar sprite scale mode. +-- @tparam View.ScaleMode scaleMode Scaling for the bar. +-- +function CustomBar:SetBarScaleMode(scaleMode) + if scaleMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].scaleMode = scaleMode + end +end +--- +-- Sets the custom bar sprite blend mode. +-- @tparam Effects.BlendID blendMode Blending modes for the bar. +-- +function CustomBar:SetBarBlendMode(blendMode) + if blendMode and LevelVars.Engine.CustomBars.bars[self.name] then + LevelVars.Engine.CustomBars.bars[self.name].blendMode = blendMode + end +end + +LevelFuncs.Engine.CustomBar.UpdateCustomBars = function() + + local playerTarget = Lara:GetTarget() + + if playerTarget ~= nil and LevelVars.Engine.CustomBars.enemiesHpBar.status then + local playerTargetName = playerTarget:GetName() + local displayName = LevelFuncs.Engine.Node.SplitString(playerTargetName, "_") + local enemytable = playerTargetName .. "_bar_data" + if LevelVars.Engine.CustomBars.bars[enemytable] == nil then + local eB = LevelVars.Engine.CustomBars.enemiesHpBar + + local enemyBar = { + barName = playerTargetName, + objectIdBg = eB.objectIdBg, + spriteIdBg = eB.spriteIdBg, + colorBg = eB.colorBg, + posBg = eB.posBg, + rotBg = eB.rotBg, + scaleBg = eB.scaleBg, + alignModeBg = eB.alignModeBg, + scaleModeBg = eB.scaleModeBg, + blendModeBg = eB.blendModeBg, + objectIdBar = eB.objectIdBar, + spriteIdBar = eB.spriteIdBar, + colorBar = eB.colorBar, + posBar = eB.posBar, + rot = eB.rot, + scaleBar = eB.scaleBar, + alignMode = eB.alignMode, + scaleMode = eB.scaleMode, + blendMode = eB.blendMode, + text = displayName[1], + textPos = eB.textPos, + textOptions = eB.textOptions, + textScale = eB.textScale, + textColor = eB.textColor, + hideText = eB.hideText, + alphaBlendSpeed = eB.alphaBlendSpeed, + blink = eB.blink, + blinkLimit = eB.blinkLimit, + showBar = false, + object = playerTargetName + } + + CustomBar.CreateEnemyHpBar(enemyBar) + LevelVars.Engine.CustomBars.bars[enemytable].getActionType = 4 + + end + end + + for _, customBar in pairs (LevelVars.Engine.CustomBars.bars) do + + if customBar ~= nil then + -- Smoothly transition to target value + local currentValue = customBar.oldValue or 0 + local targetValue = customBar.targetValue or 0 + local delta = customBar.fixedInterval + + if customBar.object ~=nil and (customBar.getActionType == 0 or customBar.getActionType == 4) then + local enemy = GetMoveableByName(customBar.object) + currentValue = enemy:GetHP() + + targetValue = currentValue + + customBar.progress = math.max(0, math.min(currentValue / customBar.maxValue, 1)) + + if customBar.showBar == true then + -- If showBar is true, the bar is always visible at full alpha + customBar.targetAlpha = 255 + customBar.visible = true + else + -- If showBar is false, only show the bar if the enemy is the player's current target + if playerTarget == enemy then + customBar.targetAlpha = 255 -- Set to full alpha if this enemy is the target + customBar.visible = true + else + customBar.targetAlpha = 0 -- Set to 0 alpha if this enemy is not the target + end + end + + if currentValue <= 0 then + customBar.targetAlpha = 0 + end + + -- When Alpha reaches 0 set visibility to false + if currentValue <= 0 and customBar.currentAlpha == 0 then + customBar.visible = false + LevelVars.Engine.CustomBars.bars[customBar.name] = nil + end + end + + if customBar.getActionType == 1 then + + currentValue = Lara:GetHP() + targetValue = currentValue + + customBar.progress = math.max(0, math.min(currentValue / customBar.maxValue, 1)) + + -- Check if `hideBar` is true, which overrides all other behaviors + if customBar.showBar == true then + customBar.targetAlpha = 255 -- Bar is always visible + customBar.visible = true + + elseif currentValue ~= (customBar.oldValue or currentValue) then + customBar.targetAlpha = 255 -- Show the bar if value changes + customBar.visible = true + + customBar.currentTimer = customBar.currentTimer + 1 + + if customBar.currentTimer >= 90 then + customBar.oldValue = currentValue + customBar.currentTimer = 0 + end + + elseif Lara:GetHandStatus() == 0 and currentValue >= customBar.blinkLimit*1000 then + -- Hide bar if hands are free and HP is 200 or more + customBar.targetAlpha = 0 + customBar.visible = false + + elseif Lara:GetHandStatus() == 2 or Lara:GetHandStatus() == 3 or Lara:GetHandStatus() == 4 then + -- Show bar if hand status is 2, 3, or 4 (weapon drawn) + customBar.targetAlpha = 255 + customBar.visible = true + + elseif Lara:GetHandStatus() == 0 and currentValue < customBar.blinkLimit*1000 then + -- Show bar if hands are free and HP is less than 200 + customBar.targetAlpha = 255 + customBar.visible = true + end + + elseif customBar.getActionType == 2 then + currentValue = Lara:GetAir() + targetValue = currentValue + + customBar.progress = math.max(0, math.min(currentValue / customBar.maxValue, 1)) + + if customBar.showBar == true then + -- If showBar is true, the bar is always visible + customBar.targetAlpha = 255 + customBar.visible = true + else + -- If showBar is false, hide the bar when currentValue is at max + if currentValue == customBar.maxValue then + customBar.targetAlpha = 0 -- Hide the bar when at max value + else + customBar.targetAlpha = 255 -- Show the bar if currentValue is not max + customBar.visible = true + end + end + + elseif customBar.getActionType == 3 then + currentValue = Lara:GetStamina() + targetValue = currentValue + + customBar.progress = math.max(0, math.min(currentValue / customBar.maxValue, 1)) + + if customBar.showBar == true then + -- If showBar is true, the bar is always visible + customBar.targetAlpha = 255 + customBar.visible = true + else + -- If showBar is false, hide the bar when currentValue is at max + if currentValue == customBar.maxValue then + customBar.targetAlpha = 0 -- Hide the bar when at max value + else + customBar.targetAlpha = 255 -- Show the bar if currentValue is not max + customBar.visible = true + end + end + + end + + if currentValue ~= targetValue then + -- Update current value by delta (increment or decrement) + if currentValue < targetValue then + currentValue = math.min(currentValue + delta, targetValue) + else + currentValue = math.max(currentValue + delta, targetValue) + end + + -- Update the bar's progress (0-1 scale) + customBar.oldValue = currentValue + customBar.progress = currentValue / customBar.maxValue + end + -- Smoothly transition alpha + if customBar.currentAlpha ~= customBar.targetAlpha then + local alphaDelta = customBar.alphaBlendSpeed + if customBar.currentAlpha < customBar.targetAlpha then + customBar.currentAlpha = math.floor(math.min(customBar.currentAlpha + alphaDelta, customBar.targetAlpha)) + else + customBar.currentAlpha = math.floor(math.max(customBar.currentAlpha - alphaDelta, customBar.targetAlpha)) + end + end + + -- Set parameters to draw the background + local posBg = customBar.posBg + local scaleBg = customBar.scaleBg + local rotBg = customBar.rotBg + local alignMBg = LevelFuncs.Engine.Node.GetDisplaySpriteAlignMode(customBar.alignModeBg) + local scaleMBg = LevelFuncs.Engine.Node.GetDisplaySpriteScaleMode(customBar.scaleModeBg) + local blendIdBg = LevelFuncs.Engine.Node.GetBlendMode(customBar.blendModeBg) + + -- Adjust color with alpha blending + local bgColor = Color(customBar.colorBg.r,customBar.colorBg.g,customBar.colorBg.b,customBar.currentAlpha) + + -- Set parameters to draw the bar + local pos = customBar.posBar + local rot = customBar.rot + local alignM = LevelFuncs.Engine.Node.GetDisplaySpriteAlignMode(customBar.alignMode) + local scaleM = LevelFuncs.Engine.Node.GetDisplaySpriteScaleMode(customBar.scaleMode) + local blendID = LevelFuncs.Engine.Node.GetBlendMode(customBar.blendMode) + local barColor = TEN.Color(customBar.colorBar.r,customBar.colorBar.g,customBar.colorBar.b,customBar.currentAlpha) + + -- when Alpha reaches 0 set visibility to false + if customBar.currentAlpha > 0 then + customBar.visible = true + elseif customBar.currentAlpha == 0 then + customBar.visible = false + end + + --draw bar if alpha is greater than 1 and visibility is true + if customBar.visible and customBar.currentAlpha > 0 then + -- Draw background sprite + local bgSprite = TEN.DisplaySprite(customBar.objectIdBg, customBar.spriteIdBg, posBg, rotBg, scaleBg, bgColor) + bgSprite:Draw(0, alignMBg, scaleMBg, blendIdBg) + + -- Draw foreground sprite (the bar itself) proportional to Progress + local barScale = TEN.Vec2(customBar.scaleBar.x * customBar.progress, customBar.scaleBar.y) + local barSprite = TEN.DisplaySprite(customBar.objectIdBar, customBar.spriteIdBar, pos, rot, barScale, barColor) + + if customBar.frameCounter == nil then + customBar.frameCounter = 0 + end + + -- Calculate HP percentage + local Percentage = (currentValue / customBar.maxValue) + + -- Update frame counter + customBar.frameCounter = customBar.frameCounter + 1 + + -- Check if blink is enabled and value is below blinkLimit + if customBar.blink == true and Percentage <= customBar.blinkLimit then + -- Only draw the sprite every other frame + if customBar.frameCounter % (customBar.blinkSpeed * 2) < customBar.blinkSpeed then + barSprite:Draw(1, alignM, scaleM, blendID) + end + else + -- Draw the sprite normally if blink is off or value is above blinkLimit + barSprite:Draw(1, alignM, scaleM, blendID) + end + + -- Reset the frame counter if it reaches the blinkSpeed limit to prevent overflow + if customBar.frameCounter >= customBar.blinkSpeed * 2 then + customBar.frameCounter = 0 + end + + if customBar.hideText == false then + -- Draw text (enemy name and health) + local barText = tostring(customBar.text) --debug text .. " (" .. currentHP .. " / " .. totalHP .. ")" + local textColor = TEN.Color(customBar.textColor.r, customBar.textColor.g, customBar.textColor.b, customBar.currentAlpha) + local posInPixel = TEN.Vec2(TEN.Util.PercentToScreen(customBar.textPos.x, customBar.textPos.y)) + local IsString = TEN.Flow.IsStringPresent(barText) + local myText = TEN.Strings.DisplayString(barText, posInPixel, customBar.textScale, textColor, IsString, customBar.textOptions) + TEN.Strings.ShowString(myText, 1/30) + end + end + end + end +end + +TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, LevelFuncs.Engine.CustomBar.UpdateCustomBars) + +return CustomBar diff --git a/Scripts/Engine/CustomDiary.lua b/Scripts/Engine/CustomDiary.lua index 17ab7b27a..20b029c37 100644 --- a/Scripts/Engine/CustomDiary.lua +++ b/Scripts/Engine/CustomDiary.lua @@ -1,6 +1,5 @@ ----- ---- Diaries: --- The module provides functions to create and manage Diaries. It maintains diary definitions and entries through all levels and hubs. +-- This module provides functions to create and manage diaries. It maintains diary definitions and entries through all levels and hubs. -- Each diary is accessed by the object that was used to create it. -- -- Example usage: @@ -532,9 +531,9 @@ end -- @tparam Objects.ObjID objectIdBg Object ID for the diary's sprite. -- @tparam int spriteIdBg SpriteID from the specified object for the diary's sprite. -- @tparam Color colorBg Color of diary's sprite. --- @tparam Vec2 pos X,Y position of the bar's background in screen percent (0-100). +-- @tparam Vec2 pos X,Y position of the diary background sprite in screen percent (0-100). -- @tparam float rot rotation of the diary's sprite (0-360). --- @tparam Vec2 scale X,Y Scaling factor for the bar's background sprite. +-- @tparam Vec2 scale X,Y Scaling factor for the diary background sprite. -- @tparam View.AlignMode alignMode Alignment for the diary's sprite. -- @tparam View.ScaleMode scaleMode Scaling for the diary's sprite. -- @tparam Effects.BlendID blendMode Blending modes for the diary's sprite. diff --git a/Scripts/Gameflow.lua b/Scripts/Gameflow.lua index 4467179a4..342c8b6b2 100644 --- a/Scripts/Gameflow.lua +++ b/Scripts/Gameflow.lua @@ -6,6 +6,11 @@ Flow.SetIntroImagePath("Screens\\main.jpg") +-- Intro video plays right after or instead of intro image, if specified. +-- If you don't want it to appear, just remove this line. + +--Flow.SetIntroVideoPath("FMV\\core.mp4") + -- Set overall amount of secrets in game. -- If set to 0, secrets won't be displayed in statistics. diff --git a/Scripts/Settings.lua b/Scripts/Settings.lua index 75981eaf7..989c44f8e 100644 --- a/Scripts/Settings.lua +++ b/Scripts/Settings.lua @@ -19,7 +19,7 @@ local settings = Flow.Settings.new() settings.Flare.offset = Vec3(0, 0, 41) settings.Flare.range = 9 settings.Flare.timeout = 60 - settings.Flare.lensflareBrightness = 0.5 + settings.Flare.lensflareBrightness = 1.0 settings.Flare.sparks = true settings.Flare.smoke = true settings.Flare.flicker = true @@ -35,6 +35,7 @@ local settings = Flow.Settings.new() settings.System.errorMode = Flow.ErrorMode.WARN settings.System.fastReload = true + settings.System.multithreaded = true -- Hair[1] is normal player hair. Types [2] and [3] are for left and right young Lara hair. diff --git a/TombEngine/Game/Hud/Speedometer.cpp b/TombEngine/Game/Hud/Speedometer.cpp index 6253fc6ac..6167b203c 100644 --- a/TombEngine/Game/Hud/Speedometer.cpp +++ b/TombEngine/Game/Hud/Speedometer.cpp @@ -70,14 +70,14 @@ namespace TEN::Hud // Draw dial. AddDisplaySprite( - ID_SPEEDOMETER, DIAL_ELEMENT_SPRITE_ID, + ID_SPEEDOMETER_GRAPHICS, DIAL_ELEMENT_SPRITE_ID, POS, 0, SCALE, color, DIAL_PRIORITY, DisplaySpriteAlignMode::Center, DisplaySpriteScaleMode::Fit, BlendMode::AlphaBlend, DisplaySpritePhase::Draw); // Draw pointer. AddDisplaySprite( - ID_SPEEDOMETER, POINTER_ELEMENT_SPRITE_ID, + ID_SPEEDOMETER_GRAPHICS, POINTER_ELEMENT_SPRITE_ID, POS, pointerAngle + POINTER_ANGLE_OFFSET, SCALE, color, POINTER_PRIORITY, DisplaySpriteAlignMode::Center, DisplaySpriteScaleMode::Fit, BlendMode::AlphaBlend, DisplaySpritePhase::Draw); diff --git a/TombEngine/Game/Hud/TargetHighlighter.cpp b/TombEngine/Game/Hud/TargetHighlighter.cpp index a1d895216..fc30b0714 100644 --- a/TombEngine/Game/Hud/TargetHighlighter.cpp +++ b/TombEngine/Game/Hud/TargetHighlighter.cpp @@ -132,7 +132,7 @@ namespace TEN::Hud void CrosshairData::Draw() const { - constexpr auto SPRITE_SEQUENCE_OBJECT_ID = ID_CROSSHAIR; + constexpr auto SPRITE_SEQUENCE_OBJECT_ID = ID_CROSSHAIR_GRAPHICS; constexpr auto STATIC_ELEMENT_SPRITE_ID = 0; constexpr auto SEGMENT_ELEMENT_SPRITE_ID = 1; constexpr auto PRIORITY = 0; // TODO: Check later. May interfere with Lua display sprites. -- Sezz 2023.10.06 diff --git a/TombEngine/Game/Lara/lara.cpp b/TombEngine/Game/Lara/lara.cpp index d222d736b..29f2bd1ee 100644 --- a/TombEngine/Game/Lara/lara.cpp +++ b/TombEngine/Game/Lara/lara.cpp @@ -1,25 +1,6 @@ #include "framework.h" #include "Game/Lara/lara.h" -#include "Game/Lara/lara_basic.h" -#include "Game/Lara/lara_cheat.h" -#include "Game/Lara/lara_climb.h" -#include "Game/Lara/lara_collide.h" -#include "Game/Lara/lara_crawl.h" -#include "Game/Lara/lara_fire.h" -#include "Game/Lara/lara_hang.h" -#include "Game/Lara/lara_helpers.h" -#include "Game/Lara/lara_helpers.h" -#include "Game/Lara/lara_initialise.h" -#include "Game/Lara/lara_jump.h" -#include "Game/Lara/lara_monkey.h" -#include "Game/Lara/lara_objects.h" -#include "Game/Lara/lara_one_gun.h" -#include "Game/Lara/lara_overhang.h" -#include "Game/Lara/lara_slide.h" -#include "Game/Lara/lara_surface.h" -#include "Game/Lara/lara_swim.h" -#include "Game/Lara/lara_tests.h" #include "Game/animation.h" #include "Game/camera.h" #include "Game/collision/collide_item.h" @@ -32,11 +13,24 @@ #include "Game/effects/tomb4fx.h" #include "Game/Gui.h" #include "Game/items.h" +#include "Game/Lara/lara_basic.h" #include "Game/Lara/lara_cheat.h" +#include "Game/Lara/lara_climb.h" #include "Game/Lara/lara_collide.h" +#include "Game/Lara/lara_crawl.h" #include "Game/Lara/lara_fire.h" +#include "Game/Lara/lara_hang.h" #include "Game/Lara/lara_helpers.h" #include "Game/Lara/lara_initialise.h" +#include "Game/Lara/lara_jump.h" +#include "Game/Lara/lara_monkey.h" +#include "Game/Lara/lara_objects.h" +#include "Game/Lara/lara_one_gun.h" +#include "Game/Lara/lara_overhang.h" +#include "Game/Lara/lara_slide.h" +#include "Game/Lara/lara_surface.h" +#include "Game/Lara/lara_swim.h" +#include "Game/Lara/lara_tests.h" #include "Game/Lara/PlayerStateMachine.h" #include "Game/misc.h" #include "Game/savegame.h" diff --git a/TombEngine/Game/Lara/lara_fire.cpp b/TombEngine/Game/Lara/lara_fire.cpp index 2e4597bb1..2ab074e1e 100644 --- a/TombEngine/Game/Lara/lara_fire.cpp +++ b/TombEngine/Game/Lara/lara_fire.cpp @@ -871,7 +871,6 @@ FireWeaponType FireWeapon(LaraWeaponType weaponType, ItemInfo* targetEntity, Ite auto ray = Ray(origin, directionNorm); player.Control.Weapon.HasFired = true; - player.Control.Weapon.Fired = true; auto vOrigin = GameVector(pos); short roomNumber = laraItem.RoomNumber; diff --git a/TombEngine/Game/Lara/lara_helpers.cpp b/TombEngine/Game/Lara/lara_helpers.cpp index f3be03a8e..63bb5878e 100644 --- a/TombEngine/Game/Lara/lara_helpers.cpp +++ b/TombEngine/Game/Lara/lara_helpers.cpp @@ -476,14 +476,14 @@ void HandlePlayerLookAround(ItemInfo& item, bool invertXAxis) if ((IsHeld(In::Forward) || IsHeld(In::Back)) && (player.Control.Look.Mode == LookMode::Free || player.Control.Look.Mode == LookMode::Vertical)) { - axisCoeff.x = AxisMap[(int)InputAxis::Move].y; + axisCoeff.x = AxisMap[InputAxisID::Move].y; } // Determine Y axis coefficient. if ((IsHeld(In::Left) || IsHeld(In::Right)) && (player.Control.Look.Mode == LookMode::Free || player.Control.Look.Mode == LookMode::Horizontal)) { - axisCoeff.y = AxisMap[(int)InputAxis::Move].x; + axisCoeff.y = AxisMap[InputAxisID::Move].x; } // Determine turn rate base values. @@ -583,7 +583,7 @@ void HandlePlayerLean(ItemInfo* item, CollisionInfo* coll, short baseRate, short if (!item->Animation.Velocity.z) return; - float axisCoeff = AxisMap[(int)InputAxis::Move].x; + float axisCoeff = AxisMap[InputAxisID::Move].x; int sign = copysign(1, axisCoeff); short maxAngleNormalized = maxAngle * axisCoeff; @@ -604,7 +604,7 @@ void HandlePlayerCrawlFlex(ItemInfo& item) if (item.Animation.Velocity.z == 0.0f) return; - float axisCoeff = AxisMap[(int)InputAxis::Move].x; + float axisCoeff = AxisMap[InputAxisID::Move].x; int sign = copysign(1, axisCoeff); short maxAngleNormalized = FLEX_ANGLE_MAX * axisCoeff; @@ -802,6 +802,7 @@ void HandlePlayerFlyCheat(ItemInfo& item) item.Animation.Velocity = Vector3::Zero; item.Animation.IsAirborne = true; item.Pose.Position.y -= CLICK(0.5f); + item.Pose.Scale = Vector3::One; item.HitPoints = LARA_HEALTH_MAX; player.Control.WaterStatus = WaterStatus::FlyCheat; @@ -1230,7 +1231,7 @@ void ModulateLaraTurnRateY(ItemInfo* item, short accelRate, short minTurnRate, s { auto* lara = GetLaraInfo(item); - float axisCoeff = AxisMap[(int)InputAxis::Move].x; + float axisCoeff = AxisMap[InputAxisID::Move].x; if (item->Animation.IsAirborne) { int sign = std::copysign(1, axisCoeff); diff --git a/TombEngine/Game/Lara/lara_one_gun.cpp b/TombEngine/Game/Lara/lara_one_gun.cpp index e9f7a7f56..ede45b080 100644 --- a/TombEngine/Game/Lara/lara_one_gun.cpp +++ b/TombEngine/Game/Lara/lara_one_gun.cpp @@ -32,6 +32,7 @@ #include "Specific/clock.h" #include "Specific/Input/Input.h" #include "Specific/level.h" +#include "Specific/trutils.h" using namespace TEN::Collision::Point; using namespace TEN::Effects::Bubble; @@ -67,27 +68,6 @@ constexpr auto HK_RAPID_MODE_SHOT_INTERVAL = 3.0f; constexpr auto SHOTGUN_PELLET_COUNT = 6; -static Vector3i GetWeaponSmokeRelOffset(LaraWeaponType weaponType) -{ - switch (weaponType) - { - case LaraWeaponType::HK: - return Vector3i(0, 228, 96); - - case LaraWeaponType::Shotgun: - return Vector3i(0, 228, 0); - - case LaraWeaponType::GrenadeLauncher: - return Vector3i(0, 180, 80); - - case LaraWeaponType::RocketLauncher: - return Vector3i(0, 84, 72);; - - default: - return Vector3i::Zero; - } -} - void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) { auto& player = *GetLaraInfo(&laraItem); @@ -95,7 +75,7 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) if (player.LeftArm.GunSmoke > 0) { - auto relOffset = GetWeaponSmokeRelOffset(weaponType); + auto relOffset = g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1].MuzzleOffset.ToVector3(); auto pos = GetJointPosition(&laraItem, LM_RHAND, relOffset); if (laraItem.MeshBits.TestAny()) @@ -114,6 +94,8 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) player.Control.Weapon.Timer = 0.0f; } + bool hasFired = false; + switch (item.Animation.ActiveState) { case WEAPON_STATE_AIM: @@ -188,11 +170,11 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) switch (weaponType) { default: - FireShotgun(laraItem); + hasFired = FireShotgun(laraItem); break; case LaraWeaponType::HarpoonGun: - FireHarpoon(laraItem); + hasFired = FireHarpoon(laraItem); if (!(player.Weapons[(int)LaraWeaponType::HarpoonGun].Ammo->GetCount() % 4) && !player.Weapons[(int)weaponType].Ammo->HasInfinite()) @@ -203,15 +185,15 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) break; case LaraWeaponType::RocketLauncher: - FireRocket(laraItem); + hasFired = FireRocket(laraItem); break; case LaraWeaponType::GrenadeLauncher: - FireGrenade(laraItem); + hasFired = FireGrenade(laraItem); break; case LaraWeaponType::Crossbow: - FireCrossbow(laraItem); + hasFired = FireCrossbow(laraItem); break; case LaraWeaponType::HK: @@ -223,7 +205,7 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) } else { - FireHK(laraItem, false); + hasFired = FireHK(laraItem, false); player.Control.Weapon.Timer = 1.0f; item.Animation.TargetState = WEAPON_STATE_RECOIL; @@ -251,9 +233,8 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) player.Control.Weapon.Timer = 0.0f; } } - else if (player.Control.Weapon.Timer != 0.0f) + else if (weaponType == LaraWeaponType::HK && player.Control.Weapon.Timer != 0.0f) { - SoundEffect(SFX_TR4_EXPLOSION1, &laraItem.Pose, SoundEnvironment::Land, 1.0f, 0.4f); SoundEffect(SFX_TR4_HK_FIRE, &laraItem.Pose); } else if (weaponType == LaraWeaponType::Shotgun && !IsHeld(In::Action) && !player.LeftArm.Locked) @@ -285,7 +266,7 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) break; case LaraWeaponType::HarpoonGun: - FireHarpoon(laraItem); + hasFired = FireHarpoon(laraItem); if (!(player.Weapons[(int)LaraWeaponType::HarpoonGun].Ammo->GetCount() % 4) && !player.Weapons[(int)weaponType].Ammo->HasInfinite()) @@ -297,14 +278,14 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) case LaraWeaponType::HK: if ((weapon.WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_2 || - weapon.WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_3) && + weapon.WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_3) && player.Control.Weapon.Interval != 0.0f) { item.Animation.TargetState = WEAPON_STATE_UNDERWATER_AIM; } else { - FireHK(laraItem, true); + hasFired = FireHK(laraItem, true); player.Control.Weapon.Timer = 1.0f; item.Animation.TargetState = WEAPON_STATE_UNDERWATER_RECOIL; @@ -332,9 +313,8 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) player.Control.Weapon.Timer = 0.0f; } } - else if (player.Control.Weapon.Timer != 0.0f) + else if (weaponType == LaraWeaponType::HK && player.Control.Weapon.Timer != 0.0f) { - SoundEffect(SFX_TR4_EXPLOSION1, &laraItem.Pose, SoundEnvironment::Land, 1.0f, 0.4f); SoundEffect(SFX_TR4_HK_FIRE, &laraItem.Pose); } @@ -344,6 +324,18 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) break; } + if (hasFired) + { + player.Control.Weapon.HasFired = true; + + player.RightArm.GunFlash = Weapons[(int)weaponType].FlashTime; + if (weaponType != LaraWeaponType::GrenadeLauncher && weaponType != LaraWeaponType::RocketLauncher) + player.LeftArm.GunSmoke = 20; + + SaveGame::Statistics.Level.AmmoUsed++; + SaveGame::Statistics.Game.AmmoUsed++; + } + item.Pose.Position = laraItem.Pose.Position; item.RoomNumber = laraItem.RoomNumber; @@ -370,13 +362,13 @@ void ReadyShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) player.RightArm.FrameBase = Objects[GetWeaponObjectID(weaponType)].frameBase; } -void FireShotgun(ItemInfo& laraItem) +bool FireShotgun(ItemInfo& laraItem) { auto& player = *GetLaraInfo(&laraItem); auto& ammo = GetAmmo(player, LaraWeaponType::Shotgun); if (!ammo.HasInfinite() && !ammo.GetCount()) - return; + return false; auto armOrient = EulerAngles( player.LeftArm.Orientation.x, @@ -410,10 +402,10 @@ void FireShotgun(ItemInfo& laraItem) if (!ammo.HasInfinite()) ammo--; - auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, 1508, 32)); - auto pos2 = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, 228, 32)); + auto offset = g_GameFlow->GetSettings()->Weapons[(int)LaraWeaponType::Shotgun].MuzzleOffset.ToVector3i(); - player.LeftArm.GunSmoke = 32; + auto pos = GetJointPosition(&laraItem, LM_RHAND, offset + Vector3::UnitY * CLICK(2)); + auto pos2 = GetJointPosition(&laraItem, LM_RHAND, offset); if (laraItem.MeshBits != 0) { @@ -426,16 +418,13 @@ void FireShotgun(ItemInfo& laraItem) } } - player.RightArm.GunFlash = Weapons[(int)LaraWeaponType::Shotgun].FlashTime; - SoundEffect(SFX_TR4_EXPLOSION1, &laraItem.Pose, TestEnvironment(ENV_FLAG_WATER, &laraItem) ? SoundEnvironment::Underwater : SoundEnvironment::Land); SoundEffect(Weapons[(int)LaraWeaponType::Shotgun].SampleNum, &laraItem.Pose); Rumble(0.5f, 0.2f); - - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; } + + return hasFired; } void DrawShotgun(ItemInfo& laraItem, LaraWeaponType weaponType) @@ -572,8 +561,6 @@ bool FireHarpoon(ItemInfo& laraItem, const std::optional& pose) if (!ammo) return false; - player.Control.Weapon.HasFired = true; - int itemNumber = CreateItem(); if (itemNumber == NO_VALUE) return false; @@ -628,14 +615,10 @@ bool FireHarpoon(ItemInfo& laraItem, const std::optional& pose) harpoonItem.HitPoints = HARPOON_TIME; AddActiveItem(itemNumber); - harpoonItem.ItemFlags[0] = (int)ProjectileType::Harpoon; Rumble(0.2f, 0.1f); - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; - return true; } @@ -672,19 +655,17 @@ void HarpoonBoltControl(short itemNumber) HandleProjectile(harpoonItem, *LaraItem, prevPos, (ProjectileType)harpoonItem.ItemFlags[0], damage); } -void FireGrenade(ItemInfo& laraItem) +bool FireGrenade(ItemInfo& laraItem) { auto& player = *GetLaraInfo(&laraItem); auto& ammo = GetAmmo(player, LaraWeaponType::GrenadeLauncher); if (!ammo) - return; - - player.Control.Weapon.HasFired = true; + return false; short itemNumber = CreateItem(); if (itemNumber == NO_VALUE) - return; + return false; auto& grenadeItem = g_Level.Items[itemNumber]; @@ -763,8 +744,7 @@ void FireGrenade(ItemInfo& laraItem) break; } - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; + return true; } void GrenadeControl(short itemNumber) @@ -855,19 +835,17 @@ void GrenadeControl(short itemNumber) HandleProjectile(grenadeItem, *LaraItem, prevPos, (ProjectileType)grenadeItem.ItemFlags[0], Weapons[(int)LaraWeaponType::GrenadeLauncher].Damage); } -void FireRocket(ItemInfo& laraItem) +bool FireRocket(ItemInfo& laraItem) { auto& player = *GetLaraInfo(&laraItem); auto& ammo = GetAmmo(player, LaraWeaponType::RocketLauncher); if (!ammo) - return; - - player.Control.Weapon.HasFired = true; + return false; short itemNumber = CreateItem(); if (itemNumber == NO_VALUE) - return; + return false; auto& rocketItem = g_Level.Items[itemNumber]; rocketItem.ObjectNumber = ID_ROCKET; @@ -925,8 +903,7 @@ void FireRocket(ItemInfo& laraItem) Rumble(0.4f, 0.3f); SoundEffect(SFX_TR4_EXPLOSION1, &laraItem.Pose); - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; + return true; } void RocketControl(short itemNumber) @@ -994,19 +971,17 @@ void RocketControl(short itemNumber) HandleProjectile(rocketItem, *LaraItem, prevPos, ProjectileType::Explosive, Weapons[(int)LaraWeaponType::RocketLauncher].Damage); } -void FireCrossbow(ItemInfo& laraItem, const std::optional& pose) +bool FireCrossbow(ItemInfo& laraItem, const std::optional& pose) { auto& player = *GetLaraInfo(&laraItem); auto& ammo = GetAmmo(player, LaraWeaponType::Crossbow); if (!ammo) - return; - - player.Control.Weapon.HasFired = true; + return false; short itemNumber = CreateItem(); if (itemNumber == NO_VALUE) - return; + return false; auto& boltItem = g_Level.Items[itemNumber]; boltItem.ObjectNumber = ID_CROSSBOW_BOLT; @@ -1079,8 +1054,7 @@ void FireCrossbow(ItemInfo& laraItem, const std::optional& pose) Rumble(0.2f, 0.1f); SoundEffect(SFX_TR4_CROSSBOW_FIRE, &laraItem.Pose); - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; + return true; } void FireCrossBowFromLaserSight(ItemInfo& laraItem, GameVector* origin, GameVector* target) @@ -1112,7 +1086,7 @@ void CrossbowBoltControl(short itemNumber) HandleProjectile(boltItem, *LaraItem, prevPos, (ProjectileType)boltItem.ItemFlags[0], damage); } -void FireHK(ItemInfo& laraItem, bool inaccurateMode) +bool FireHK(ItemInfo& laraItem, bool inaccurateMode) { auto& player = *GetLaraInfo(&laraItem); const auto& weapon = player.Weapons[(int)LaraWeaponType::HK]; @@ -1154,19 +1128,19 @@ void FireHK(ItemInfo& laraItem, bool inaccurateMode) Weapons[(int)LaraWeaponType::HK].Damage = damage / 3; } - if (FireWeapon(LaraWeaponType::HK, player.TargetEntity, laraItem, angles) != FireWeaponType::NoAmmo) + bool hasFired = FireWeapon(LaraWeaponType::HK, player.TargetEntity, laraItem, angles) != FireWeaponType::NoAmmo; + + if (hasFired) { - player.LeftArm.GunSmoke = 12; - TriggerGunShell(1, ID_GUNSHELL, LaraWeaponType::HK); - player.RightArm.GunFlash = Weapons[(int)LaraWeaponType::HK].FlashTime; - Rumble(0.2f, 0.1f); } // HACK: Restore accuracy/damage values. Weapons[(int)LaraWeaponType::HK].ShotAccuracy = accuracy; Weapons[(int)LaraWeaponType::HK].Damage = damage; + + return hasFired; } void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType) @@ -1215,6 +1189,9 @@ void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType) } else if (player.Control.Weapon.GunType == LaraWeaponType::HK) { + SaveGame::Statistics.Level.AmmoUsed++; + SaveGame::Statistics.Game.AmmoUsed++; + bool playSound = false; if (weapon.WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_3) @@ -1251,7 +1228,6 @@ void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType) if (playSound) { - SoundEffect(SFX_TR4_EXPLOSION1, nullptr, SoundEnvironment::Land, 1.0f, 0.4f); SoundEffect(SFX_TR4_HK_FIRE, nullptr); Camera.bounce = -16 - (GetRandomControl() & 0x1F); } @@ -1304,16 +1280,17 @@ void RifleHandler(ItemInfo& laraItem, LaraWeaponType weaponType) auto color = Color(settings.FlashColor); color += Color(Random::GenerateFloat(-0.2f, 0.2f)); - if (weaponType == LaraWeaponType::Shotgun || weaponType == LaraWeaponType::HK) - { - auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, -64, 0)); - SpawnDynamicPointLight(pos.ToVector3(), color, CLICK(settings.FlashRange)); - } - else if (weaponType == LaraWeaponType::Revolver) + if (weaponType == LaraWeaponType::Revolver) { auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, -32, 0)); SpawnDynamicPointLight(pos.ToVector3(), color, CLICK(settings.FlashRange)); } + else + { + auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, -64, 0)); + SpawnDynamicPointLight(pos.ToVector3(), color, CLICK(settings.FlashRange)); + } + } } @@ -1339,8 +1316,8 @@ void DoExplosiveDamage(ItemInfo& emitter, ItemInfo& target, ItemInfo& projectile SaveGame::Statistics.Level.AmmoHits++; if (target.HitPoints <= 0) { - SaveGame::Statistics.Level.Kills++; SaveGame::Statistics.Game.Kills++; + SaveGame::Statistics.Level.Kills++; CreatureDie(target.Index, true); } } @@ -1594,7 +1571,7 @@ void HandleProjectile(ItemInfo& projectile, ItemInfo& emitter, const Vector3i& p for (auto* itemPtr : collObjects.Items) { // Object was already affected by collision, skip it. - if (std::find(affectedObjects.begin(), affectedObjects.end(), itemPtr->Index) != affectedObjects.end()) + if (TEN::Utils::Contains(affectedObjects, itemPtr->Index)) continue; const auto& currentObject = Objects[itemPtr->ObjectNumber]; diff --git a/TombEngine/Game/Lara/lara_one_gun.h b/TombEngine/Game/Lara/lara_one_gun.h index 17495531e..24cf906b8 100644 --- a/TombEngine/Game/Lara/lara_one_gun.h +++ b/TombEngine/Game/Lara/lara_one_gun.h @@ -28,7 +28,7 @@ enum class ProjectileType void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType); void ReadyShotgun(ItemInfo& laraItem, LaraWeaponType weaponType); -void FireShotgun(ItemInfo& laraItem); +bool FireShotgun(ItemInfo& laraItem); void DrawShotgun(ItemInfo& laraItem, LaraWeaponType weaponType); void UndrawShotgun(ItemInfo& laraItem, LaraWeaponType weaponType); void DrawShotgunMeshes(ItemInfo& laraItem, LaraWeaponType weaponType); @@ -36,16 +36,15 @@ void UndrawShotgunMeshes(ItemInfo& laraItem, LaraWeaponType weaponType); bool FireHarpoon(ItemInfo& laraItem, const std::optional& pose = std::nullopt); void HarpoonBoltControl(short itemNumber); -void FireGrenade(ItemInfo& laraItem); +bool FireGrenade(ItemInfo& laraItem); void GrenadeControl(short itemNumber); -void FireRocket(ItemInfo& laraItem); -void FireRocket(ItemInfo& laraItem); +bool FireRocket(ItemInfo& laraItem); void RocketControl(short itemNumber); -void FireCrossbow(ItemInfo& laraItem, const std::optional& pose = std::nullopt); +bool FireCrossbow(ItemInfo& laraItem, const std::optional& pose = std::nullopt); void FireCrossBowFromLaserSight(ItemInfo& laraItem, GameVector* origin, GameVector* target); void CrossbowBoltControl(short itemNumber); -void FireHK(ItemInfo& laraItem, bool inaccurateMode); +bool FireHK(ItemInfo& laraItem, bool inaccurateMode); void RifleHandler(ItemInfo& laraItem, LaraWeaponType weaponType); void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType); diff --git a/TombEngine/Game/Lara/lara_struct.h b/TombEngine/Game/Lara/lara_struct.h index 42a446380..b0d6bb61d 100644 --- a/TombEngine/Game/Lara/lara_struct.h +++ b/TombEngine/Game/Lara/lara_struct.h @@ -611,7 +611,7 @@ enum LaraAnim LA_LADDER_RIGHT_CORNER_OUTER_START = 365, // Ladder around outer right corner LA_PUSHABLE_BLOCK_PUSH_EDGE_SLIP = 366, LA_LADDER_LEFT_CORNER_INNER_START = 367, // Ladder around inner left corner - LA_LADDER_LEFT_CORNER_INNER_END = 368, // TODO: Remove. + LA_LADDER_LEFT_CORNER_INNER_END = 368, LA_LADDER_RIGHT_CORNER_INNER_START = 369, // Ladder around inner right corner LA_LADDER_RIGHT_CORNER_INNER_END = 370, // TODO: Remove. LA_JUMP_UP_TO_ROPE_START = 371, // Jump up > rope idle (1/2) @@ -688,7 +688,7 @@ enum LaraAnim LA_PICKUP_SARCOPHAGUS = 439, // Pickup from sarcophagus LA_DRAG_BODY = 440, // Drag dead body LA_BINOCULARS_IDLE = 441, // Stand, looking through binoculars - LA_UNUSED_442 = 442, // Formelly, LA_BIG_SCORPION_DEATH, but that animation is now in LARA EXTRA ANIMS so this slot is unused. + LA_UNDERWATER_FLOOR_TRAPDOOR = 442, // Underwater floor trapdoor LA_ELEVATOR_RECOVER = 443, // Recover from elevator crash LA_MECHANICAL_BEETLE_USE = 444, // Wind mechanical beetle, place on floor LA_FLY_CHEAT = 445, // Fly cheat @@ -828,7 +828,7 @@ enum LaraAnim NUM_LARA_ANIMS // TRASHED ANIMS (reuse slots before going any higher and remove entries from this list when you do): - // 368, 370, + // 370, // 442 }; @@ -1218,7 +1218,6 @@ struct WeaponControlData short WeaponItem = -1; bool HasFired = false; - bool Fired = false; bool UziLeft = false; bool UziRight = false; diff --git a/TombEngine/Game/Lara/lara_two_guns.cpp b/TombEngine/Game/Lara/lara_two_guns.cpp index a044c4282..48a26e200 100644 --- a/TombEngine/Game/Lara/lara_two_guns.cpp +++ b/TombEngine/Game/Lara/lara_two_guns.cpp @@ -45,24 +45,6 @@ static WeaponAnimData GetWeaponAnimData(LaraWeaponType weaponType) return ((it != ANIM_DATA_MAP.end()) ? it->second : ANIM_DATA_MAP.at(LaraWeaponType::None)); } -static Vector3i GetWeaponSmokeRelOffset(LaraWeaponType weaponType, bool isRightWeapon) -{ - switch (weaponType) - { - case LaraWeaponType::Pistol: - return Vector3i(isRightWeapon ? -16 : 4, 128, 40); - - case LaraWeaponType::Revolver: - return Vector3i(isRightWeapon ? -32 : 16, 160, 56); - - case LaraWeaponType::Uzi: - return Vector3i(isRightWeapon ? -16 : 8, 140, 48); - - default: - return Vector3i::Zero; - } -} - static void SetArmInfo(const ItemInfo& laraItem, ArmInfo& arm, int frame) { const auto& player = GetLaraInfo(laraItem); @@ -118,8 +100,9 @@ static void AnimateWeapon(ItemInfo& laraItem, LaraWeaponType weaponType, bool& h // Spawn weapon smoke. if (laraItem.MeshBits.TestAny() && arm.GunSmoke) { - auto relOffset = GetWeaponSmokeRelOffset(weaponType, isRightWeapon); + auto relOffset = g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1].MuzzleOffset.ToVector3(); auto pos = GetJointPosition(&laraItem, isRightWeapon ? LM_RHAND : LM_LHAND, relOffset); + TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, weaponType, arm.GunSmoke); } diff --git a/TombEngine/Game/Setup.cpp b/TombEngine/Game/Setup.cpp index 76b6a2944..cff23c284 100644 --- a/TombEngine/Game/Setup.cpp +++ b/TombEngine/Game/Setup.cpp @@ -27,6 +27,7 @@ #include "Objects/TR4/Entity/tr4_beetle_swarm.h" #include "Objects/Utils/object_helper.h" #include "Specific/level.h" +#include "Objects/Effects/Fireflies.h" using namespace TEN::Effects::Hair; using namespace TEN::Entities; @@ -174,6 +175,7 @@ void InitializeGameFlags() FlipEffect = NO_VALUE; FlipStatus = false; + NumRPickups = 0; Camera.underwater = false; } @@ -197,6 +199,7 @@ void InitializeSpecialEffects() TEN::Entities::TR4::ClearBeetleSwarm(); TEN::Entities::Creatures::TR3::ClearFishSwarm(); + TEN::Effects::Fireflies::ClearFireflySwarm(); } void CustomObjects() @@ -206,6 +209,8 @@ void CustomObjects() void InitializeObjects() { + TENLog("Initializing objects...", LogLevel::Info); + AllocTR4Objects(); AllocTR5Objects(); @@ -248,10 +253,6 @@ void InitializeObjects() // User defined objects CustomObjects(); - HairEffect.Initialize(); - InitializeSpecialEffects(); - - NumRPickups = 0; CurrentSequence = 0; SequenceResults[0][1][2] = 0; SequenceResults[0][2][1] = 1; diff --git a/TombEngine/Game/animation.cpp b/TombEngine/Game/animation.cpp index 53d0a6d46..3588ef746 100644 --- a/TombEngine/Game/animation.cpp +++ b/TombEngine/Game/animation.cpp @@ -689,6 +689,18 @@ void ClampRotation(Pose& outPose, short angle, short rotation) Vector3i GetJointPosition(const ItemInfo& item, int jointIndex, const Vector3i& relOffset) { + bool incorrectJoint = false; + if (jointIndex < 0 || jointIndex >= Objects[item.ObjectNumber].nmeshes) + { + TENLog("Unknown joint ID specified for object " + GetObjectName(item.ObjectNumber), LogLevel::Warning, LogConfig::All); + incorrectJoint = true; + } + + // Always return object's root position if it's invisible, because we can't predict its + // joint position otherwise, since it's not animated. + if (incorrectJoint || Objects[item.ObjectNumber].drawRoutine == nullptr || item.Status == ITEM_INVISIBLE) + return Geometry::TranslatePoint(item.Pose.Position, item.Pose.Orientation, relOffset); + // Use matrices done in renderer to transform relative offset. return Vector3i(g_Renderer.GetMoveableBonePosition(item.Index, jointIndex, relOffset.ToVector3())); } @@ -711,6 +723,10 @@ Vector3i GetJointPosition(const ItemInfo& item, const CreatureBiteInfo& bite) Vector3 GetJointOffset(GAME_OBJECT_ID objectID, int jointIndex) { const auto& object = Objects[objectID]; + int boneIndex = object.boneIndex + (jointIndex * 4); + + if (g_Level.Bones.size() <= boneIndex) + return Vector3::Zero; int* bonePtr = &g_Level.Bones[object.boneIndex + (jointIndex * 4)]; return Vector3(*(bonePtr + 1), *(bonePtr + 2), *(bonePtr + 3)); diff --git a/TombEngine/Game/camera.cpp b/TombEngine/Game/camera.cpp index 3fe1ef9f7..b6095f8f1 100644 --- a/TombEngine/Game/camera.cpp +++ b/TombEngine/Game/camera.cpp @@ -22,6 +22,7 @@ #include "Sound/sound.h" #include "Specific/Input/Input.h" #include "Specific/level.h" +#include "Specific/trutils.h" #include "Specific/winmain.h" using namespace TEN::Collision::Point; @@ -93,7 +94,7 @@ void DoThumbstickCamera() if (Camera.laraNode == -1 && Camera.target.ToVector3i() == OldCam.target) { - const auto& axisCoeff = AxisMap[(int)InputAxis::Camera]; + const auto& axisCoeff = AxisMap[InputAxisID::Camera]; if (abs(axisCoeff.x) > EPSILON && abs(Camera.targetAngle) == 0) Camera.targetAngle = ANGLE(VERTICAL_CONSTRAINT_ANGLE * axisCoeff.x); @@ -1392,7 +1393,7 @@ static std::vector FillCollideableItemList() { const auto& item = g_Level.Items[i]; - if (std::find(roomList.begin(), roomList.end(), item.RoomNumber) == roomList.end()) + if (!TEN::Utils::Contains(roomList, (int)item.RoomNumber)) continue; if (!g_Level.Rooms[item.RoomNumber].Active()) diff --git a/TombEngine/Game/collision/collide_item.cpp b/TombEngine/Game/collision/collide_item.cpp index e7a35887b..7ea0b5e1e 100644 --- a/TombEngine/Game/collision/collide_item.cpp +++ b/TombEngine/Game/collision/collide_item.cpp @@ -946,6 +946,10 @@ void CollideSolidStatics(ItemInfo* item, CollisionInfo* coll) if (!(mesh.flags & StaticMeshFlags::SM_VISIBLE)) continue; + // Bypass static meshes which are marked as non-collidable. + if (!(mesh.flags & StaticMeshFlags::SM_COLLISION)) + continue; + // Only process meshes which are solid, or if solid mode is set by the setup. if (!coll->Setup.ForceSolidStatics && !(mesh.flags & StaticMeshFlags::SM_SOLID)) continue; @@ -1895,9 +1899,14 @@ void DoObjectCollision(ItemInfo* item, CollisionInfo* coll) for (auto& staticObject : neighborRoom.mesh) { + // Check if static is visible. if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE)) continue; + // Check if static is collidable. + if (!(staticObject.flags & StaticMeshFlags::SM_COLLISION)) + continue; + // For Lara, solid static mesh collisions are directly managed by GetCollisionInfo, // so we bypass them here to avoid interference. if (isPlayer && (staticObject.flags & StaticMeshFlags::SM_SOLID)) diff --git a/TombEngine/Game/control/box.cpp b/TombEngine/Game/control/box.cpp index b60256557..763dfec8b 100644 --- a/TombEngine/Game/control/box.cpp +++ b/TombEngine/Game/control/box.cpp @@ -1150,6 +1150,7 @@ bool StalkBox(ItemInfo* item, ItemInfo* enemy, int boxNumber) { if (enemy == nullptr || boxNumber == NO_VALUE) return false; + auto* box = &g_Level.PathfindingBoxes[boxNumber]; int xRange = STALK_DIST + ((box->bottom - box->top) * BLOCK(1)); @@ -1635,8 +1636,11 @@ void CreatureMood(ItemInfo* item, AI_INFO* AI, bool isViolent) auto* LOT = &creature->LOT; auto* enemy = creature->Enemy; - if (enemy == nullptr) - return; + + // HACK: Fallback to bored mood from attack mood if enemy was cleared. + // Replaces previous "fix" with early exit, because it was breaking friendly NPC pathfinding. -- Lwmte, 24.03.25 + if (enemy == nullptr && creature->Mood == MoodType::Attack) + creature->Mood = MoodType::Bored; int boxNumber; switch (creature->Mood) @@ -1645,7 +1649,7 @@ void CreatureMood(ItemInfo* item, AI_INFO* AI, bool isViolent) boxNumber = LOT->Node[GetRandomControl() * LOT->ZoneCount >> 15].boxNumber; if (ValidBox(item, AI->zoneNumber, boxNumber)) { - if (StalkBox(item, enemy, boxNumber) && enemy->HitPoints > 0 && creature->Enemy) + if (StalkBox(item, enemy, boxNumber) && creature->Enemy && enemy->HitPoints > 0) { TargetBox(LOT, boxNumber); creature->Mood = MoodType::Bored; diff --git a/TombEngine/Game/control/control.cpp b/TombEngine/Game/control/control.cpp index bea185269..9fa8dffd6 100644 --- a/TombEngine/Game/control/control.cpp +++ b/TombEngine/Game/control/control.cpp @@ -41,6 +41,7 @@ #include "Math/Math.h" #include "Objects/Effects/LensFlare.h" #include "Objects/Effects/tr4_locusts.h" +#include "Objects/Effects/Fireflies.h" #include "Objects/Generic/Object/objects.h" #include "Objects/Generic/Object/rope.h" #include "Objects/Generic/Switches/generic_switch.h" @@ -55,11 +56,13 @@ #include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h" #include "Scripting/Include/ScriptInterfaceGame.h" #include "Scripting/Include/Strings/ScriptInterfaceStringsHandler.h" +#include "Scripting/Internal/TEN/Flow/Level/FlowLevel.h" #include "Sound/sound.h" #include "Specific/clock.h" #include "Specific/Input/Input.h" #include "Specific/level.h" #include "Specific/winmain.h" +#include "Specific/Video/Video.h" using namespace std::chrono; using namespace TEN::Effects; @@ -90,6 +93,8 @@ using namespace TEN::Math; using namespace TEN::Renderer; using namespace TEN::Entities::Creatures::TR3; using namespace TEN::Entities::Effects; +using namespace TEN::Effects::Fireflies; +using namespace TEN::Video; constexpr auto DEATH_NO_INPUT_TIMEOUT = 10 * FPS; constexpr auto DEATH_INPUT_TIMEOUT = 3 * FPS; @@ -198,6 +203,7 @@ GameStatus GamePhase(bool insideMenu) UpdateBlood(); UpdateBubbles(); UpdateDebris(); + UpdateGunFlashes(); UpdateGunShells(); UpdateFootprints(); UpdateSplashes(); @@ -217,6 +223,7 @@ GameStatus GamePhase(bool insideMenu) UpdateLocusts(); UpdateUnderwaterBloodParticles(); UpdateFishSwarm(); + UpdateFireflySwarm(); UpdateGlobalLensFlare(); // Update HUD. @@ -224,7 +231,7 @@ GameStatus GamePhase(bool insideMenu) UpdateFadeScreenAndCinematicBars(); // Rumble screen (like in submarine level of TRC). - if (g_GameFlow->GetLevel(CurrentLevel)->Rumble) + if (g_GameFlow->GetLevel(CurrentLevel)->GetRumbleEnabled()) RumbleScreen(); DoFlipEffect(FlipEffect, LaraItem); @@ -358,18 +365,21 @@ unsigned CALLBACK GameMain(void *) TimeInit(); // Do fixed-time title image. - if (g_GameFlow->IntroImagePath.empty()) - { - TENLog("Intro image path not set.", LogLevel::Warning); - } - else - { + if (!g_GameFlow->IntroImagePath.empty()) g_Renderer.RenderTitleImage(); + + // Play intro video. + if (!g_GameFlow->IntroVideoPath.empty()) + { + g_VideoPlayer.Play(g_GameFlow->IntroVideoPath); + while (DoTheGame && g_VideoPlayer.Update()); } // Execute Lua gameflow and play game. g_GameFlow->DoFlow(); - + + // Exit game. + DeInitialize(); DoTheGame = false; // Finish thread. @@ -395,6 +405,7 @@ GameStatus DoLevel(int levelIndex, bool loadGame) InitializeCamera(); InitializeSpotCamSequences(isTitle); InitializeItemBoxData(); + InitializeSpecialEffects(); // Initialize scripting. InitializeScripting(levelIndex, loadGame); @@ -491,6 +502,25 @@ int GetRandomDraw() return Random::GenerateInt(); } +void DeInitialize() +{ + g_VideoPlayer.DeInitialize(); + Sound_DeInit(); + DeinitializeInput(); + + delete g_GameScript; + g_GameScript = nullptr; + + delete g_GameFlow; + g_GameFlow = nullptr; + + delete g_GameScriptEntities; + g_GameScriptEntities = nullptr; + + delete g_GameStringsHandler; + g_GameStringsHandler = nullptr; +} + void CleanUp() { // Reset oscillator seed. @@ -592,9 +622,14 @@ void InitializeScripting(int levelIndex, bool loadGame) void DeInitializeScripting(int levelIndex, GameStatus reason) { + // Reload gameflow script to clear level script variables. + if (reason != GameStatus::ExitGame) + g_GameFlow->LoadFlowScript(); + g_GameScript->FreeLevelScripts(); g_GameScriptEntities->FreeEntities(); + // If level index is 0, it means we are in a title level and game variables should be cleared. if (levelIndex == 0) g_GameScript->ResetScripts(true); } @@ -661,6 +696,9 @@ GameStatus DoGameLoop(int levelIndex) { g_Synchronizer.Sync(); + if (g_VideoPlayer.Update()) + continue; + while (g_Synchronizer.Synced()) { status = ControlPhase(false); @@ -689,7 +727,7 @@ GameStatus DoGameLoop(int levelIndex) } } - EndGameLoop(levelIndex, status); + EndGameLoop(levelIndex, DoTheGame ? status : GameStatus::ExitGame); return status; } @@ -699,9 +737,12 @@ void EndGameLoop(int levelIndex, GameStatus reason) // Save last screenshot for loading screen. g_Renderer.DumpGameScene(); - SaveGame::SaveHub(levelIndex); + if (reason == GameStatus::LevelComplete) + SaveGame::SaveHub(levelIndex); + DeInitializeScripting(levelIndex, reason); + g_VideoPlayer.Stop(); StopAllSounds(); StopSoundTracks(SOUND_XFADETIME_LEVELJUMP, true); StopRumble(); @@ -711,13 +752,20 @@ void SetupInterpolation() { for (auto& item : g_Level.Items) item.DisableInterpolation = false; + + // HACK: Remove after ScriptInterfaceFlowHandler is deprecated. + auto* level = (Level*)g_GameFlow->GetLevel(CurrentLevel); + level->Horizon1.SetPosition(level->Horizon1.GetPosition(), true); + level->Horizon2.SetPosition(level->Horizon2.GetPosition(), true); + level->Horizon1.SetRotation(level->Horizon1.GetRotation(), true); + level->Horizon2.SetRotation(level->Horizon2.GetRotation(), true); } void HandleControls(bool isTitle) { // Poll input devices and update input variables. // TODO: To allow cutscene skipping later, don't clear Deselect action. - UpdateInputActions(LaraItem, true); + UpdateInputActions(false, true); if (isTitle) ClearAction(In::Look); diff --git a/TombEngine/Game/control/control.h b/TombEngine/Game/control/control.h index 742856cf8..ff96daae2 100644 --- a/TombEngine/Game/control/control.h +++ b/TombEngine/Game/control/control.h @@ -96,6 +96,7 @@ void KillMoveEffects(); void UpdateShatters(); void CleanUp(); +void DeInitialize(); void InitializeOrLoadGame(bool loadGame); void InitializeScripting(int levelIndex, bool loadGame); diff --git a/TombEngine/Game/control/flipeffect.cpp b/TombEngine/Game/control/flipeffect.cpp index 080d3fd05..94ee79bb9 100644 --- a/TombEngine/Game/control/flipeffect.cpp +++ b/TombEngine/Game/control/flipeffect.cpp @@ -15,7 +15,9 @@ #include "Game/Lara/lara_helpers.h" #include "Game/pickup/pickup.h" #include "Game/Setup.h" -#include "Objects/Effects/tr4_locusts.h" +#include "Sound/sound.h" +#include "Specific/level.h" +#include "Objects/Effects/Fireflies.h" #include "Objects/Generic/puzzles_keys.h" #include "Objects/TR3/Entity/FishSwarm.h" #include "Objects/TR4/Entity/tr4_beetle_swarm.h" @@ -28,6 +30,7 @@ using namespace TEN::Effects::Environment; using namespace TEN::Effects::Footprint; using namespace TEN::Effects::Hair; using namespace TEN::Entities::Creatures::TR3; +using namespace TEN::Effects::Fireflies; int FlipEffect; @@ -89,6 +92,7 @@ void ClearSwarmEnemies(ItemInfo* item) ClearBeetleSwarm(); ClearLocusts(); ClearFishSwarm(); + ClearFireflySwarm(); } void FlashOrange(ItemInfo* item) diff --git a/TombEngine/Game/control/los.cpp b/TombEngine/Game/control/los.cpp index 861b92bb4..37d371827 100644 --- a/TombEngine/Game/control/los.cpp +++ b/TombEngine/Game/control/los.cpp @@ -261,7 +261,6 @@ bool GetTargetOnLOS(GameVector* origin, GameVector* target, bool drawTarget, boo if (isFiring && Lara.Control.Look.IsUsingLasersight) { Lara.Control.Weapon.HasFired = true; - Lara.Control.Weapon.Fired = true; Lara.RightArm.GunFlash = Weapons[(int)Lara.Control.Weapon.GunType].FlashTime; if (Lara.Control.Weapon.GunType == LaraWeaponType::Revolver) @@ -705,6 +704,10 @@ std::optional GetStaticObjectLos(const Vector3& origin, int roomNumber, if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE)) continue; + // Check if static is collidable. + if (!(staticObject.flags & StaticMeshFlags::SM_COLLISION)) + continue; + // Check if static is solid (if applicable). if (onlySolid && !(staticObject.flags & StaticMeshFlags::SM_SOLID)) continue; diff --git a/TombEngine/Game/debug/debug.cpp b/TombEngine/Game/debug/debug.cpp index 903fd1190..6b1826941 100644 --- a/TombEngine/Game/debug/debug.cpp +++ b/TombEngine/Game/debug/debug.cpp @@ -51,6 +51,10 @@ namespace TEN::Debug } auto logger = spdlog::get("multi_sink"); + + if (!logger) + return; + switch (level) { case LogLevel::Error: diff --git a/TombEngine/Game/effects/Streamer.cpp b/TombEngine/Game/effects/Streamer.cpp index 1b1a1a8e1..b836b2d67 100644 --- a/TombEngine/Game/effects/Streamer.cpp +++ b/TombEngine/Game/effects/Streamer.cpp @@ -73,10 +73,10 @@ namespace TEN::Effects::Streamer } } - Streamer::Streamer(StreamerFeatherType featherType, BlendMode blendMode) + Streamer::Streamer(StreamerFeatherMode featherMode, BlendMode blendMode) { _segmentSpawnTimeOffset = GlobalCounter % SEGMENT_SPAWN_INTERVAL_TIME; - _featherType = featherType; + _featherMode = featherMode; _blendMode = blendMode; } @@ -85,9 +85,9 @@ namespace TEN::Effects::Streamer return _segments; } - StreamerFeatherType Streamer::GetFeatherType() const + StreamerFeatherMode Streamer::GetFeatherMode() const { - return _featherType; + return _featherMode; } BlendMode Streamer::GetBlendMode() const @@ -110,7 +110,7 @@ namespace TEN::Effects::Streamer // Avoid creating "clipped" streamers by clamping max life according to max segment count. int lifeMax = (int)std::min(round(life * FPS), (float)SEGMENT_COUNT_MAX); - float alpha = (float(segmentCount + SEGMENT_SPAWN_INTERVAL_TIME) / (float)lifeMax) * FADE_IN_COEFF; + float alpha = (float(segmentCount * SEGMENT_SPAWN_INTERVAL_TIME) / (float)lifeMax) * FADE_IN_COEFF; float opacityMax = EaseInOutSine(colorEnd.w, colorStart.w, alpha); segment.Orientation = AxisAngle(dir, orient); @@ -165,7 +165,7 @@ namespace TEN::Effects::Streamer void StreamerGroup::AddStreamer(int tag, const Vector3& pos, const Vector3& dir, short orient, const Color& colorStart, const Color& colorEnd, float width, float life, float vel, float expRate, short rot, - StreamerFeatherType featherType, BlendMode blendMode) + StreamerFeatherMode featherMode, BlendMode blendMode) { TENAssert(_pools.size() <= POOL_COUNT_MAX, "Streamer pool count overflow."); @@ -174,7 +174,7 @@ namespace TEN::Effects::Streamer return; // Get and extend streamer iteration. - auto& streamer = GetStreamerIteration(tag, featherType, blendMode); + auto& streamer = GetStreamerIteration(tag, featherMode, blendMode); streamer.Extend(pos, dir, orient, colorStart, colorEnd, width, life, vel, expRate, rot, (unsigned int)streamer.GetSegments().size()); } @@ -202,7 +202,7 @@ namespace TEN::Effects::Streamer return pool; } - Streamer& StreamerGroup::GetStreamerIteration(int tag, StreamerFeatherType featherType, BlendMode blendMode) + Streamer& StreamerGroup::GetStreamerIteration(int tag, StreamerFeatherMode featherMode, BlendMode blendMode) { auto& pool = GetPool(tag); TENAssert(pool.size() <= STREAMER_COUNT_MAX, "Streamer pool size overflow."); @@ -220,7 +220,7 @@ namespace TEN::Effects::Streamer pool.erase(pool.begin()); // Add and return new streamer iteration. - return pool.emplace_back(Streamer(featherType, blendMode)); + return pool.emplace_back(Streamer(featherMode, blendMode)); } void StreamerGroup::ClearInactivePools() @@ -259,7 +259,7 @@ namespace TEN::Effects::Streamer void StreamerEffectController::Spawn(int itemNumber, int tag, const Vector3& pos, const Vector3& dir, short orient, const Color& colorStart, const Color& colorEnd, float width, float life, float vel, float expRate, short rot, - StreamerFeatherType featherType, BlendMode blendMode) + StreamerFeatherMode featherMode, BlendMode blendMode) { TENAssert(_groups.size() <= GROUP_COUNT_MAX, "Streamer group count overflow."); @@ -269,7 +269,7 @@ namespace TEN::Effects::Streamer // Add new or extend existing streamer. auto& group = GetGroup(itemNumber); - group.AddStreamer(tag, pos, dir, orient, colorStart, colorEnd, width, life, vel, expRate, rot, featherType, blendMode); + group.AddStreamer(tag, pos, dir, orient, colorStart, colorEnd, width, life, vel, expRate, rot, featherMode, blendMode); } void StreamerEffectController::Update() diff --git a/TombEngine/Game/effects/Streamer.h b/TombEngine/Game/effects/Streamer.h index 9779da6d6..b2700a6fd 100644 --- a/TombEngine/Game/effects/Streamer.h +++ b/TombEngine/Game/effects/Streamer.h @@ -9,7 +9,7 @@ struct ItemInfo; namespace TEN::Effects::Streamer { - enum class StreamerFeatherType + enum class StreamerFeatherMode { None, Center, @@ -62,7 +62,7 @@ namespace TEN::Effects::Streamer std::vector _segments = {}; int _segmentSpawnTimeOffset = 0; // Time in game frames. - StreamerFeatherType _featherType = StreamerFeatherType::None; + StreamerFeatherMode _featherMode = StreamerFeatherMode::None; BlendMode _blendMode = BlendMode::AlphaBlend; bool _isBroken = false; @@ -70,12 +70,12 @@ namespace TEN::Effects::Streamer public: // Constructors - Streamer(StreamerFeatherType featherType, BlendMode blendMode); + Streamer(StreamerFeatherMode featherMode, BlendMode blendMode); // Getters const std::vector& GetSegments() const; - StreamerFeatherType GetFeatherType() const; + StreamerFeatherMode GetFeatherMode() const; BlendMode GetBlendMode() const; // Inquirers @@ -116,14 +116,14 @@ namespace TEN::Effects::Streamer void AddStreamer(int tag, const Vector3& pos, const Vector3& dir, short orient, const Color& colorStart, const Color& colorEnd, float width, float life, float vel, float expRate, short rot, - StreamerFeatherType featherType, BlendMode blendMode); + StreamerFeatherMode featherMode, BlendMode blendMode); void Update(); private: // Helpers std::vector& GetPool(int tag); - Streamer& GetStreamerIteration(int tag, StreamerFeatherType featherType, BlendMode blendMode); + Streamer& GetStreamerIteration(int tag, StreamerFeatherMode featherMode, BlendMode blendMode); void ClearInactivePools(); void ClearInactiveStreamers(int tag); }; @@ -149,7 +149,7 @@ namespace TEN::Effects::Streamer // TODO: Use seconds. void Spawn(int itemNumber, int tag, const Vector3& pos, const Vector3& dir, short orient, const Color& colorStart, const Color& colorEnd, float width, float life, float vel, float expRate, short rot, - StreamerFeatherType featherType = StreamerFeatherType::None, BlendMode blendMode = BlendMode::AlphaBlend); + StreamerFeatherMode featherMode = StreamerFeatherMode::None, BlendMode blendMode = BlendMode::AlphaBlend); void Update(); void Clear(); diff --git a/TombEngine/Game/effects/effects.cpp b/TombEngine/Game/effects/effects.cpp index ff7625efa..999c8def1 100644 --- a/TombEngine/Game/effects/effects.cpp +++ b/TombEngine/Game/effects/effects.cpp @@ -31,6 +31,7 @@ #include "Sound/sound.h" #include "Specific/clock.h" #include "Specific/level.h" +#include "Specific/trutils.h" using namespace TEN::Collision::Point; using namespace TEN::Effects::Blood; @@ -189,6 +190,86 @@ void SetSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID) particle.SpriteID = (int)round(Lerp(0.0f, spriteCount, normalizedAge)); } +void SetAdvancedSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID, ParticleAnimType animationType, float frameRate) +{ + // Ensure valid lifespan + if (particle.life <= 0) + { + particle.on = false; + ParticleDynamics[particle.dynamic].On = false; + return; + } + + // Calculate particle's age and normalized progress + float particleAge = particle.sLife - particle.life; // Elapsed time since spawn + float normalizedAge = particleAge / particle.sLife; // Progress as a fraction [0.0, 1.0] + + // Retrieve sprite sequence information + //int firstFrame = Objects[objectID].meshIndex; // Starting sprite index + int totalFrames = -Objects[objectID].nmeshes; // Total frames (assuming nmeshes is negative) + if (totalFrames <= 0) + { + particle.SpriteSeqID = objectID; + particle.SpriteID = 0; // Default to the first frame if no valid frames exist + return; + } + + particle.SpriteSeqID = objectID; + + // Handle animation modes + switch (animationType) + { + case ParticleAnimType::Loop: // Frames loop sequentially + { + float frameDuration = frameRate > 0 ? 1.0f / frameRate : 1.0f / totalFrames; // Duration per frame + int currentFrame = (int)(particleAge / frameDuration) % totalFrames; // Wrap frames + particle.SpriteID = currentFrame; + break; + } + + case ParticleAnimType::OneShot: // Frames play once, then freeze on the last frame + { + float totalDuration = frameRate > 0 ? totalFrames / frameRate : particle.sLife; + int currentFrame = (int)(particleAge / (totalDuration / totalFrames)); + if (currentFrame >= totalFrames) + currentFrame = totalFrames - 1; // Clamp to the last frame + particle.SpriteID = currentFrame; + break; + } + + case ParticleAnimType::BackAndForth: // Frames go forward and then backward + { + float frameDuration = frameRate > 0 ? 1.0f / frameRate : 1.0f / totalFrames; + int totalFrameSteps = totalFrames * 2 - 2; // Forward and backward frames (avoiding double-count of last frame) + int step = (int)(particleAge / frameDuration) % totalFrameSteps; + int currentFrame = step < totalFrames ? step : totalFrames - (step - totalFrames) - 1; + particle.SpriteID = currentFrame; + break; + } + + case ParticleAnimType::LifetimeSpread: // Distribute all frames evenly over lifetime + { + int currentFrame = (int)(normalizedAge * totalFrames); + if (currentFrame >= totalFrames) + currentFrame = totalFrames - 1; // Clamp to the last frame + particle.SpriteID = currentFrame; + break; + } + + case ParticleAnimType::None: // Distribute all frames evenly over lifetime + { + particle.SpriteID = 0; + break; + } + + + default: // Default behavior: keep the first frame + particle.SpriteID = 0; + break; + } +} + + void UpdateWibble() { // Update oscillator seed. @@ -352,8 +433,56 @@ void UpdateSparks() if (spark.flags & SP_EXPLOSION) SetSpriteSequence(spark, ID_EXPLOSION_SPRITES); + + if (spark.flags & SP_ANIMATED) + { + ParticleAnimType animationType = static_cast(spark.animationType); + GAME_OBJECT_ID spriteObject = static_cast(spark.SpriteSeqID); + SetAdvancedSpriteSequence(spark, spriteObject, animationType, spark.framerate); + } + + if (spark.flags & SP_SOUND) + SoundEffect(spark.sound, &Pose(Vector3(spark.x, spark.y, spark.z)), SoundEnvironment::Always); + + if (spark.flags & SP_LIGHT) + { + float radius = spark.lightRadius * spark.size / spark.sSize; + // Decrease flicker timer if set + if (spark.lightFlicker > 0) + { + spark.lightFlicker--; + + if (spark.lightFlicker <= 0) + { + // Apply random flicker effect + int random = GetRandomControl(); + int colorOffset = (random % 21) - 10; // Random change between -10 and +10 + + byte r = std::clamp(spark.r + colorOffset, 0, 255); + byte g = std::clamp(spark.g + colorOffset, 0, 255); + byte b = std::clamp(spark.b + colorOffset, 0, 255); + + // Reset flicker timer + spark.lightFlicker = spark.lightFlickerS; + + // Emit flickering light + SpawnDynamicPointLight(Vector3(spark.x, spark.y, spark.z), ScriptColor(r, g, b), radius, false, GetHash(std::string())); + } + else + { + // Normal light emission while flicker is counting down + SpawnDynamicPointLight(Vector3(spark.x, spark.y, spark.z), ScriptColor(spark.r, spark.g, spark.b), radius, false, GetHash(std::string())); + } + } + else + { + // If flicker is disabled or 0, just emit normal light + SpawnDynamicPointLight(Vector3(spark.x, spark.y, spark.z), ScriptColor(spark.r, spark.g, spark.b), radius, false, GetHash(std::string())); + } + } + if ((spark.flags & SP_FIRE && LaraItem->Effect.Type == EffectType::None) || - (spark.flags & SP_DAMAGE) || + (spark.flags & SP_DAMAGE) || (spark.flags & SP_POISON)) { int ds = spark.size * (spark.scalar / 2.0); @@ -368,10 +497,10 @@ void UpdateSparks() ItemBurn(LaraItem); if (spark.flags & SP_DAMAGE) - DoDamage(LaraItem, 2); + DoDamage(LaraItem, spark.damage); if (spark.flags & SP_POISON) - Lara.Status.Poison += 5; + Lara.Status.Poison += spark.damage; } } } diff --git a/TombEngine/Game/effects/effects.h b/TombEngine/Game/effects/effects.h index b1c659781..e36464c41 100644 --- a/TombEngine/Game/effects/effects.h +++ b/TombEngine/Game/effects/effects.h @@ -41,7 +41,19 @@ enum SpriteEnumFlag SP_NODEATTACH = (1 << 12), SP_PLASMAEXP = (1 << 13), SP_POISON = (1 << 14), - SP_COLOR = (1 << 15) + SP_COLOR = (1 << 15), + SP_ANIMATED = (1 << 16), + SP_LIGHT = (1 << 17), + SP_SOUND = (1 << 18) +}; + +enum ParticleAnimType +{ + None, + OneShot, + Loop, + BackAndForth, + LifetimeSpread }; // Used by Particle.nodeNumber. @@ -130,8 +142,8 @@ struct Particle short rotAdd; // TODO: Due to legacy conventions, assigned values must be shifted >> 4. short gravity; - unsigned short flags; // SP_enum - + unsigned int flags; // SP_enum + float sSize; float dSize; float size; @@ -160,6 +172,16 @@ struct Particle unsigned char extras; signed char dynamic; unsigned char nodeNumber; // ParticleNodeOffsetIDs enum. + + int damage; + float framerate; + ParticleAnimType animationType; + + int lightRadius; + int lightFlicker; + int lightFlickerS; + + int sound; int PrevX; int PrevY; @@ -248,6 +270,7 @@ void ClearInactiveEffects(std::vector& effects) Particle* GetFreeParticle(); void SetSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID); +void SetAdvancedSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID, ParticleAnimType animationType, float frameRate); void DetatchSpark(int num, SpriteEnumFlag type); void UpdateSparks(); diff --git a/TombEngine/Game/effects/tomb4fx.cpp b/TombEngine/Game/effects/tomb4fx.cpp index 2b5834296..d2960a410 100644 --- a/TombEngine/Game/effects/tomb4fx.cpp +++ b/TombEngine/Game/effects/tomb4fx.cpp @@ -353,6 +353,7 @@ void ThrowPoison(const ItemInfo& item, int boneID, const Vector3& offset, const auto& part = SetupPoisonParticle(colorStart, colorEnd); AttachAndCreateSpark(&part, &item, boneID, offset, vel, spriteID); part.flags = SP_POISON | SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF; + part.damage = 5; } } @@ -803,6 +804,55 @@ void TriggerGunShell(short hand, short objNum, LaraWeaponType weaponType) } } +void UpdateGunFlashes() +{ + if (Lara.Control.Weapon.GunType == LaraWeaponType::None) + return; + + const auto& settings = g_GameFlow->GetSettings()->Weapons[(int)Lara.Control.Weapon.GunType - 1]; + + if (!settings.MuzzleGlow) + return; + + for (int hand = 0; hand < 2; hand++) + { + if ((hand ? Lara.RightArm.GunFlash : Lara.LeftArm.GunFlash) == 0) + continue; + + auto& part = *GetFreeParticle(); + + part.on = true; + part.SpriteSeqID = ID_DEFAULT_SPRITES; + part.SpriteID = 11; + part.blendMode = BlendMode::Additive; + + auto pos = GetJointPosition(LaraItem, hand ? LM_RHAND : LM_LHAND, settings.MuzzleOffset.ToVector3i()); + part.x = pos.x; + part.y = pos.y; + part.z = pos.z; + part.roomNumber = LaraItem->RoomNumber; + + part.rotAng = ANGLE(TO_DEGREES(Random::GenerateAngle())) >> 4; + part.rotAdd = 0; + + part.sSize = part.size = part.dSize = 192; + part.scalar = 2; + + part.xVel = part.yVel = part.zVel = 0; + part.gravity = part.friction = part.maxYvel = 0; + + part.sR = part.dR = settings.FlashColor.GetR() / 2; + part.sG = part.dG = settings.FlashColor.GetG() / 2; + part.sB = part.dB = settings.FlashColor.GetB() / 2; + + part.life = part.sLife = 2; + part.colFadeSpeed = 1; + part.fadeToBlack = 1; + + part.flags = SP_SCALE | SP_DEF | SP_EXPDEF; + } +} + void UpdateGunShells() { for (int i = 0; i < MAX_GUNSHELL; i++) diff --git a/TombEngine/Game/effects/tomb4fx.h b/TombEngine/Game/effects/tomb4fx.h index 169989aca..d7f360473 100644 --- a/TombEngine/Game/effects/tomb4fx.h +++ b/TombEngine/Game/effects/tomb4fx.h @@ -241,6 +241,7 @@ void TriggerGunSmoke(int x, int y, int z, short xv, short yv, short zv, byte ini void TriggerShatterSmoke(int x, int y, int z); int GetFreeGunshell(); void TriggerGunShell(short hand, short objNum, LaraWeaponType weaponType); +void UpdateGunFlashes(); void UpdateGunShells(); void AddWaterSparks(int x, int y, int z, int num); void ExplodingDeath(short itemNumber, short flags); // BODY_ flags diff --git a/TombEngine/Game/effects/weather.cpp b/TombEngine/Game/effects/weather.cpp index fae652147..0c3f184f7 100644 --- a/TombEngine/Game/effects/weather.cpp +++ b/TombEngine/Game/effects/weather.cpp @@ -9,7 +9,7 @@ #include "Game/effects/tomb4fx.h" #include "Game/savegame.h" #include "Game/Setup.h" -#include "Math.h" +#include "Math/Math.h" #include "Objects/game_object_ids.h" #include "Sound/sound.h" #include "Scripting/Include/ScriptInterfaceLevel.h" @@ -19,7 +19,7 @@ using namespace TEN::Collision::Point; using namespace TEN::Effects::Ripple; using namespace TEN::Math; -namespace TEN::Effects::Environment +namespace TEN::Effects::Environment { EnvironmentController Weather; @@ -232,52 +232,65 @@ namespace TEN::Effects::Environment void EnvironmentController::UpdateStarfield(const ScriptInterfaceLevel& level) { - if (!level.GetStarfieldStarsEnabled()) + int starCount = level.GetStarfieldStarCount(); + if (starCount == 0) return; if (ResetStarField) { - int starCount = level.GetStarfieldStarCount(); - Stars.clear(); - Stars.reserve(starCount); + ResetStarField = false; + } - for (int i = 0; i < starCount; i++) + if (starCount != Stars.size()) + { + // If starCount increased, add new stars to existing list. + if (starCount > Stars.size()) { - auto starDir = Random::GenerateDirectionInCone(-Vector3::UnitY, 70.0f); - starDir.Normalize(); + // Reserve space for new stars if necessary. + Stars.reserve(starCount); - auto star = StarParticle{}; - star.Direction = starDir; - star.Color = Vector3( - Random::GenerateFloat(0.6f, 1.0f), - Random::GenerateFloat(0.6f, 1.0f), - Random::GenerateFloat(0.6f, 1.0f)); - star.Scale = Random::GenerateFloat(0.5f, 1.5f); - - float cosine = Vector3::UnitY.Dot(starDir); - float maxCosine = cos(DEG_TO_RAD(50.0f)); - float minCosine = cos(DEG_TO_RAD(70.0f)); - - if (cosine >= minCosine && cosine <= maxCosine) + for (int i = (int)Stars.size(); i < starCount; i++) { - star.Extinction = (cosine - minCosine) / (maxCosine - minCosine); - } - else - { - star.Extinction = 1.0f; - } + auto starDir = Random::GenerateDirectionInCone(-Vector3::UnitY, 70.0f); + starDir.Normalize(); - Stars.push_back(star); + auto star = StarParticle{}; + star.Direction = starDir; + star.Color = Vector3( + Random::GenerateFloat(0.6f, 1.0f), + Random::GenerateFloat(0.6f, 1.0f), + Random::GenerateFloat(0.6f, 1.0f)); + star.Scale = Random::GenerateFloat(0.5f, 1.5f); + + float cosine = Vector3::UnitY.Dot(starDir); + float maxCosine = cos(DEG_TO_RAD(50.0f)); + float minCosine = cos(DEG_TO_RAD(70.0f)); + + if (cosine >= minCosine && cosine <= maxCosine) + { + star.Extinction = (cosine - minCosine) / (maxCosine - minCosine); + } + else + { + star.Extinction = 1.0f; + } + + Stars.push_back(star); + } + } + // If starCount decreased, resize vector without reinitializing. + else + { + Stars.resize(starCount); } - ResetStarField = false; } for (auto& star : Stars) star.Blinking = Random::GenerateFloat(0.5f, 1.0f); - if (level.GetStarfieldMeteorsEnabled()) + if (level.GetStarfieldMeteorCount() > 0) { for (auto& meteor : Meteors) { @@ -513,7 +526,7 @@ namespace TEN::Effects::Environment if (!IsPointInRoom(pos, roomNumber)) roomNumber = FindRoomNumber(pos, Camera.pos.RoomNumber, true); - if (roomNumber == NO_VALUE) + if (!IsPointInRoom(pos, roomNumber) || roomNumber == NO_VALUE) continue; // Check if water room. @@ -639,7 +652,7 @@ namespace TEN::Effects::Environment Meteors.end()); } - if (!level.GetStarfieldMeteorsEnabled()) + if (level.GetStarfieldMeteorCount() == 0) return; int density = level.GetStarfieldMeteorSpawnDensity(); diff --git a/TombEngine/Game/effects/weather.h b/TombEngine/Game/effects/weather.h index ad06bbc9b..b112554ff 100644 --- a/TombEngine/Game/effects/weather.h +++ b/TombEngine/Game/effects/weather.h @@ -1,6 +1,7 @@ #pragma once -#include "Math/Math.h" + #include "Objects/Effects/LensFlare.h" +#include "Objects/game_object_ids.h" #include "Scripting/Include/ScriptInterfaceLevel.h" using namespace TEN::Entities::Effects; @@ -100,6 +101,48 @@ namespace TEN::Effects::Environment class EnvironmentController { + private: + // Weather + + std::vector Particles = {}; + + // Sky + + Vector4 SkyCurrentColor[2] = {}; + short SkyCurrentPosition[2] = {}; + + // Wind + + int WindX = 0; + int WindZ = 0; + int WindAngle = 0; + int WindDAngle = 0; + int WindCurrent = 0; + + // Flash fader + + Vector3 FlashColorBase = Vector3::Zero; + float FlashSpeed = 1.0f; + float FlashProgress = 0.0f; + + // Lightning + + int StormCount = 0; + int StormRand = 0; + int StormTimer = 0; + byte StormSkyColor = 1; + byte StormSkyColor2 = 1; + + // Starfield + + std::vector Stars = {}; + std::vector Meteors = {}; + bool ResetStarField = true; + + // Lens flare + + LensFlare GlobalLensFlare = {}; + public: EnvironmentController(); @@ -117,47 +160,13 @@ namespace TEN::Effects::Environment const std::vector& GetMeteors() const { return Meteors; } private: - // Weather - std::vector Particles = {}; - - // Sky - Vector4 SkyCurrentColor[2] = {}; - short SkyCurrentPosition[2] = {}; - - // Wind - int WindX = 0; - int WindZ = 0; - int WindAngle = 0; - int WindDAngle = 0; - int WindCurrent = 0; - - // Flash fader - Vector3 FlashColorBase = Vector3::Zero; - float FlashSpeed = 1.0f; - float FlashProgress = 0.0f; - - // Lightning - int StormCount = 0; - int StormRand = 0; - int StormTimer = 0; - byte StormSkyColor = 1; - byte StormSkyColor2 = 1; - - // Starfield - std::vector Stars = {}; - std::vector Meteors = {}; - bool ResetStarField = true; - - // Lens flare - LensFlare GlobalLensFlare = {}; - - void UpdateStarfield(const ScriptInterfaceLevel& level); + void UpdateWeather(const ScriptInterfaceLevel& level); void UpdateSky(const ScriptInterfaceLevel& level); - void UpdateStorm(const ScriptInterfaceLevel& level); void UpdateWind(const ScriptInterfaceLevel& level); void UpdateFlash(const ScriptInterfaceLevel& level); - void UpdateWeather(const ScriptInterfaceLevel& level); void UpdateLightning(); + void UpdateStarfield(const ScriptInterfaceLevel& level); + void UpdateStorm(const ScriptInterfaceLevel& level); void SpawnDustParticles(const ScriptInterfaceLevel& level); void SpawnWeatherParticles(const ScriptInterfaceLevel& level); diff --git a/TombEngine/Game/gui.cpp b/TombEngine/Game/gui.cpp index 66ac2e759..9d0377ab5 100644 --- a/TombEngine/Game/gui.cpp +++ b/TombEngine/Game/gui.cpp @@ -23,17 +23,18 @@ #include "Scripting/Include/ScriptInterfaceLevel.h" #include "Sound/sound.h" #include "Specific/Input/Input.h" -#include "Specific/Input/InputAction.h" #include "Specific/clock.h" #include "Specific/configuration.h" #include "Specific/level.h" #include "Specific/trutils.h" +#include "Specific/Video/Video.h" #include "Specific/winmain.h" using namespace TEN::Effects::DisplaySprite; using namespace TEN::Input; using namespace TEN::Renderer; using namespace TEN::Utils; +using namespace TEN::Video; namespace TEN::Gui { @@ -124,7 +125,7 @@ namespace TEN::Gui STRING_ACTIONS_LOAD }; - bool GuiController::GuiIsPulsed(ActionID actionID) const + bool GuiController::GuiIsPulsed(InputActionID actionID) const { constexpr auto DELAY = 0.1f; constexpr auto INITIAL_DELAY = 0.4f; @@ -134,7 +135,7 @@ namespace TEN::Gui return false; // Pulse only directional inputs. - auto oppositeAction = std::optional(std::nullopt); + auto oppositeAction = std::optional(std::nullopt); switch (actionID) { case In::Forward: @@ -239,7 +240,7 @@ namespace TEN::Gui { if (mode != InvMode) { - TimeInMenu = 0.0f; + TimeInMenu = 0; InvMode = mode; } } @@ -617,12 +618,16 @@ namespace TEN::Gui { // Save the configuration. auto screenResolution = g_Configuration.SupportedScreenResolutions[CurrentSettings.SelectedScreenResolution]; + + bool screenResolutionChanged = CurrentSettings.Configuration.ScreenWidth != screenResolution.x || + CurrentSettings.Configuration.ScreenHeight != screenResolution.y; + CurrentSettings.Configuration.ScreenWidth = screenResolution.x; CurrentSettings.Configuration.ScreenHeight = screenResolution.y; // Determine whether we should update AA shaders. - bool shouldRecompileAAShaders = g_Configuration.AntialiasingMode != CurrentSettings.Configuration.AntialiasingMode && - CurrentSettings.Configuration.AntialiasingMode != AntialiasingMode::Low; + bool shouldRecompileAAShaders = CurrentSettings.Configuration.AntialiasingMode != AntialiasingMode::Low && + (screenResolutionChanged || g_Configuration.AntialiasingMode != CurrentSettings.Configuration.AntialiasingMode); g_Configuration = CurrentSettings.Configuration; SaveConfiguration(); @@ -687,7 +692,7 @@ namespace TEN::Gui CurrentSettings.IgnoreInput = true; } - if (CurrentSettings.NewKeyWaitTimer > 0.0f) + if (CurrentSettings.NewKeyWaitTimer > 0) { ClearAllActions(); @@ -696,15 +701,15 @@ namespace TEN::Gui bool legacy30FpsDoneDraw = false; bool decreaseCounter = false; - while (CurrentSettings.NewKeyWaitTimer > 0.0f) + while (CurrentSettings.NewKeyWaitTimer > 0) { g_Synchronizer.Sync(); while (g_Synchronizer.Synced()) { - CurrentSettings.NewKeyWaitTimer -= 1.0f; - if (CurrentSettings.NewKeyWaitTimer <= 0.0f) - CurrentSettings.NewKeyWaitTimer = 0.0f; + CurrentSettings.NewKeyWaitTimer--; + if (CurrentSettings.NewKeyWaitTimer <= 0) + CurrentSettings.NewKeyWaitTimer = 0; if (!fromPauseMenu) { @@ -713,7 +718,7 @@ namespace TEN::Gui else { g_Renderer.PrepareScene(); // Just for updating blink time. - UpdateInputActions(item); + UpdateInputActions(); } if (CurrentSettings.IgnoreInput) @@ -723,17 +728,17 @@ namespace TEN::Gui } else { - int selectedKey = 0; - for (selectedKey = 0; selectedKey < MAX_INPUT_SLOTS; selectedKey++) + int selectedKeyID = 0; + for (selectedKeyID = 0; selectedKeyID < KEY_COUNT; selectedKeyID++) { - if (KeyMap[selectedKey]) + if (KeyMap[selectedKeyID]) break; } - if (selectedKey == MAX_INPUT_SLOTS) - selectedKey = 0; + if (selectedKeyID == KEY_COUNT) + selectedKeyID = 0; - if (selectedKey && !g_KeyNames[selectedKey].empty()) + if (selectedKeyID && !GetKeyName(selectedKeyID).empty()) { unsigned int baseIndex = 0; switch (MenuToDisplay) @@ -754,10 +759,10 @@ namespace TEN::Gui break; } - Bindings[1][baseIndex + SelectedOption] = selectedKey; + g_Bindings.SetKeyBinding(InputDeviceID::Custom, InputActionID(baseIndex + SelectedOption), selectedKeyID); DefaultConflict(); - CurrentSettings.NewKeyWaitTimer = 0.0f; + CurrentSettings.NewKeyWaitTimer = 0; CurrentSettings.IgnoreInput = true; return; } @@ -847,6 +852,7 @@ namespace TEN::Gui if (SelectedOption == (OptionCount - 2)) { SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); + ApplyDefaultBindings(); return; } @@ -855,9 +861,11 @@ namespace TEN::Gui if (SelectedOption == (OptionCount - 1)) { SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); - CurrentSettings.Configuration.Bindings = Bindings[1]; - g_Configuration.Bindings = Bindings[1]; + + CurrentSettings.Configuration.Bindings = g_Bindings.GetBindingProfile(InputDeviceID::Custom); + g_Configuration.Bindings = g_Bindings.GetBindingProfile(InputDeviceID::Custom); SaveConfiguration(); + MenuToDisplay = fromPauseMenu ? Menu::Pause : Menu::Options; SelectedOption = 2; return; @@ -867,7 +875,9 @@ namespace TEN::Gui if (SelectedOption == OptionCount) { SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); - Bindings[1] = CurrentSettings.Configuration.Bindings; + + g_Bindings.SetBindingProfile(InputDeviceID::Custom, CurrentSettings.Configuration.Bindings); + MenuToDisplay = fromPauseMenu ? Menu::Pause : Menu::Options; SelectedOption = 2; return; @@ -878,6 +888,8 @@ namespace TEN::Gui { SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); + g_Bindings.SetBindingProfile(InputDeviceID::Custom, CurrentSettings.Configuration.Bindings); + MenuToDisplay = Menu::Options; SelectedOption = 2; } @@ -1147,7 +1159,7 @@ namespace TEN::Gui static const int numOptionsOptions = 2; TimeInMenu++; - UpdateInputActions(item); + UpdateInputActions(); switch (MenuToDisplay) { @@ -2190,7 +2202,7 @@ namespace TEN::Gui { // HACK. ClearAllActions(); - ActionMap[(int)In::Flare].Update(1.0f); + ActionMap[In::Flare].Update(1.0f); HandleWeapon(item); ClearAllActions(); @@ -2234,6 +2246,7 @@ namespace TEN::Gui item.HitPoints = LARA_HEALTH_MAX; SoundEffect(SFX_TR4_MENU_MEDI, nullptr, SoundEnvironment::Always); + SaveGame::Statistics.Level.HealthUsed++; SaveGame::Statistics.Game.HealthUsed++; } else @@ -2260,6 +2273,7 @@ namespace TEN::Gui item.HitPoints = LARA_HEALTH_MAX; SoundEffect(SFX_TR4_MENU_MEDI, nullptr, SoundEnvironment::Always); + SaveGame::Statistics.Level.HealthUsed++; SaveGame::Statistics.Game.HealthUsed++; } else @@ -3173,6 +3187,7 @@ namespace TEN::Gui bool GuiController::CallPause() { g_Renderer.DumpGameScene(SceneRenderMode::NoHud); + g_VideoPlayer.Pause(); PauseAllSounds(SoundPauseMode::Pause); SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); @@ -3237,6 +3252,7 @@ namespace TEN::Gui } else { + g_VideoPlayer.Resume(); ResumeAllSounds(SoundPauseMode::Pause); } @@ -3254,6 +3270,7 @@ namespace TEN::Gui player.Inventory.OldBusy = player.Inventory.IsBusy; g_Renderer.DumpGameScene(SceneRenderMode::NoHud); + g_VideoPlayer.Pause(); PauseAllSounds(SoundPauseMode::Inventory); SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always); @@ -3284,7 +3301,7 @@ namespace TEN::Gui SaveGame::Statistics.Game.TimeTaken++; SaveGame::Statistics.Level.TimeTaken++; - UpdateInputActions(item); + UpdateInputActions(); if (GuiIsDeselected() || IsClicked(In::Inventory)) { @@ -3375,6 +3392,7 @@ namespace TEN::Gui AlterFOV(LastFOV); g_Renderer.PrepareScene(); + g_VideoPlayer.Resume(); ResumeAllSounds(SoundPauseMode::Inventory); player.Inventory.IsBusy = player.Inventory.OldBusy; diff --git a/TombEngine/Game/gui.h b/TombEngine/Game/gui.h index 70b5754d0..8a04f1e9c 100644 --- a/TombEngine/Game/gui.h +++ b/TombEngine/Game/gui.h @@ -111,16 +111,16 @@ namespace TEN::Gui GameConfiguration Configuration = {}; - int SelectedScreenResolution = 0; - bool IgnoreInput = false; // Ignore input until all actions are inactive. - float NewKeyWaitTimer = 0.0f; + int SelectedScreenResolution = 0; + bool IgnoreInput = false; // Ignore input until all actions are inactive. + int NewKeyWaitTimer = 0; }; class GuiController { private: // Input inquirers - bool GuiIsPulsed(ActionID actionID) const; + bool GuiIsPulsed(InputActionID actionID) const; bool GuiIsSelected(bool onClicked = true) const; bool GuiIsDeselected() const; bool CanSelect() const; @@ -132,7 +132,7 @@ namespace TEN::Gui int OptionCount; int SelectedSaveSlot; - float TimeInMenu = -1.0f; + int TimeInMenu = NO_VALUE; SettingsData CurrentSettings; // Inventory variables diff --git a/TombEngine/Game/pickup/pickup.cpp b/TombEngine/Game/pickup/pickup.cpp index f9e5cf5c2..260cca2a2 100644 --- a/TombEngine/Game/pickup/pickup.cpp +++ b/TombEngine/Game/pickup/pickup.cpp @@ -22,6 +22,7 @@ #include "Game/pickup/pickup_misc_items.h" #include "Game/pickup/pickup_weapon.h" #include "Game/room.h" +#include "Game/savegame.h" #include "Game/Setup.h" #include "Math/Math.h" #include "Objects/Generic/Object/burning_torch.h" @@ -158,6 +159,11 @@ void PickedUpObject(GAME_OBJECT_ID objectID, std::optional count) { // Item isn't any of the above; do nothing. } + else + { + SaveGame::Statistics.Level.Pickups++; + SaveGame::Statistics.Game.Pickups++; + } } void PickedUpObject(ItemInfo& item) @@ -1233,30 +1239,6 @@ void SearchObjectControl(short itemNumber) AnimateItem(item); int frameNumber = item->Animation.FrameNumber - GetAnimData(item).frameBase; - if (item->ObjectNumber == ID_SEARCH_OBJECT1) - { - if (frameNumber > 0) - { - item->SetMeshSwapFlags(NO_JOINT_BITS); - item->MeshBits = ALL_JOINT_BITS; - } - else - { - item->SetMeshSwapFlags(ALL_JOINT_BITS); - item->MeshBits = 7; - } - } - else if (item->ObjectNumber == ID_SEARCH_OBJECT2) - { - if (frameNumber == 18) - { - item->MeshBits = 1; - } - else if (frameNumber == 172) - { - item->MeshBits = 2; - } - } if (frameNumber == SearchCollectFrames[objectNumber]) { diff --git a/TombEngine/Game/room.h b/TombEngine/Game/room.h index eec49f807..a43e2c428 100644 --- a/TombEngine/Game/room.h +++ b/TombEngine/Game/room.h @@ -37,8 +37,9 @@ enum RoomEnvFlags enum StaticMeshFlags : short { - SM_VISIBLE = 1, - SM_SOLID = 2 + SM_VISIBLE = (1 << 0), + SM_SOLID = (1 << 1), + SM_COLLISION = (1 << 2) }; struct ROOM_VERTEX diff --git a/TombEngine/Game/savegame.cpp b/TombEngine/Game/savegame.cpp index 6725159cd..941a5e83a 100644 --- a/TombEngine/Game/savegame.cpp +++ b/TombEngine/Game/savegame.cpp @@ -10,8 +10,10 @@ #include "Game/control/flipeffect.h" #include "Game/control/lot.h" #include "Game/control/volume.h" +#include "Objects/Effects/Fireflies.h" #include "Game/effects/item_fx.h" #include "Game/effects/effects.h" +#include "Game/effects/weather.h" #include "Game/items.h" #include "Game/itemdata/creature_info.h" #include "Game/Lara/lara.h" @@ -30,6 +32,7 @@ #include "Objects/TR5/Emitter/tr5_bats_emitter.h" #include "Objects/TR5/Emitter/tr5_spider_emitter.h" #include "Renderer/Renderer.h" +#include "Scripting/Internal/TEN/Flow//Level/FlowLevel.h" #include "Scripting/Include/ScriptInterfaceGame.h" #include "Scripting/Include/ScriptInterfaceLevel.h" #include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h" @@ -37,10 +40,13 @@ #include "Specific/clock.h" #include "Specific/level.h" #include "Specific/savegame/flatbuffers/ten_savegame_generated.h" +#include "Specific/Video/Video.h" using namespace flatbuffers; using namespace TEN::Collision::Floordata; using namespace TEN::Control::Volumes; +using namespace TEN::Effects::Environment; +using namespace TEN::Effects::Fireflies; using namespace TEN::Effects::Items; using namespace TEN::Entities::Creatures::TR3; using namespace TEN::Entities::Generic; @@ -48,6 +54,7 @@ using namespace TEN::Entities::Switches; using namespace TEN::Entities::TR4; using namespace TEN::Gui; using namespace TEN::Renderer; +using namespace TEN::Video; namespace Save = TEN::Save; @@ -271,6 +278,7 @@ const std::vector SaveGame::Build() sgLevelStatisticsBuilder.add_medipacks_used(Statistics.Level.HealthUsed); sgLevelStatisticsBuilder.add_damage_taken(Statistics.Level.DamageTaken); sgLevelStatisticsBuilder.add_distance(Statistics.Level.Distance); + sgLevelStatisticsBuilder.add_pickups(Statistics.Level.Pickups); sgLevelStatisticsBuilder.add_secrets(Statistics.Level.Secrets); sgLevelStatisticsBuilder.add_timer(SaveGame::Statistics.Level.TimeTaken); auto levelStatisticsOffset = sgLevelStatisticsBuilder.Finish(); @@ -282,10 +290,20 @@ const std::vector SaveGame::Build() sgGameStatisticsBuilder.add_medipacks_used(Statistics.Game.HealthUsed); sgGameStatisticsBuilder.add_damage_taken(Statistics.Game.DamageTaken); sgGameStatisticsBuilder.add_distance(Statistics.Game.Distance); + sgGameStatisticsBuilder.add_pickups(Statistics.Game.Pickups); sgGameStatisticsBuilder.add_secrets(Statistics.Game.Secrets); sgGameStatisticsBuilder.add_timer(SaveGame::Statistics.Game.TimeTaken); auto gameStatisticsOffset = sgGameStatisticsBuilder.Finish(); + // Background video playback + auto videoNameOffset = fbb.CreateString(g_VideoPlayer.GetFileName()); + Save::VideoInfoBuilder sgVideoInfoBuilder{ fbb }; + sgVideoInfoBuilder.add_name(videoNameOffset); + sgVideoInfoBuilder.add_position(g_VideoPlayer.GetNormalizedPosition()); + sgVideoInfoBuilder.add_silent(g_VideoPlayer.GetSilent()); + sgVideoInfoBuilder.add_looped(g_VideoPlayer.GetLooped()); + auto videoInfoOffset = sgVideoInfoBuilder.Finish(); + // Lara std::vector puzzles; for (int i = 0; i < NUM_PUZZLES; i++) @@ -465,7 +483,6 @@ const std::vector SaveGame::Build() Save::WeaponControlDataBuilder weaponControl{ fbb }; weaponControl.add_weapon_item(Lara.Control.Weapon.WeaponItem); weaponControl.add_has_fired(Lara.Control.Weapon.HasFired); - weaponControl.add_fired(Lara.Control.Weapon.Fired); weaponControl.add_uzi_left(Lara.Control.Weapon.UziLeft); weaponControl.add_uzi_right(Lara.Control.Weapon.UziRight); weaponControl.add_gun_type((int)Lara.Control.Weapon.GunType); @@ -919,6 +936,38 @@ const std::vector SaveGame::Build() } auto fishSwarmOffset = fbb.CreateVector(fishSwarm); + std::vector> fireflySwarm; + for (const auto& firefly : FireflySwarm) + { + Save::FireflyDataBuilder fireflySave{ fbb }; + fireflySave.add_sprite_index(firefly.SpriteSeqID); + fireflySave.add_sprite_id(firefly.SpriteID); + fireflySave.add_blend_mode((int)firefly.blendMode); + fireflySave.add_scalar(firefly.scalar); + fireflySave.add_position(&FromVector3(firefly.Position)); + fireflySave.add_room_number(firefly.RoomNumber); + fireflySave.add_position_target(&FromVector3(firefly.PositionTarget)); + fireflySave.add_orientation(&FromEulerAngles(firefly.Orientation)); + fireflySave.add_velocity(firefly.Velocity); + fireflySave.add_target_item_number((firefly.TargetItemPtr == nullptr) ? -1 : firefly.TargetItemPtr->Index); + fireflySave.add_z_vel(firefly.zVel); + fireflySave.add_life(firefly.Life); + fireflySave.add_number(firefly.Number); + fireflySave.add_d_r(firefly.rB); + fireflySave.add_d_g(firefly.gB); + fireflySave.add_d_b(firefly.bB); + fireflySave.add_r(firefly.r); + fireflySave.add_g(firefly.g); + fireflySave.add_b(firefly.b); + fireflySave.add_on(firefly.on); + fireflySave.add_size(firefly.size); + fireflySave.add_rot_ang(firefly.rotAng); + + auto fireflySaveOffset = fireflySave.Finish(); + fireflySwarm.push_back(fireflySaveOffset); + } + auto fireflySwarmOffset = fbb.CreateVector(fireflySwarm); + // TODO: In future, we should save only active FX, not whole array. // This may come together with Monty's branch merge -- Lwmte, 10.07.22 @@ -970,8 +1019,8 @@ const std::vector SaveGame::Build() // Action queue std::vector actionQueue; - for (int i = 0; i < ActionQueue.size(); i++) - actionQueue.push_back((int)ActionQueue[i]); + for (int i = 0; i < ActionQueueMap.size(); i++) + actionQueue.push_back((int)ActionQueueMap[(InputActionID)i]); auto actionQueueOffset = fbb.CreateVector(actionQueue); // Flipmaps @@ -1086,6 +1135,54 @@ const std::vector SaveGame::Build() auto staticMeshesOffset = fbb.CreateVector(staticMeshes); auto volumesOffset = fbb.CreateVector(volumes); + // Level state + auto* level = (Level*)g_GameFlow->GetLevel(CurrentLevel); + Save::LevelDataBuilder levelData { fbb }; + + levelData.add_level_far_view(level->LevelFarView); + + levelData.add_fog_color(level->Fog.GetColor()); + levelData.add_fog_min_distance(level->Fog.MinDistance); + levelData.add_fog_max_distance(level->Fog.MaxDistance); + + levelData.add_sky_layer_1_enabled(level->GetSkyLayerEnabled(0)); + levelData.add_sky_layer_1_color(level->GetSkyLayerColor(0)); + levelData.add_sky_layer_1_speed(level->GetSkyLayerSpeed(0)); + + levelData.add_sky_layer_2_enabled(level->GetSkyLayerEnabled(1)); + levelData.add_sky_layer_2_color(level->GetSkyLayerColor(1)); + levelData.add_sky_layer_2_speed(level->GetSkyLayerSpeed(1)); + + levelData.add_lensflare_enabled(level->LensFlare.GetEnabled()); + levelData.add_lensflare_color(level->LensFlare.GetColor()); + levelData.add_lensflare_pitch(level->LensFlare.GetPitch()); + levelData.add_lensflare_yaw(level->LensFlare.GetYaw()); + levelData.add_lensflare_sprite_id(level->LensFlare.GetSunSpriteID()); + + levelData.add_starfield_meteor_count(level->Starfield.GetMeteorCount()); + levelData.add_starfield_meteor_spawn_density(level->Starfield.GetMeteorSpawnDensity()); + levelData.add_starfield_meteor_velocity(level->Starfield.GetMeteorVelocity()); + levelData.add_starfield_star_count(level->Starfield.GetStarCount()); + + levelData.add_horizon1_enabled(level->Horizon1.GetEnabled()); + levelData.add_horizon1_object_id(level->Horizon1.GetObjectID()); + levelData.add_horizon1_position(&FromVector3(level->GetHorizonPosition(0))); + levelData.add_horizon1_orientation(&FromEulerAngles(level->GetHorizonOrientation(0))); + levelData.add_horizon1_transparency(level->Horizon1.GetTransparency()); + + levelData.add_horizon2_enabled(level->Horizon2.GetEnabled()); + levelData.add_horizon2_object_id(level->Horizon2.GetObjectID()); + levelData.add_horizon2_position(&FromVector3(level->GetHorizonPosition(1))); + levelData.add_horizon2_orientation(&FromEulerAngles(level->GetHorizonOrientation(1))); + levelData.add_horizon2_transparency(level->Horizon2.GetTransparency()); + + levelData.add_storm_enabled(level->Storm); + levelData.add_rumble_enabled(level->Rumble); + levelData.add_weather_type((int)level->Weather); + levelData.add_weather_strength(level->WeatherStrength); + + auto levelDataOffset = levelData.Finish(); + // Global event sets std::vector> globalEventSets{}; for (int j = 0; j < g_Level.GlobalEventSets.size(); j++) @@ -1149,11 +1246,13 @@ const std::vector SaveGame::Build() Save::ParticleInfoBuilder particleInfo{ fbb }; + particleInfo.add_animation_type(particle->animationType); particleInfo.add_b(particle->b); particleInfo.add_col_fade_speed(particle->colFadeSpeed); particleInfo.add_d_b(particle->dB); particleInfo.add_sprite_index(particle->SpriteSeqID); particleInfo.add_sprite_id(particle->SpriteID); + particleInfo.add_damage(particle->damage); particleInfo.add_d_g(particle->dG); particleInfo.add_d_r(particle->dR); particleInfo.add_d_size(particle->dSize); @@ -1161,11 +1260,15 @@ const std::vector SaveGame::Build() particleInfo.add_extras(particle->extras); particleInfo.add_fade_to_black(particle->fadeToBlack); particleInfo.add_flags(particle->flags); + particleInfo.add_framerate(particle->framerate); particleInfo.add_friction(particle->friction); particleInfo.add_fx_obj(particle->fxObj); particleInfo.add_g(particle->g); particleInfo.add_gravity(particle->gravity); particleInfo.add_life(particle->life); + particleInfo.add_light_radius(particle->lightRadius); + particleInfo.add_light_flicker(particle->lightFlicker); + particleInfo.add_light_flicker_s(particle->lightFlickerS); particleInfo.add_max_y_vel(particle->maxYvel); particleInfo.add_node_number(particle->nodeNumber); particleInfo.add_on(particle->on); @@ -1180,9 +1283,10 @@ const std::vector SaveGame::Build() particleInfo.add_s_life(particle->sLife); particleInfo.add_s_r(particle->sR); particleInfo.add_s_size(particle->sSize); + particleInfo.add_sound(particle->sound); particleInfo.add_blend_mode((int)particle->blendMode); particleInfo.add_x(particle->x); - particleInfo.add_x_vel(particle->sSize); + particleInfo.add_x_vel(particle->xVel); particleInfo.add_y(particle->y); particleInfo.add_y_vel(particle->yVel); particleInfo.add_z(particle->z); @@ -1477,6 +1581,7 @@ const std::vector SaveGame::Build() sgb.add_header(headerOffset); sgb.add_level(levelStatisticsOffset); sgb.add_game(gameStatisticsOffset); + sgb.add_level_data(levelDataOffset); sgb.add_secret_bits(SaveGame::Statistics.SecretBits); sgb.add_camera(cameraOffset); sgb.add_lara(laraOffset); @@ -1485,6 +1590,7 @@ const std::vector SaveGame::Build() sgb.add_next_item_active(NextItemActive); sgb.add_items(serializedItemsOffset); sgb.add_fish_swarm(fishSwarmOffset); + sgb.add_firefly_swarm(fireflySwarmOffset); sgb.add_fxinfos(serializedEffectsOffset); sgb.add_next_fx_free(NextFxFree); sgb.add_next_fx_active(NextFxActive); @@ -1493,6 +1599,7 @@ const std::vector SaveGame::Build() sgb.add_postprocess_tint(&FromVector3(g_Renderer.GetPostProcessTint())); sgb.add_soundtracks(soundtrackOffset); sgb.add_cd_flags(soundtrackMapOffset); + sgb.add_video(videoInfoOffset); sgb.add_action_queue(actionQueueOffset); sgb.add_flip_maps(flipMapsOffset); sgb.add_flip_stats(flipStatsOffset); @@ -1711,6 +1818,7 @@ static void ParseStatistics(const Save::SaveGame* s, bool isHub) SaveGame::Statistics.Level.HealthUsed = s->level()->medipacks_used(); SaveGame::Statistics.Level.DamageTaken = s->level()->damage_taken(); SaveGame::Statistics.Level.Kills = s->level()->kills(); + SaveGame::Statistics.Level.Pickups = s->level()->pickups(); SaveGame::Statistics.Level.Secrets = s->level()->secrets(); SaveGame::Statistics.Level.TimeTaken = s->level()->timer(); @@ -1724,12 +1832,57 @@ static void ParseStatistics(const Save::SaveGame* s, bool isHub) SaveGame::Statistics.Game.HealthUsed = s->game()->medipacks_used(); SaveGame::Statistics.Game.DamageTaken = s->game()->damage_taken(); SaveGame::Statistics.Game.Kills = s->game()->kills(); + SaveGame::Statistics.Game.Pickups = s->game()->pickups(); SaveGame::Statistics.Game.Secrets = s->game()->secrets(); SaveGame::Statistics.Game.TimeTaken = s->game()->timer(); } static void ParseLua(const Save::SaveGame* s, bool hubMode) { + // Global level data + + auto* level = (Level*)g_GameFlow->GetLevel(CurrentLevel); + + level->Fog.MaxDistance = s->level_data()->fog_max_distance(); + level->Fog.MinDistance = s->level_data()->fog_min_distance(); + level->Fog.SetColor(s->level_data()->fog_color()); + + level->Layer1.Enabled = s->level_data()->sky_layer_1_enabled(); + level->Layer1.CloudSpeed = s->level_data()->sky_layer_1_speed(); + level->Layer1.SetColor(s->level_data()->sky_layer_1_color()); + + level->Layer2.Enabled = s->level_data()->sky_layer_2_enabled(); + level->Layer2.CloudSpeed = s->level_data()->sky_layer_2_speed(); + level->Layer2.SetColor(s->level_data()->sky_layer_2_color()); + + level->LensFlare.SetEnabled(s->level_data()->lensflare_enabled()); + level->LensFlare.SetSunSpriteID(s->level_data()->lensflare_sprite_id()); + level->LensFlare.SetPitch(s->level_data()->lensflare_pitch()); + level->LensFlare.SetYaw(s->level_data()->lensflare_yaw()); + level->LensFlare.SetColor(s->level_data()->lensflare_color()); + + level->Starfield.SetStarCount(s->level_data()->starfield_star_count()); + level->Starfield.SetMeteorCount(s->level_data()->starfield_meteor_count()); + level->Starfield.SetMeteorSpawnDensity(s->level_data()->starfield_meteor_spawn_density()); + level->Starfield.SetMeteorVelocity(s->level_data()->starfield_meteor_velocity()); + + level->Horizon1.SetEnabled(s->level_data()->horizon1_enabled()); + level->Horizon1.SetObjectID((GAME_OBJECT_ID)s->level_data()->horizon1_object_id()); + level->Horizon1.SetPosition(ToVector3(s->level_data()->horizon1_position()), true); + level->Horizon1.SetRotation(ToEulerAngles(s->level_data()->horizon1_orientation()), true); + level->Horizon1.SetTransparency(s->level_data()->horizon1_transparency()); + + level->Horizon2.SetEnabled(s->level_data()->horizon2_enabled()); + level->Horizon2.SetObjectID((GAME_OBJECT_ID)s->level_data()->horizon2_object_id()); + level->Horizon2.SetPosition(ToVector3(s->level_data()->horizon2_position()), true); + level->Horizon2.SetRotation(ToEulerAngles(s->level_data()->horizon2_orientation()), true); + level->Horizon2.SetTransparency(s->level_data()->horizon2_transparency()); + + level->Storm = s->level_data()->storm_enabled(); + level->Rumble = s->level_data()->rumble_enabled(); + level->Weather = (WeatherType)s->level_data()->weather_type(); + level->WeatherStrength = s->level_data()->weather_strength(); + // Event sets if (g_Level.VolumeEventSets.size() == s->volume_event_sets()->size()) @@ -1758,6 +1911,8 @@ static void ParseLua(const Save::SaveGame* s, bool hubMode) } } + // Variables + auto loadedVars = std::vector{}; auto unionVec = s->script_vars(); @@ -1843,6 +1998,8 @@ static void ParseLua(const Save::SaveGame* s, bool hubMode) g_GameScript->SetVariables(loadedVars, hubMode); + // Callbacks + auto populateCallbackVecs = [&s](auto callbackFunc) { auto callbacksVec = std::vector{}; @@ -1975,7 +2132,6 @@ static void ParsePlayer(const Save::SaveGame* s) Lara.Control.Weapon.GunType = (LaraWeaponType)s->lara()->control()->weapon()->gun_type(); Lara.Control.Weapon.HasFired = s->lara()->control()->weapon()->has_fired(); Lara.Control.Weapon.Interval = s->lara()->control()->weapon()->interval(); - Lara.Control.Weapon.Fired = s->lara()->control()->weapon()->fired(); Lara.Control.Weapon.LastGunType = (LaraWeaponType)s->lara()->control()->weapon()->last_gun_type(); Lara.Control.Weapon.RequestGunType = (LaraWeaponType)s->lara()->control()->weapon()->request_gun_type(); Lara.Control.Weapon.HolsterInfo.BackHolster = (HolsterSlot)s->lara()->control()->weapon()->holster_info()->back_holster(); @@ -2157,6 +2313,14 @@ static void ParseEffects(const Save::SaveGame* s) PlaySoundTrack(track->name()->str(), (SoundTrackType)i, track->position(), SOUND_XFADETIME_LEVELJUMP); } + // Restore video playback. + std::string videoName = s->video()->name()->str(); + if (!videoName.empty()) + { + g_VideoPlayer.Play(videoName, VideoPlaybackMode::Background, s->video()->silent(), s->video()->looped()); + g_VideoPlayer.SetNormalizedPosition(s->video()->position()); + } + // Load fish swarm. for (int i = 0; i < s->fish_swarm()->size(); i++) { @@ -2179,6 +2343,38 @@ static void ParseEffects(const Save::SaveGame* s) FishSwarm.push_back(fish); } + // Load firefly swarm. + for (int i = 0; i < s->firefly_swarm()->size(); i++) + { + const auto& fireflySave = s->firefly_swarm()->Get(i); + auto firefly = FireflyData{}; + + firefly.SpriteSeqID = fireflySave->sprite_index(); + firefly.SpriteID = fireflySave->sprite_id(); + firefly.blendMode = (BlendMode)fireflySave->blend_mode(); + firefly.scalar = fireflySave->scalar(); + firefly.Position = ToVector3(fireflySave->position()); + firefly.RoomNumber = fireflySave->room_number(); + firefly.PositionTarget = ToVector3(fireflySave->position_target()); + firefly.Orientation = ToEulerAngles(fireflySave->orientation()); + firefly.Velocity = fireflySave->velocity(); + firefly.TargetItemPtr = (fireflySave->target_item_number() == -1) ? nullptr : &g_Level.Items[fireflySave->target_item_number()]; + firefly.zVel = fireflySave->z_vel(); + firefly.Life = fireflySave->life(); + firefly.Number = fireflySave->number(); + firefly.rB = fireflySave->d_r(); + firefly.gB = fireflySave->d_g(); + firefly.bB = fireflySave->d_b(); + firefly.r = fireflySave->r(); + firefly.g = fireflySave->g(); + firefly.b = fireflySave->b(); + firefly.on = fireflySave->on(); + firefly.size = fireflySave->size(); + firefly.rotAng = fireflySave->rot_ang(); + + FireflySwarm.push_back(firefly); + } + // Load particles. for (int i = 0; i < s->particles()->size(); i++) { @@ -2224,6 +2420,14 @@ static void ParseEffects(const Save::SaveGame* s) particle->roomNumber = particleInfo->room_number(); particle->nodeNumber = particleInfo->node_number(); particle->targetPos = ToVector3(particleInfo->target_pos()); + particle->animationType = (ParticleAnimType)particleInfo->animation_type(); + particle->damage = particleInfo->damage(); + particle->framerate = particleInfo->framerate(); + particle->lightRadius = particleInfo->light_radius(); + particle->lightFlicker = particleInfo->light_flicker(); + particle->lightFlickerS = particleInfo->light_flicker_s(); + particle->sound = particleInfo->sound(); + } for (int i = 0; i < s->bats()->size(); i++) @@ -2373,8 +2577,8 @@ static void ParseLevel(const Save::SaveGame* s, bool hubMode) // Restore action queue. for (int i = 0; i < s->action_queue()->size(); i++) { - TENAssert(i < ActionQueue.size(), "Action queue size was changed"); - ActionQueue[i] = (QueueState)s->action_queue()->Get(i); + TENAssert(i < ActionQueueMap.size(), "Action queue size was changed."); + ActionQueueMap[(InputActionID)i] = (ActionQueueState)s->action_queue()->Get(i); } // Legacy soundtrack map. diff --git a/TombEngine/Game/spotcam.cpp b/TombEngine/Game/spotcam.cpp index ffa8be942..e58df71d2 100644 --- a/TombEngine/Game/spotcam.cpp +++ b/TombEngine/Game/spotcam.cpp @@ -839,14 +839,27 @@ int Spline(int x, int* knots, int nk) return ((__int64)x * (((__int64)x * (((__int64)x * c1 >> 16) + c2) >> 16) + (k[2] >> 1) + ((-k[0] - 1) >> 1)) >> 16) + k[1]; } -Pose GetCameraTransform(int sequence, float alpha) +Pose GetCameraTransform(int sequence, float alpha, bool loop) { + constexpr auto BLEND_RANGE = 0.1f; + constexpr auto BLEND_START = BLEND_RANGE; + constexpr auto BLEND_END = 1.0f - BLEND_RANGE; + alpha = std::clamp(alpha, 0.0f, 1.0f); + if (sequence < 0 || sequence >= MAX_SPOTCAMS) + { + TENLog("Wrong flyby sequence number provided for getting camera coordinates.", LogLevel::Warning); + return Pose::Zero; + } + // Retrieve camera count in sequence. int cameraCount = CameraCnt[SpotCamRemap[sequence]]; if (cameraCount < 2) - return Pose::Zero; // Not enough cameras to interpolate. + { + TENLog("Not enough cameras in flyby sequence to calculate the coordinates.", LogLevel::Warning); + return Pose::Zero; + } // Find first ID for sequence. int firstSeqID = 0; @@ -873,15 +886,39 @@ Pose GetCameraTransform(int sequence, float alpha) } // Compute spline interpolation of main flyby camera parameters. - auto origin = Vector3(Spline(splineAlpha, xOrigins.data(), splinePoints), - Spline(splineAlpha, yOrigins.data(), splinePoints), - Spline(splineAlpha, zOrigins.data(), splinePoints)); + auto getInterpolatedPoint = [&](float t, std::vector& x, std::vector& y, std::vector& z) + { + int tAlpha = int(t * (float)USHRT_MAX); + return Vector3(Spline(tAlpha, x.data(), splinePoints), + Spline(tAlpha, y.data(), splinePoints), + Spline(tAlpha, z.data(), splinePoints)); + }; - auto target = Vector3(Spline(splineAlpha, xTargets.data(), splinePoints), - Spline(splineAlpha, yTargets.data(), splinePoints), - Spline(splineAlpha, zTargets.data(), splinePoints)); + auto getInterpolatedRoll = [&](float t) + { + int tAlpha = int(t * (float)USHRT_MAX); + return Spline(tAlpha, rolls.data(), splinePoints); + }; - short orientZ = Spline(splineAlpha, rolls.data(), splinePoints); + auto origin = Vector3::Zero; + auto target = Vector3::Zero; + short orientZ = 0; + + // If loop is enabled and alpha is at sequence start or end, blend between last and first cameras. + if (loop && (alpha < BLEND_START || alpha >= BLEND_END)) + { + float blendFactor = (alpha < BLEND_START) ? (0.5f + ((alpha / BLEND_RANGE) * 0.5f)) : (((alpha - BLEND_END) / BLEND_START) * 0.5f); + + origin = Vector3::Lerp(getInterpolatedPoint(BLEND_END, xOrigins, yOrigins, zOrigins), getInterpolatedPoint(BLEND_START, xOrigins, yOrigins, zOrigins), blendFactor); + target = Vector3::Lerp(getInterpolatedPoint(BLEND_END, xTargets, yTargets, zTargets), getInterpolatedPoint(BLEND_START, xTargets, yTargets, zTargets), blendFactor); + orientZ = Lerp(getInterpolatedRoll(BLEND_END), getInterpolatedRoll(BLEND_START), blendFactor); + } + else + { + origin = getInterpolatedPoint(alpha, xOrigins, yOrigins, zOrigins); + target = getInterpolatedPoint(alpha, xTargets, yTargets, zTargets); + orientZ = getInterpolatedRoll(alpha); + } auto pose = Pose(origin, EulerAngles(target - origin)); pose.Orientation.z = orientZ; diff --git a/TombEngine/Game/spotcam.h b/TombEngine/Game/spotcam.h index 035929e93..07917c26d 100644 --- a/TombEngine/Game/spotcam.h +++ b/TombEngine/Game/spotcam.h @@ -64,4 +64,4 @@ void InitializeSpotCam(short sequence); void CalculateSpotCameras(); int Spline(int x, int* knots, int nk); -Pose GetCameraTransform(int sequence, float alpha); +Pose GetCameraTransform(int sequence, float alpha, bool loop); diff --git a/TombEngine/Objects/Effects/EmberEmitter.cpp b/TombEngine/Objects/Effects/EmberEmitter.cpp index ac87a2a20..850064dfd 100644 --- a/TombEngine/Objects/Effects/EmberEmitter.cpp +++ b/TombEngine/Objects/Effects/EmberEmitter.cpp @@ -76,6 +76,7 @@ namespace TEN::Effects::EmberEmitter spark.scalar = 3.0f; spark.gravity = Random::GenerateFloat(32.0f, 96.0f); spark.flags = SP_DAMAGE | SP_ROTATE | SP_DEF | SP_SCALE | SP_EXPDEF; + spark.damage = 2; } else { @@ -150,6 +151,7 @@ namespace TEN::Effects::EmberEmitter spark.size = Random::GenerateFloat(32.0f, 48.0f); spark.dSize = spark.size; spark.flags = SP_DAMAGE | SP_ROTATE | SP_DEF | SP_SCALE; + spark.damage = 2; } } } diff --git a/TombEngine/Objects/Effects/Fireflies.cpp b/TombEngine/Objects/Effects/Fireflies.cpp new file mode 100644 index 000000000..0510283f9 --- /dev/null +++ b/TombEngine/Objects/Effects/Fireflies.cpp @@ -0,0 +1,445 @@ +#include "framework.h" +#include "Objects/Effects/Fireflies.h" + +#include "Game/collision/collide_item.h" +#include "Game/collision/collide_room.h" +#include "Game/collision/Point.h" +#include "Game/control/box.h" +#include "Game/control/flipeffect.h" +#include "Game/effects/effects.h" +#include "Game/effects/Streamer.h" +#include "Game/effects/tomb4fx.h" +#include "Game/items.h" +#include "Game/Lara/lara.h" +#include "Game/Lara/lara_helpers.h" +#include "Game/misc.h" +#include "Game/Setup.h" +#include "Math/Math.h" +#include "Renderer/Renderer.h" +#include "Specific/clock.h" +#include "Specific/level.h" + +using namespace TEN::Collision::Point; +using namespace TEN::Math; +using namespace TEN::Renderer; +using namespace TEN::Effects::Streamer; + +namespace TEN::Effects::Fireflies +{ + constexpr auto FIREFLY_COHESION_FACTOR = 600.1f; + constexpr auto FIREFLY_SPACING_FACTOR = 600.0f; + constexpr auto FIREFLY_CATCH_UP_FACTOR = 0.2f; + constexpr auto FIREFLY_TARGET_DISTANCE_MAX = SQUARE(BLOCK(1.0f)); + constexpr auto FIREFLY_BASE_SEPARATION_DISTANCE = 10.0f; + constexpr auto FIREFLY_FLEE_DISTANCE = BLOCK(0.7); + constexpr auto MAX_FIREFLIES = 92; + constexpr auto DEFAULT_FIREFLY_COUNT = 20; + constexpr auto FIREFLY_RISE_UP_FACTOR = 200; + constexpr auto MAX_AREA_RANGE = 8; + constexpr auto LIGHT_ALPHA_CYCLE_DURATION = 120.0f; + + std::vector FireflySwarm = {}; + std::unordered_map nextFireflyNumberMap; // Numbering the Fireflies for Streamer effect. + + void InitializeFireflySwarm(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + + item.Animation.Velocity.z = Random::GenerateFloat(32.0f, 160.0f); + + item.HitPoints = DEFAULT_FIREFLY_COUNT; + item.ItemFlags[FirefliesItemFlags::TargetItemPtr] = item.Index; + item.ItemFlags[FirefliesItemFlags::Light] = 1; // 0 = Turn off light effect, 1 = turn on light (DEFAULT). + + item.ItemFlags[FirefliesItemFlags::TriggerFlags] = std::clamp((int)item.TriggerFlags, -MAX_AREA_RANGE, MAX_AREA_RANGE); + + item.ItemFlags[FirefliesItemFlags::Spawncounter] = 0; + item.ItemFlags[FirefliesItemFlags::RemoveFliesEffect] = 0; + + // Firefly numbers that has the light. + item.ItemFlags[FirefliesItemFlags::LightIndex1] = NO_VALUE; + item.ItemFlags[FirefliesItemFlags::LightIndex2] = NO_VALUE; + } + + void SpawnFireflySwarm(ItemInfo& item, int triggerFlags) + { + constexpr auto VEL_MAX = 34.0f; + constexpr auto VEL_MIN = 6.0f; + + // Create new firefly. + auto& firefly = GetNewEffect(FireflySwarm, MAX_FIREFLIES); + + unsigned char r = 255; + unsigned char g = 255; + unsigned char b = 255; + + if (triggerFlags >= 0) + { + float brightnessShift = Random::GenerateFloat(-0.1f, 0.1f); + r = std::clamp(item.Model.Color.x / 2.0f + brightnessShift, 0.0f, 1.0f) * UCHAR_MAX; + g = std::clamp(item.Model.Color.y / 2.0f + brightnessShift, 0.0f, 1.0f) * UCHAR_MAX; + b = std::clamp(item.Model.Color.z / 2.0f + brightnessShift, 0.0f, 1.0f) * UCHAR_MAX; + + firefly.SpriteSeqID = ID_FIREFLY_SPRITES; + firefly.SpriteID = 0; + firefly.blendMode = BlendMode::Additive; + firefly.scalar = 3.0f; + firefly.size = 1.0f; + } + else + { + firefly.SpriteSeqID = ID_FIREFLY_SPRITES; + firefly.SpriteID = 1; + firefly.blendMode = BlendMode::Subtractive; + firefly.scalar = 1.2f; + firefly.size = 1.2f; + } + + firefly.r = firefly.rB = r; + firefly.g = firefly.gB = g; + firefly.b = firefly.bB = b; + + firefly.rotAng = ANGLE(0.0f); + + if (item.TriggerFlags > 8) + firefly.rotAng = ANGLE(90.0f); + + firefly.on = true; + + firefly.Position = item.Pose.Position.ToVector3(); + firefly.RoomNumber = item.RoomNumber; + firefly.Orientation = item.Pose.Orientation; + firefly.Velocity = Random::GenerateFloat(VEL_MIN, VEL_MAX); + firefly.zVel = 0.3f; + + firefly.Life = Random::GenerateInt(1, 400); + firefly.TargetItemPtr = &g_Level.Items[item.ItemFlags[FirefliesItemFlags::TargetItemPtr]]; + + int& nextFireflyNumber = nextFireflyNumberMap[item.Index]; + firefly.Number = nextFireflyNumber++; + } + + void ControlFireflySwarm(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + + if (!TriggerActive(&item)) + { + // Remove all fireflies associated with this item. + RemoveFireflies(item); + + // Reset ItemFlags. + if (item.HitPoints == NOT_TARGETABLE) + item.HitPoints = item.ItemFlags[FirefliesItemFlags::Spawncounter]; + + item.ItemFlags[FirefliesItemFlags::Spawncounter] = 0; + item.ItemFlags[FirefliesItemFlags::LightIndex1] = NO_VALUE; + item.ItemFlags[FirefliesItemFlags::LightIndex2] = NO_VALUE; + + return; + } + + constexpr auto ALPHA_PAUSE_DURATION = 2.0f; + static float frameCounter = 0.0f; + + // Increment the counter variable in each frame. + frameCounter += 1.0f; + + if (item.HitPoints != NOT_TARGETABLE) + { + int fireflyCount = item.HitPoints - item.ItemFlags[FirefliesItemFlags::Spawncounter]; + + if (fireflyCount < 0) + { + int firefliesToTurnOff = -fireflyCount; + for (auto& firefly : FireflySwarm) + { + if (firefly.TargetItemPtr == &item && firefly.Life > 0.0f) + { + firefly.Life = 0.0f; + firefly.on = false; + firefliesToTurnOff--; + + if (firefliesToTurnOff == 0) + break; + } + } + } + else if (fireflyCount > 0) + { + for (int i = 0; i < fireflyCount; i++) + { + SpawnFireflySwarm(item, item.TriggerFlags); + } + } + + item.ItemFlags[FirefliesItemFlags::Spawncounter] = item.HitPoints; + item.HitPoints = NOT_TARGETABLE; + } + + // Update color values for blinking effect. + float alphaFactor; + + for (auto& firefly : FireflySwarm) + { + auto targetItem = firefly.TargetItemPtr; + + if (targetItem == &item) + { + // Choose one of the available firefly number that has the light. + if (targetItem->ItemFlags[FirefliesItemFlags::LightIndex1] == NO_VALUE && targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] >= 0) + { + targetItem->ItemFlags[FirefliesItemFlags::LightIndex1] = Random::GenerateInt(0, targetItem->TriggerFlags); + } + // Two lights max for each cluster. + if (targetItem->ItemFlags[FirefliesItemFlags::LightIndex2] == NO_VALUE && targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] >= 0) + { + targetItem->ItemFlags[FirefliesItemFlags::LightIndex2] = Random::GenerateInt(0, targetItem->TriggerFlags); + } + + auto posBase = firefly.Position; + auto rotMatrix = firefly.Orientation.ToRotationMatrix(); + auto pos = posBase + Vector3::Transform(Vector3(0, 0, 30), rotMatrix); + auto direction0 = Geometry::RotatePoint(posBase, EulerAngles::Identity); + short orient2D = firefly.Orientation.z; + + if (targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] >= 0) + { + StreamerEffect.Spawn(targetItem->Index, firefly.Number, pos, direction0, orient2D, + Vector4(firefly.r / (float)UCHAR_MAX, firefly.g / (float)UCHAR_MAX, firefly.b / (float)UCHAR_MAX, 1.0f), + Vector4::Zero, + 6.3f - (firefly.zVel / 12), ((firefly.Velocity / 8) + firefly.zVel * 3) / (float)UCHAR_MAX, 0.0f, -0.1f, 90.0f, StreamerFeatherMode::None, BlendMode::Additive); + } + else if (targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] < 0) + { + StreamerEffect.Spawn(targetItem->Index, firefly.Number, pos, direction0, orient2D, + Vector4((firefly.r / 2) / (float)UCHAR_MAX, (firefly.g / 2) / (float)UCHAR_MAX, (firefly.b / 2) / (float)UCHAR_MAX, 0.2f), + Vector4((firefly.r / 3) / (float)UCHAR_MAX, (firefly.g / 3) / (float)UCHAR_MAX, (firefly.b / 3) / (float)UCHAR_MAX, 0.2f), + 0.0f, 0.4f, 0.0f, 0.2f, 0.0f, StreamerFeatherMode::None, BlendMode::Subtractive); + } + + if ((targetItem->ItemFlags[FirefliesItemFlags::LightIndex1] == firefly.Number || targetItem->ItemFlags[FirefliesItemFlags::LightIndex2] == firefly.Number) && + targetItem->ItemFlags[FirefliesItemFlags::Light] == 1) + { + float totalCycleDuration = 2 * (LIGHT_ALPHA_CYCLE_DURATION + ALPHA_PAUSE_DURATION); + float alphaTime = fmod(frameCounter, totalCycleDuration); + + if (alphaTime < ALPHA_PAUSE_DURATION) + { + alphaFactor = 1.0f; // Pause on Alpha 1. + } + else if (alphaTime < ALPHA_PAUSE_DURATION + LIGHT_ALPHA_CYCLE_DURATION) + { + alphaFactor = 1.0f - ((alphaTime - ALPHA_PAUSE_DURATION) / LIGHT_ALPHA_CYCLE_DURATION); + } + else if (alphaTime < 2 * ALPHA_PAUSE_DURATION + LIGHT_ALPHA_CYCLE_DURATION) + { + alphaFactor = 0.0f; // Pause on Alpha 0. + targetItem->ItemFlags[FirefliesItemFlags::LightIndex1] = NO_VALUE; + targetItem->ItemFlags[FirefliesItemFlags::LightIndex2] = NO_VALUE; + } + else + { + alphaFactor = (alphaTime - 2 * ALPHA_PAUSE_DURATION - LIGHT_ALPHA_CYCLE_DURATION) / LIGHT_ALPHA_CYCLE_DURATION; + } + + SpawnDynamicLight(firefly.Position.x, firefly.Position.y, firefly.Position.z, 3, + static_cast(std::clamp(firefly.r * alphaFactor, 0.0f, (float)firefly.r)), + static_cast(std::clamp(firefly.g * alphaFactor, 0.0f, (float)firefly.g)), + static_cast(std::clamp(firefly.b * alphaFactor, 0.0f, (float)firefly.b))); + } + } + } + } + + void UpdateFireflySwarm() + { + constexpr auto FLEE_VEL = 1.5f; + constexpr auto ALPHA_PAUSE_DURATION = 100.0f; + + static const auto SPHERE = BoundingSphere(Vector3::Zero, BLOCK(1 / 8.0f)); + + if (FireflySwarm.empty()) + return; + + const auto& playerItem = *LaraItem; + static float frameCounter = 0.0f; + + // Increment the counter variable in each frame. + frameCounter += 1.0f; + + for (auto& firefly : FireflySwarm) + { + if (firefly.Life <= 0.0f || !firefly.on) + continue; + + auto targetItem = firefly.TargetItemPtr; + + if (targetItem->ItemFlags[FirefliesItemFlags::RemoveFliesEffect]) + { + firefly.r = 0; + firefly.g = 0; + firefly.b = 0; + continue; + } + + firefly.StoreInterpolationData(); + + firefly.PositionTarget = Random::GeneratePointInSphere(SPHERE); + + int multiplierX = CLICK(targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] * 2); + int multiplierY = CLICK(targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] * 4); + int multiplierZ = CLICK(targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] * 2); + + auto spheroidAxis = Vector3(multiplierX, multiplierY, multiplierZ); + auto itemPos = Vector3i(targetItem->Pose.Position.x, targetItem->Pose.Position.y - FIREFLY_RISE_UP_FACTOR, targetItem->Pose.Position.z); + + // Calculate desired position based on target object and random offsets. + auto desiredPos = itemPos + Random::GeneratePointInSpheroid(firefly.PositionTarget, EulerAngles::Identity, spheroidAxis); + auto dir = desiredPos - firefly.Position; + + auto dirs = dir.ToVector3(); + dirs.Normalize(); + auto dirNorm = dirs; + + // Define cohesion factor to keep fireflies close together. + float distToTarget = dirs.Length(); + + float targetVel = (distToTarget * FIREFLY_COHESION_FACTOR) + Random::GenerateFloat(3.0f, 5.0f); + firefly.Velocity = std::min(targetVel, targetItem->Animation.Velocity.z - 21.0f); + + // If firefly is too far from target, increase velocity to catch up. + if (distToTarget > FIREFLY_TARGET_DISTANCE_MAX) + firefly.Velocity += FIREFLY_CATCH_UP_FACTOR; + + // Translate. + auto moveDir = firefly.Orientation.ToDirection(); + moveDir.Normalize(); + firefly.Position += (moveDir * firefly.Velocity) / 26.0f; + firefly.Position += (moveDir * FIREFLY_SPACING_FACTOR) / 26.0f; + + auto orientTo = Geometry::GetOrientToPoint(firefly.Position, desiredPos.ToVector3()); + firefly.Orientation.Lerp(orientTo, 0.1f); + + // Update color values for blinking effect. + float totalCycleDuration = 2 * (LIGHT_ALPHA_CYCLE_DURATION + ALPHA_PAUSE_DURATION); + float alphaTime = fmod(frameCounter + firefly.Life, totalCycleDuration); + float alphaFactor; + + if (alphaTime < ALPHA_PAUSE_DURATION) + { + alphaFactor = 1.0f; + } + else if (alphaTime < ALPHA_PAUSE_DURATION + LIGHT_ALPHA_CYCLE_DURATION) + { + alphaFactor = 1.0f - ((alphaTime - ALPHA_PAUSE_DURATION) / LIGHT_ALPHA_CYCLE_DURATION); + } + else if (alphaTime < 2 * ALPHA_PAUSE_DURATION + LIGHT_ALPHA_CYCLE_DURATION) + { + alphaFactor = 0.0f; + } + else + { + alphaFactor = (alphaTime - 2 * ALPHA_PAUSE_DURATION - LIGHT_ALPHA_CYCLE_DURATION) / LIGHT_ALPHA_CYCLE_DURATION; + } + + firefly.r = static_cast(firefly.rB * alphaFactor); + firefly.g = static_cast(firefly.gB * alphaFactor); + firefly.b = static_cast(firefly.bB * alphaFactor); + + for (const auto& otherFirefly : FireflySwarm) + { + if (&firefly == &otherFirefly) + continue; + + float distToOtherFirefly = Vector3i::Distance(firefly.Position, otherFirefly.Position); + float distToPlayer = Vector3i::Distance(firefly.Position, playerItem.Pose.Position); + + // If player is too close, flee. + if (distToPlayer < FIREFLY_FLEE_DISTANCE && playerItem.Animation.ActiveState != 2) + { + auto separationDir = firefly.Position - playerItem.Pose.Position.ToVector3(); + separationDir.Normalize(); + + // Reduce the Y component of the escape direction. + separationDir.y *= Random::GenerateFloat(0.0f, 0.4f); + + // Normalize the direction again to get the length of the vector. + separationDir.Normalize(); + + firefly.Position += separationDir * FLEE_VEL; + + auto orientTo = Geometry::GetOrientToPoint(firefly.Position, separationDir); + firefly.Orientation.Lerp(orientTo, 0.05f); + + firefly.Velocity -= std::min(FLEE_VEL, firefly.TargetItemPtr->Animation.Velocity.z - 1.0f); + + if (Random::TestProbability(1.0f / 700.0f) && + targetItem->ItemFlags[FirefliesItemFlags::Light] == 1 && + targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] >= 0) + { + if (firefly.zVel == 0.3f) + { + firefly.zVel = 50.0f; + } + } + + if (firefly.zVel > 50.0f) + firefly.zVel = 0.3f; + } + + if (distToOtherFirefly < FIREFLY_BASE_SEPARATION_DISTANCE) + { + auto separationDir = firefly.Position - otherFirefly.Position; + separationDir.Normalize(); + + firefly.Position += separationDir * (FIREFLY_BASE_SEPARATION_DISTANCE - distToOtherFirefly); + } + } + + auto pointColl = GetPointCollision(firefly.Position, firefly.RoomNumber); + + // Update firefly room number. + if (pointColl.GetRoomNumber() != firefly.RoomNumber && + pointColl.GetRoomNumber() != NO_VALUE) + { + firefly.RoomNumber = pointColl.GetRoomNumber(); + } + + if (targetItem->ItemFlags[FirefliesItemFlags::Light] == 1 && targetItem->ItemFlags[FirefliesItemFlags::TriggerFlags] >= 0) + { + if (Random::TestProbability(1.0f / (700.0f - (float)(targetItem->ItemFlags[FirefliesItemFlags::Spawncounter] * 2)))) + firefly.zVel = 100.0f; + + if (firefly.zVel > 1.0f) + firefly.zVel -= 2.0f; + if (firefly.zVel <= 1.0f) + firefly.zVel = 0.3f; + } + } + } + + void RemoveFireflies(ItemInfo& item) + { + FireflySwarm.erase(std::remove_if(FireflySwarm.begin(), FireflySwarm.end(), + [&item](FireflyData& firefly) + { + if (firefly.TargetItemPtr == &item) + { + firefly.Life = 0.0f; + firefly.on = false; + return true; + } + return false; + }), FireflySwarm.end()); + nextFireflyNumberMap.erase(item.Index); + } + + void ClearFireflySwarm() + { + FireflySwarm.clear(); + nextFireflyNumberMap.clear(); + } +} + + diff --git a/TombEngine/Objects/Effects/Fireflies.h b/TombEngine/Objects/Effects/Fireflies.h new file mode 100644 index 000000000..807869b81 --- /dev/null +++ b/TombEngine/Objects/Effects/Fireflies.h @@ -0,0 +1,76 @@ +#pragma once +#include "Game/items.h" +#include "Math/Math.h" + +using namespace TEN::Math; + +namespace TEN::Effects::Fireflies +{ + enum FirefliesItemFlags + { + TargetItemPtr, + Light, + TriggerFlags, + Spawncounter, + RemoveFliesEffect, + LightIndex1, + LightIndex2 + }; + + struct FireflyData + { + int SpriteSeqID = ID_DEFAULT_SPRITES; + int SpriteID = SPR_UNDERWATERDUST; + BlendMode blendMode; + unsigned int scalar; + + Vector3 Position = Vector3::Zero; + int RoomNumber = 0; + Vector3 PositionTarget = Vector3::Zero; + EulerAngles Orientation = EulerAngles::Identity; + float Velocity = 0.0f; + + ItemInfo* TargetItemPtr = nullptr; + + float zVel; + float Life = 0.0f; + int Number = 0; + + unsigned char rB; + unsigned char gB; + unsigned char bB; + unsigned char r; + unsigned char g; + unsigned char b; + + bool on; + float size; + short rotAng; + + int PrevX; + int PrevY; + int PrevZ; + byte PrevR; + byte PrevG; + byte PrevB; + + void StoreInterpolationData() + { + PrevX = Position.x; + PrevY = Position.y; + PrevZ = Position.z; + PrevR = r; + PrevG = g; + PrevB = b; + } + }; + + extern std::vector FireflySwarm; + + void InitializeFireflySwarm(short itemNumber); + void ControlFireflySwarm(short itemNumber); + void UpdateFireflySwarm(); + void ClearFireflySwarm(); + void SpawnFireflySwarm(ItemInfo& item, int triggerFlags); + void RemoveFireflies(ItemInfo& item); +} diff --git a/TombEngine/Objects/Generic/Object/generic_trapdoor.cpp b/TombEngine/Objects/Generic/Object/generic_trapdoor.cpp index f9fa318ab..893d51aec 100644 --- a/TombEngine/Objects/Generic/Object/generic_trapdoor.cpp +++ b/TombEngine/Objects/Generic/Object/generic_trapdoor.cpp @@ -48,8 +48,23 @@ namespace TEN::Entities::Generic EulerAngles(ANGLE(-10.0f), ANGLE(-30.0f), ANGLE(-10.0f)), EulerAngles(ANGLE(10.0f), ANGLE(30.0f), ANGLE(10.0f))) }; + static auto FloorTrapDoorPos = Vector3i(0, 0, -655); + static auto WaterFloorTrapDoorPos = Vector3i(0, -CLICK(1), -655); + const ObjectCollisionBounds WaterFloorTrapDoorBounds = + { + GameBoundingBox( + -BLOCK(3.0f / 8), BLOCK(3.0f / 8), + -BLOCK(0.5f), 0, + -BLOCK(3 / 4.0f), BLOCK(1 / 4.0f) + ), + std::pair( + EulerAngles(ANGLE(-80.0f), ANGLE(-80.0f), ANGLE(-80.0f)), + EulerAngles(ANGLE(80.0f), ANGLE(80.0f), ANGLE(80.0f)) + ) + }; + static std::optional GetTrapDoorFloorHeight(const ItemInfo& item, const Vector3i& pos) { if (!item.MeshBits.TestAny() || item.ItemFlags[2] == 0) @@ -162,19 +177,26 @@ namespace TEN::Entities::Generic auto* laraInfo = GetLaraInfo(laraItem); auto* trapDoorItem = &g_Level.Items[itemNumber]; - if ((IsHeld(In::Action) && - laraItem->Animation.ActiveState == LS_IDLE && - laraItem->Animation.AnimNumber == LA_STAND_IDLE && - laraInfo->Control.HandStatus == HandStatus::Free && - trapDoorItem->Status != ITEM_ACTIVE) || - (laraInfo->Control.IsMoving && laraInfo->Context.InteractedItem == itemNumber)) + bool isUnderwater = (laraInfo->Control.WaterStatus == WaterStatus::Underwater); + + const auto& bounds = isUnderwater ? WaterFloorTrapDoorBounds : FloorTrapDoorBounds; + const auto& position = isUnderwater ? WaterFloorTrapDoorPos : FloorTrapDoorPos; + + bool isActionActive = laraInfo->Control.IsMoving && laraInfo->Context.InteractedItem == itemNumber; + bool isActionReady = IsHeld(In::Action); + bool isPlayerAvailable = laraInfo->Control.HandStatus == HandStatus::Free && trapDoorItem->Status != ITEM_ACTIVE; + + bool isPlayerIdle = (!isUnderwater && laraItem->Animation.ActiveState == LS_IDLE && laraItem->Animation.AnimNumber == LA_STAND_IDLE) || + ( isUnderwater && laraItem->Animation.ActiveState == LS_UNDERWATER_IDLE && laraItem->Animation.AnimNumber == LA_UNDERWATER_IDLE); + + if (isActionActive || (isActionReady && isPlayerAvailable && isPlayerIdle)) { - if (TestLaraPosition(FloorTrapDoorBounds, trapDoorItem, laraItem)) + if (TestLaraPosition(bounds, trapDoorItem, laraItem)) { - if (MoveLaraPosition(FloorTrapDoorPos, trapDoorItem, laraItem)) + if (MoveLaraPosition(position, trapDoorItem, laraItem)) { ResetPlayerFlex(laraItem); - laraItem->Animation.AnimNumber = LA_TRAPDOOR_FLOOR_OPEN; + laraItem->Animation.AnimNumber = isUnderwater ? LA_UNDERWATER_FLOOR_TRAPDOOR : LA_TRAPDOOR_FLOOR_OPEN; laraItem->Animation.FrameNumber = GetAnimData(laraItem).frameBase; laraItem->Animation.ActiveState = LS_TRAPDOOR_FLOOR_OPEN; laraInfo->Control.IsMoving = false; diff --git a/TombEngine/Objects/Generic/generic_objects.cpp b/TombEngine/Objects/Generic/generic_objects.cpp index 5e09d44ba..8f10a3420 100644 --- a/TombEngine/Objects/Generic/generic_objects.cpp +++ b/TombEngine/Objects/Generic/generic_objects.cpp @@ -176,7 +176,7 @@ void StartSwitches(ObjectInfo* object) object->shadowType = ShadowMode::All; } - for (int objectID = ID_UNDERWATER_WALL_SWITCH_1; objectID <= ID_UNDERWATER_WALL_SWITCH_2; objectID++) + for (int objectID = ID_UNDERWATER_WALL_SWITCH1; objectID <= ID_UNDERWATER_WALL_SWITCH2; objectID++) { object = &Objects[objectID]; if (object->loaded) @@ -186,7 +186,7 @@ void StartSwitches(ObjectInfo* object) } } - for (int objectID = ID_UNDERWATER_CEILING_SWITCH_1; objectID <= ID_UNDERWATER_CEILING_SWITCH_2; objectID++) + for (int objectID = ID_UNDERWATER_CEILING_SWITCH1; objectID <= ID_UNDERWATER_CEILING_SWITCH2; objectID++) { object = &Objects[objectID]; if (object->loaded) diff --git a/TombEngine/Objects/TR1/Trap/ThorHammer.cpp b/TombEngine/Objects/TR1/Trap/ThorHammer.cpp new file mode 100644 index 000000000..ba468670a --- /dev/null +++ b/TombEngine/Objects/TR1/Trap/ThorHammer.cpp @@ -0,0 +1,197 @@ +#include "framework.h" +#include "Objects/TR1/Trap/ThorHammer.h" + +#include "Game/camera.h" +#include "Game/collision/collide_item.h" +#include "Game/collision/collide_room.h" +#include "Game/collision/Point.h" +#include "Game/collision/Sphere.h" +#include "Game/effects/effects.h" +#include "Game/Lara/lara.h" +#include "Game/Setup.h" +#include "Math/Math.h" +#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h" +#include "Specific/level.h" + +using namespace TEN::Collision::Point; +using namespace TEN::Collision::Sphere; +using namespace TEN::Math; + +// NOTES: +// item.TriggerFlags = 0; Default TR1 behavior. +// item.TriggerFlags = 1; Retract after striking once. +// item.TriggerFlags = 2; Strike continuously. + +namespace TEN::Entities::Traps +{ + constexpr auto HAMMER_HIT_FRAME = 30; + + enum HammerState + { + HAMMER_STATE_IDLE = 0, + HAMMER_STATE_UNSTABLE = 1, + HAMMER_STATE_FALL_START = 2, + HAMMER_STATE_FALL_END = 3, + HAMMER_STATE_RETRACT = 4 + }; + + enum HammerAnim + { + HAMMER_ANIM_IDLE = 0, + HAMMER_ANIM_UNSTABLE = 1, + HAMMER_ANIM_FALL_START = 2, + HAMMER_ANIM_FALL_END = 3, + HAMMER_ANIM_RETRACT = 4 + }; + + void InitializeThorHammer(short itemNumber) + { + auto& headItem = g_Level.Items[itemNumber]; + + int handleItemNumber = SpawnItem(headItem, ID_THOR_HAMMER_HEAD); + if (handleItemNumber == NO_VALUE) + { + TENLog("Failed to create hammer handle moveable.", LogLevel::Warning); + return; + } + + auto& handleItem = g_Level.Items[handleItemNumber]; + + // Store hammer handle item number. + headItem.ItemFlags[0] = handleItemNumber; + handleItem.ItemFlags[0] = NO_VALUE; + } + + static void SyncThorHammerHandle(ItemInfo& headItem) + { + int handleItemNumber = headItem.ItemFlags[0]; + auto& handleItem = g_Level.Items[handleItemNumber]; + + // Sync item status. + handleItem.Status = headItem.Status; + + //Sync item TriggerFlag + handleItem.TriggerFlags = headItem.TriggerFlags; + + // Sync animation. + SetAnimation(handleItem, GetAnimNumber(headItem), GetFrameNumber(headItem)); + + // Sync position. + handleItem.Pose = headItem.Pose; + if (handleItem.RoomNumber != headItem.RoomNumber) + ItemNewRoom(handleItem.Index, headItem.RoomNumber); + } + + void ControlThorHammer(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + const auto& playerItem = *LaraItem; + + switch (item.Animation.ActiveState) + { + case HAMMER_STATE_IDLE: + if (TriggerActive(&item)) + { + if (std::abs(item.TriggerFlags) == 1 && item.ItemFlags[1] == 1) + { + item.Status = ITEM_NOT_ACTIVE; + break; + + } + + if (std::abs(item.TriggerFlags) == 2) + { + item.Animation.TargetState = HAMMER_STATE_FALL_START; + break; + + } + + item.Animation.TargetState = HAMMER_STATE_UNSTABLE; + } + else + { + RemoveActiveItem(itemNumber); + item.Status = ITEM_NOT_ACTIVE; + } + + break; + + case HAMMER_STATE_UNSTABLE: + if (TriggerActive(&item)) + { + item.Animation.TargetState = HAMMER_STATE_FALL_START; + } + else + { + item.Animation.TargetState = HAMMER_STATE_IDLE; + } + + break; + + case HAMMER_STATE_FALL_START: + break; + + case HAMMER_STATE_FALL_END: + if (std::abs(item.TriggerFlags) > 0) + { + item.Animation.TargetState = HAMMER_STATE_RETRACT; + + if (std::abs(item.TriggerFlags) == 1) + { + item.ItemFlags[1] = 1; + } + } + else + { + item.Status = ITEM_NOT_ACTIVE; + RemoveActiveItem(itemNumber); + } + + break; + } + + AnimateItem(&item); + SyncThorHammerHandle(item); + } + + void CollideThorHammer(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll) + { + auto& item = g_Level.Items[itemNumber]; + + if (!TestBoundsCollide(&item, playerItem, coll->Setup.Radius)) + return; + + if (!HandleItemSphereCollision(item, *playerItem)) + return; + + if (item.Animation.ActiveState == HAMMER_STATE_FALL_START && (item.Animation.FrameNumber - GetAnimData(item).frameBase) <= HAMMER_HIT_FRAME) + { + auto pointColl = GetPointCollision(*playerItem); + + playerItem->Pose.Position.y = pointColl.GetFloorHeight(); + playerItem->Animation.Velocity = Vector3::Zero; + playerItem->Animation.IsAirborne = false; + + if (item.TriggerFlags < 0) + playerItem->Pose.Scale = Vector3(1.0f, 0.1f, 1.0f); + + DoDamage(playerItem, INT_MAX); + SetAnimation(playerItem, LA_BOULDER_DEATH); + } + else if (playerItem->HitPoints > 0) + { + ItemPushItem(&item, playerItem, coll, false, 1); + } + } + + void CollideThorHammerHandle(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll) + { + auto& item = g_Level.Items[itemNumber]; + + if (!TestBoundsCollide(&item, playerItem, coll->Setup.Radius)) + return; + + if (coll->Setup.EnableObjectPush) + ItemPushItem(&item, playerItem, coll, false, 1); + } +} diff --git a/TombEngine/Objects/TR1/Trap/ThorHammer.h b/TombEngine/Objects/TR1/Trap/ThorHammer.h new file mode 100644 index 000000000..97736f830 --- /dev/null +++ b/TombEngine/Objects/TR1/Trap/ThorHammer.h @@ -0,0 +1,13 @@ +#pragma once + +struct CollisionInfo; +struct ItemInfo; +struct ObjectInfo; + +namespace TEN::Entities::Traps +{ + void InitializeThorHammer(short itemNumber); + void ControlThorHammer(short itemNumber); + void CollideThorHammer(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll); + void CollideThorHammerHandle(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll); +} diff --git a/TombEngine/Objects/TR1/tr1_objects.cpp b/TombEngine/Objects/TR1/tr1_objects.cpp index 998a5556b..c611a171b 100644 --- a/TombEngine/Objects/TR1/tr1_objects.cpp +++ b/TombEngine/Objects/TR1/tr1_objects.cpp @@ -26,9 +26,10 @@ // Traps #include "Objects/TR1/Trap/DamoclesSword.h" +#include "Objects/TR1/Trap/ElectricBall.h" +#include "Objects/TR1/Trap/ThorHammer.h" #include "Objects/TR1/Trap/SlammingDoors.h" #include "Objects/TR1/Trap/SwingingBlade.h" -#include "Objects/TR1/Trap/ElectricBall.h" using namespace TEN::Entities::Creatures::TR1; using namespace TEN::Entities::Traps; @@ -250,6 +251,26 @@ static void StartTrap(ObjectInfo* obj) obj->shadowType = ShadowMode::All; obj->SetHitEffect(true); } + + obj = &Objects[ID_THOR_HAMMER_HANDLE]; + if (obj->loaded) + { + CheckIfSlotExists(ID_THOR_HAMMER_HEAD, "Thor hammer"); + obj->Initialize = InitializeThorHammer; + obj->collision = CollideThorHammerHandle; + obj->control = ControlThorHammer; + obj->shadowType = ShadowMode::All; + obj->SetHitEffect(true); + } + + obj = &Objects[ID_THOR_HAMMER_HEAD]; + if (obj->loaded) + { + CheckIfSlotExists(ID_THOR_HAMMER_HANDLE, "Thor hammer"); + obj->collision = CollideThorHammer; + obj->shadowType = ShadowMode::All; + obj->SetHitEffect(true); + } obj = &Objects[ID_SLAMMING_DOORS]; if (obj->loaded) diff --git a/TombEngine/Objects/TR2/Entity/Bartoli.cpp b/TombEngine/Objects/TR2/Entity/Bartoli.cpp index be31d6b96..e7c6237d4 100644 --- a/TombEngine/Objects/TR2/Entity/Bartoli.cpp +++ b/TombEngine/Objects/TR2/Entity/Bartoli.cpp @@ -81,21 +81,21 @@ namespace TEN::Entities::Creatures::TR2 { SpawnDynamicPointLight(lightPos, lightColor, Random::GenerateFloat(BLOCK(12), BLOCK(24))); SpawnBartoliTransformEffect(item, ID_SPHERE_OF_DOOM); - SoundEffect(SFX_TR2_MARCO_BARTOLLI_TRANSFORM, &item.Pose); + SoundEffect(SFX_TR2_MARCO_BARTOLI_TRANSFORM, &item.Pose); } if (effectTimer == timeExplosion2) { SpawnDynamicPointLight(lightPos, lightColor, Random::GenerateFloat(BLOCK(12), BLOCK(24))); SpawnBartoliTransformEffect(item, ID_SPHERE_OF_DOOM2); - SoundEffect(SFX_TR2_MARCO_BARTOLLI_TRANSFORM, &item.Pose); + SoundEffect(SFX_TR2_MARCO_BARTOLI_TRANSFORM, &item.Pose); } if (effectTimer == timeExplosion3) { SpawnDynamicPointLight(lightPos, lightColor, Random::GenerateFloat(BLOCK(12), BLOCK(24))); SpawnBartoliTransformEffect(item, ID_SPHERE_OF_DOOM3); - SoundEffect(SFX_TR2_MARCO_BARTOLLI_TRANSFORM, &item.Pose); + SoundEffect(SFX_TR2_MARCO_BARTOLI_TRANSFORM, &item.Pose); item.Animation.FrameNumber = animationFrameEnd; } diff --git a/TombEngine/Objects/TR2/tr2_objects.cpp b/TombEngine/Objects/TR2/tr2_objects.cpp index 308bfb5ee..1be6656b1 100644 --- a/TombEngine/Objects/TR2/tr2_objects.cpp +++ b/TombEngine/Objects/TR2/tr2_objects.cpp @@ -432,7 +432,7 @@ static void StartEntity(ObjectInfo* obj) obj = &Objects[ID_DRAGON_FRONT]; if (obj->loaded) { - CheckIfSlotExists(ID_DRAGON_BACK, "ID_DRAGON_BACK"); + CheckIfSlotExists(ID_DRAGON_BACK, "Dragon"); obj->Initialize = InitializeDragon; obj->collision = CollideDragonFront; obj->control = ControlDragon; @@ -449,9 +449,9 @@ static void StartEntity(ObjectInfo* obj) obj = &Objects[ID_DRAGON_BACK]; if (obj->loaded) { - CheckIfSlotExists(ID_DRAGON_FRONT, "ID_DRAGON_FRONT"); - CheckIfSlotExists(ID_DRAGON_BONE_FRONT, "ID_DRAGON_BONE_FRONT"); - CheckIfSlotExists(ID_DRAGON_BONE_BACK, "ID_DRAGON_BONE_BACK"); + CheckIfSlotExists(ID_DRAGON_FRONT, "Dragon"); + CheckIfSlotExists(ID_DRAGON_BONE_FRONT, "Dragon"); + CheckIfSlotExists(ID_DRAGON_BONE_BACK, "Dragon"); obj->collision = CollideDragonBack; obj->SetHitEffect(false, true); obj->shadowType = ShadowMode::All; @@ -472,9 +472,9 @@ static void StartEntity(ObjectInfo* obj) obj = &Objects[ID_MARCO_BARTOLI]; if (obj->loaded) { - CheckIfSlotExists(ID_SPHERE_OF_DOOM, "ID_SPHERE_OF_DOOM"); - CheckIfSlotExists(ID_SPHERE_OF_DOOM2, "ID_SPHERE_OF_DOOM2"); - CheckIfSlotExists(ID_SPHERE_OF_DOOM3, "ID_SPHERE_OF_DOOM3"); + CheckIfSlotExists(ID_SPHERE_OF_DOOM, "Marco Bartoli"); + CheckIfSlotExists(ID_SPHERE_OF_DOOM2, "Marco Bartoli"); + CheckIfSlotExists(ID_SPHERE_OF_DOOM3, "Marco Bartoli"); obj->Initialize = InitializeBartoli; obj->control = ControlBartoli; } diff --git a/TombEngine/Objects/TR3/Object/corpse.cpp b/TombEngine/Objects/TR3/Object/corpse.cpp index 527f12f1c..3b3da8a3b 100644 --- a/TombEngine/Objects/TR3/Object/corpse.cpp +++ b/TombEngine/Objects/TR3/Object/corpse.cpp @@ -17,6 +17,7 @@ #include "Game/Lara/lara_helpers.h" #include "Game/Setup.h" #include "Math/Math.h" +#include "Objects/Effects/Fireflies.h" #include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h" #include "Sound/sound.h" #include "Specific/level.h" @@ -25,9 +26,13 @@ using namespace TEN::Collision::Point; using namespace TEN::Effects::Ripple; using namespace TEN::Effects::Splash; using namespace TEN::Math; +using namespace TEN::Effects::Fireflies; namespace TEN::Entities::TR3 { + constexpr auto FLY_EFFECT_MAX_WIDTH = -1; + constexpr auto FLY_AMOUNT = 16; + enum CorpseState { CORPSE_STATE_GROUNDED = 0, @@ -51,19 +56,25 @@ namespace TEN::Entities::TR3 if (item.TriggerFlags == 1) { - item.ItemFlags[1] = (int)CorpseFlag::Hang; + item.ItemFlags[7] = (int)CorpseFlag::Hang; item.Animation.AnimNumber = object.animIndex + CORPSE_ANIM_HANG; item.Animation.ActiveState = CORPSE_STATE_HANG; } else { - item.ItemFlags[1] = (int)CorpseFlag::Grounded; + item.ItemFlags[7] = (int)CorpseFlag::Grounded; item.Animation.AnimNumber = object.animIndex + CORPSE_ANIM_GROUNDED; item.Animation.ActiveState = CORPSE_STATE_GROUNDED; } + item.ItemFlags[FirefliesItemFlags::RemoveFliesEffect] = 0; + AddActiveItem(itemNumber); item.Status = ITEM_ACTIVE; + + item.ItemFlags[FirefliesItemFlags::TargetItemPtr] = item.Index; + item.ItemFlags[FirefliesItemFlags::TriggerFlags] = -1; + item.HitPoints = FLY_AMOUNT; } void ControlCorpse(short itemNumber) @@ -71,9 +82,11 @@ namespace TEN::Entities::TR3 auto& item = g_Level.Items[itemNumber]; const auto& object = Objects[item.ObjectNumber]; - if (item.ItemFlags[1] == (int)CorpseFlag::Fall) + if (item.ItemFlags[7] == (int)CorpseFlag::Fall) { bool isWater = TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item.RoomNumber); + bool isSwamp = TestEnvironment(RoomEnvFlags::ENV_FLAG_SWAMP, item.RoomNumber); + float verticalVelCoeff = isWater ? 81.0f : 1.0f; auto pointColl = GetPointCollision(item); @@ -94,31 +107,37 @@ namespace TEN::Entities::TR3 ItemNewRoom(itemNumber, pointColl.GetRoomNumber()); } - pointColl = GetPointCollision(item); + // Remove fly effect when in water. + if (isWater || isSwamp) + { + item.ItemFlags[FirefliesItemFlags::RemoveFliesEffect] = 1; + } + + auto bounds = GameBoundingBox(&item); + item.Animation.IsAirborne = true; - if (pointColl.GetFloorHeight() < item.Pose.Position.y) + if (pointColl.GetFloorHeight() <= item.Pose.Position.y - bounds.Y2) { if (!isWater) { - item.Pose.Position.y = item.Pose.Position.y - item.Animation.Velocity.y; + item.Pose.Position.y = pointColl.GetFloorHeight(); SoundEffect(SFX_TR4_CROCGOD_LAND, &item.Pose); } - else + else { - item.Pose.Position.y = item.Pose.Position.y; + item.Pose.Position.y = pointColl.GetFloorHeight(); } item.Animation.IsAirborne = false; item.Animation.Velocity = Vector3::Zero; item.Animation.TargetState = CORPSE_STATE_LAND; item.Animation.AnimNumber = object.animIndex + CORPSE_ANIM_LAND; - AlignEntityToSurface(&item, Vector2(object.radius)); - item.ItemFlags[1] = (int)CorpseFlag::Grounded; + item.ItemFlags[7] = (int)CorpseFlag::Grounded; return; } - else + else if (item.Animation.ActiveState == CORPSE_STATE_FALL) { if (isWater) { @@ -133,17 +152,56 @@ namespace TEN::Entities::TR3 AnimateItem(&item); - if (!TriggerActive(&item)) - return; - - int meshCount = object.nmeshes; - for (int i = 0; i < meshCount; i++) + if (!TriggerActive(&item) || item.ItemFlags[FirefliesItemFlags::RemoveFliesEffect] == 1) { - if (Random::TestProbability(1 / 72.0f)) + // Remove all fireflies associated with this item. + RemoveFireflies(item); + + // Reset ItemFlags. + if (item.HitPoints == NOT_TARGETABLE) + item.HitPoints = FLY_AMOUNT; + + item.ItemFlags[FirefliesItemFlags::Spawncounter] = 0; + + return; + } + else + { + AddActiveItem(itemNumber); + item.Status = ITEM_ACTIVE; + } + + // Spawn fly effect. + if (item.HitPoints != NOT_TARGETABLE) + { + int fireflyCount = item.HitPoints - item.ItemFlags[FirefliesItemFlags::Spawncounter]; + + if (fireflyCount < 0) { - auto pos = GetJointPosition(&item, i).ToVector3(); - SpawnCorpseEffect(pos); + int firefliesToTurnOff = -fireflyCount; + for (auto& firefly : FireflySwarm) + { + if (firefly.TargetItemPtr == &item && firefly.Life > 0.0f) + { + firefly.Life = 0.0f; + firefly.on = false; + firefliesToTurnOff--; + + if (firefliesToTurnOff == 0) + break; + } + } } + else if (fireflyCount > 0) + { + for (int i = 0; i < fireflyCount; i++) + { + SpawnFireflySwarm(item, FLY_EFFECT_MAX_WIDTH); + } + } + + item.ItemFlags[FirefliesItemFlags::Spawncounter] = item.HitPoints; + item.HitPoints = NOT_TARGETABLE; } } @@ -160,9 +218,9 @@ namespace TEN::Entities::TR3 { DoBloodSplat(pos->x, pos->y, pos->z, Random::GenerateInt(4, 8), source.Pose.Orientation.y, pos->RoomNumber); - if (target.ItemFlags[1] == (int)CorpseFlag::Hang) + if (target.ItemFlags[7] == (int)CorpseFlag::Hang) { - target.ItemFlags[1] = (int)CorpseFlag::Fall; + target.ItemFlags[7] = (int)CorpseFlag::Fall; target.Animation.AnimNumber = object.animIndex + CORPSE_ANIM_FALL; target.Animation.ActiveState = CORPSE_STATE_FALL; } diff --git a/TombEngine/Objects/TR4/Entity/Wraith.cpp b/TombEngine/Objects/TR4/Entity/Wraith.cpp index 75b719344..e84ada397 100644 --- a/TombEngine/Objects/TR4/Entity/Wraith.cpp +++ b/TombEngine/Objects/TR4/Entity/Wraith.cpp @@ -84,21 +84,21 @@ namespace TEN::Entities::TR4 item.Index, (int)TailTag::First, pos, dir0, orient2D, colorStart, COLOR_END, WIDTH, LIFE_MAX, VEL, EXP_RATE, 0, - StreamerFeatherType::Center, BlendMode::Additive); + StreamerFeatherMode::Center, BlendMode::Additive); // Spawn second tail. StreamerEffect.Spawn( item.Index, (int)TailTag::Second, pos, dir1, orient2D, colorStart, COLOR_END, WIDTH, LIFE_MAX, VEL, EXP_RATE, 0, - StreamerFeatherType::Center, BlendMode::Additive); + StreamerFeatherMode::Center, BlendMode::Additive); // Spawn third tail. StreamerEffect.Spawn( item.Index, (int)TailTag::Third, pos, dir2, orient2D, colorStart, COLOR_END, WIDTH, LIFE_MAX, VEL, EXP_RATE, 0, - StreamerFeatherType::Center, BlendMode::Additive); + StreamerFeatherMode::Center, BlendMode::Additive); } static void WraithWallEffect(Vector3i pos, short yRot, int objectNumber) @@ -308,6 +308,11 @@ namespace TEN::Entities::TR4 item.Pose.Orientation.x += angleV; } + // Translate wraith. + item.Pose.Position.x += item.Animation.Velocity.z * phd_sin(item.Pose.Orientation.y); + item.Pose.Position.y += item.Animation.Velocity.z * phd_sin(item.Pose.Orientation.x); + item.Pose.Position.z += item.Animation.Velocity.z * phd_cos(item.Pose.Orientation.y); + auto pointColl = GetPointCollision(item); bool hasHitWall = false; @@ -317,13 +322,8 @@ namespace TEN::Entities::TR4 hasHitWall = true; } - // Translate wraith. - item.Pose.Position.x += item.Animation.Velocity.z * phd_sin(item.Pose.Orientation.y); - item.Pose.Position.y += item.Animation.Velocity.z * phd_sin(item.Pose.Orientation.x); - item.Pose.Position.z += item.Animation.Velocity.z * phd_cos(item.Pose.Orientation.y); - if (pointColl.GetRoomNumber() != item.RoomNumber) - ItemNewRoom(itemNumber, pointColl.GetRoomNumber()); + ItemNewRoom(itemNumber, FindRoomNumber(item.Pose.Position, item.RoomNumber)); for (int linkItemNumber = g_Level.Rooms[item.RoomNumber].itemNumber; linkItemNumber != NO_VALUE; linkItemNumber = g_Level.Items[linkItemNumber].NextItem) { diff --git a/TombEngine/Objects/TR4/Object/StatuePlinth.cpp b/TombEngine/Objects/TR4/Object/StatuePlinth.cpp new file mode 100644 index 000000000..bf1ee0b93 --- /dev/null +++ b/TombEngine/Objects/TR4/Object/StatuePlinth.cpp @@ -0,0 +1,157 @@ +#include "framework.h" +#include "Objects/TR4/Object/StatuePlinth.h" + +#include "Game/animation.h" +#include "Game/collision/collide_room.h" +#include "Game/collision/collide_item.h" +#include "Game/control/control.h" +#include "Game/effects/effects.h" +#include "Game/effects/tomb4fx.h" +#include "Game/Gui.h" +#include "Game/items.h" +#include "Game/Lara/lara.h" +#include "Game/Lara/lara_helpers.h" +#include "Game/pickup/pickup.h" +#include "Game/Setup.h" +#include "Sound/sound.h" +#include "Specific/Input/Input.h" +#include "Specific/level.h" + +using namespace TEN::Gui; +using namespace TEN::Input; + +namespace TEN::Entities::TR4 +{ + constexpr auto PLACE_PLINTHITEM_FRAME = 45; + + const auto KeyHolePosition = Vector3i(0, 0, -390); + const ObjectCollisionBounds KeyHoleBounds = + { + GameBoundingBox( + -CLICK(1), CLICK(1), + -BLOCK(0.5f), 0, + -BLOCK(0.5f), 0), + std::pair( + EulerAngles(ANGLE(-10.0f), ANGLE(-30.0f), ANGLE(-10.0f)), + EulerAngles(ANGLE(10.0f), ANGLE(30.0f), ANGLE(10.0f))) + }; + + void InitializeStatuePlinth(short itemNumber) + { + auto* item = &g_Level.Items[itemNumber]; + + // Hide mesh 1. + item->MeshBits = 1; + } + + void CollideStatuePlinth(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll) + { + auto& keyHoleItem = g_Level.Items[itemNumber]; + const auto& player = GetLaraInfo(playerItem); + + short* triggerIndexPtr = GetTriggerIndex(&keyHoleItem); + + if (!keyHoleItem.ItemFlags[0]) + keyHoleItem.ItemFlags[0] = PLACE_PLINTHITEM_FRAME; + + GAME_OBJECT_ID keyItem; + + // There are only 16 puzzle items. -1 is added to keep OCB aligned with puzzle item number. + if (keyHoleItem.TriggerFlags < 17 && keyHoleItem.TriggerFlags > 0) + { + keyItem = GAME_OBJECT_ID(keyHoleItem.TriggerFlags + ID_PUZZLE_ITEM1 - 1); + + } + else + { + keyItem = ID_PUZZLE_ITEM1; + } + + if (triggerIndexPtr == nullptr) + return; + + short triggerType = (*(triggerIndexPtr++) >> 8) & TRIGGER_BITS; + + bool hasAction = (IsHeld(In::Action) || g_Gui.GetInventoryItemChosen() != NO_VALUE); + bool isPlayerAvailable = (player->Control.Look.OpticRange == 0 && + playerItem->Animation.ActiveState == LS_IDLE && + playerItem->Animation.AnimNumber == LA_STAND_IDLE); + + if (hasAction && isPlayerAvailable && !keyHoleItem.ItemFlags[3]) + { + if (!keyHoleItem.ItemFlags[1]) + { + short prevYOrient = keyHoleItem.Pose.Orientation.y; + + int quadrant = GetQuadrant(LaraItem->Pose.Orientation.y); + keyHoleItem.DisableInterpolation = true; + switch (quadrant) + { + case NORTH: + keyHoleItem.Pose.Orientation.y = ANGLE(0.0f); + break; + + case EAST: + keyHoleItem.Pose.Orientation.y = ANGLE(90.0f); + break; + + case SOUTH: + keyHoleItem.Pose.Orientation.y = ANGLE(180.0f); + break; + + case WEST: + keyHoleItem.Pose.Orientation.y = ANGLE(270.0f); + break; + + default: + break; + } + + if (TestLaraPosition(KeyHoleBounds, &keyHoleItem, playerItem)) + { + if (g_Gui.IsObjectInInventory(keyItem)) + { + g_Gui.SetEnterInventory(keyItem); + keyHoleItem.ItemFlags[1] = 1; + } + } + + keyHoleItem.Pose.Orientation.y = prevYOrient; + return; + } + + if (g_Gui.GetInventoryItemChosen() == keyItem) + { + ResetPlayerFlex(playerItem); + SetAnimation(*playerItem, LA_PICKUP_PEDESTAL_HIGH); + playerItem->Animation.ActiveState = LS_INSERT_KEY; + + player->Control.HandStatus = HandStatus::Busy; + g_Gui.SetInventoryItemChosen(NO_VALUE); + keyHoleItem.ItemFlags[2] = 1; + return; + } + } + + if (playerItem->Animation.AnimNumber == LA_PICKUP_PEDESTAL_HIGH && + playerItem->Animation.FrameNumber == (GetAnimData(LA_PICKUP_PEDESTAL_HIGH).frameBase + keyHoleItem.ItemFlags[0]) && + keyHoleItem.ItemFlags[2]) + { + TestTriggers(&keyHoleItem, true, keyHoleItem.Flags & 0x3E00); + keyHoleItem.Flags |= TRIGGERED; + keyHoleItem.Status = ITEM_ACTIVE; + keyHoleItem.MeshBits = 255; + + // TODO: Allow meshswap of puzzle items. + //keyHoleItem.Model.MeshIndex[1] = Objects[keyItem].meshIndex + 0; + //keyHoleItem.Model.Mutators[0].Offset = Vector3(0.0f, -896.0f, 0.0f); + keyHoleItem.ItemFlags[3] = 1; + RemoveObjectFromInventory(keyItem, 1); + } + else + { + keyHoleItem.ItemFlags[1] = 0; + ObjectCollision(itemNumber, playerItem, coll); + } + } +} diff --git a/TombEngine/Objects/TR4/Object/StatuePlinth.h b/TombEngine/Objects/TR4/Object/StatuePlinth.h new file mode 100644 index 000000000..b4bdce750 --- /dev/null +++ b/TombEngine/Objects/TR4/Object/StatuePlinth.h @@ -0,0 +1,10 @@ +#pragma once + +struct CollisionInfo; +struct ItemInfo; + +namespace TEN::Entities::TR4 +{ + void InitializeStatuePlinth(short itemNumber); + void CollideStatuePlinth(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll); +} diff --git a/TombEngine/Objects/TR4/tr4_objects.cpp b/TombEngine/Objects/TR4/tr4_objects.cpp index 441ec3b40..f91d32c9f 100644 --- a/TombEngine/Objects/TR4/tr4_objects.cpp +++ b/TombEngine/Objects/TR4/tr4_objects.cpp @@ -43,6 +43,7 @@ #include "Objects/TR4/Entity/tr4_setha.h" // Objects +#include "Objects/TR4/Object/StatuePlinth.h" #include "Objects/TR4/Object/WraithTrap.h" #include "Objects/TR4/Object/tr4_element_puzzle.h" #include "Objects/TR4/Object/tr4_mapper.h" @@ -695,6 +696,14 @@ namespace TEN::Entities obj->SetHitEffect(true); } + obj = &Objects[ID_STATUE_PLINTH]; + if (obj->loaded) + { + obj->Initialize = InitializeStatuePlinth; + obj->collision = CollideStatuePlinth; + obj->SetHitEffect(true); + } + obj = &Objects[ID_WHEEL_OF_FORTUNE]; if (obj->loaded) { diff --git a/TombEngine/Objects/TR5/Emitter/tr5_smoke_emitter.cpp b/TombEngine/Objects/TR5/Emitter/tr5_smoke_emitter.cpp index 2febc14b8..a7e748787 100644 --- a/TombEngine/Objects/TR5/Emitter/tr5_smoke_emitter.cpp +++ b/TombEngine/Objects/TR5/Emitter/tr5_smoke_emitter.cpp @@ -140,8 +140,11 @@ namespace TEN::Effects::SmokeEmitter bool ignoreDamage = item.ItemFlags[3] & SmokeEmitterFlags::NoDamage; if (!ignoreDamage && TestGlobalTimeInterval(DAMAGE_TIME_INTERVAL)) + { part.flags |= SP_DAMAGE; - + part.damage = 2; + } + part.rotAng = Random::GenerateAngle(ANGLE(0.0f), ANGLE(22.5f)); part.rotAdd = Random::GenerateAngle(ANGLE(0.04f), ANGLE(0.08f)) * (Random::TestProbability(1 / 2.0f) ? 1 : -1); @@ -384,7 +387,7 @@ namespace TEN::Effects::SmokeEmitter steamPauseTimer = item.TriggerFlags >> 4; } - SoundEffect(SFX_TEN_STEAM_EMITTER_LOOP, &item.Pose); + SoundEffect(SFX_TR4_STEAM_EMITTER_LOOP, &item.Pose); } if (!drawNormalSmoke) diff --git a/TombEngine/Objects/TR5/Object/tr5_teleporter.cpp b/TombEngine/Objects/TR5/Object/tr5_teleporter.cpp index 6ebb9961a..a71934996 100644 --- a/TombEngine/Objects/TR5/Object/tr5_teleporter.cpp +++ b/TombEngine/Objects/TR5/Object/tr5_teleporter.cpp @@ -1,28 +1,18 @@ #include "framework.h" -#include "tr5_teleporter.h" -#include "Game/items.h" -#include "Specific/level.h" -#include "Game/collision/collide_room.h" -#include "Sound/sound.h" -#include "Game/effects/weather.h" -#include "Game/Lara/lara.h" +#include "Objects/TR5/Object/tr5_teleporter.h" + #include "Game/camera.h" +#include "Game/collision/collide_room.h" +#include "Game/collision/Point.h" +#include "Game/effects/weather.h" +#include "Game/items.h" +#include "Game/Lara/lara.h" +#include "Sound/sound.h" +#include "Specific/level.h" +using namespace TEN::Collision::Point; using namespace TEN::Effects::Environment; -void InitializeTeleporter(short itemNumber) -{ - /*ItemInfo* item = &g_Level.Items[itemNumber]; - - if (item->triggerFlags == 512) - { - ItemInfo* puzzleHoleItem = FindItem(ID_PUZZLE_HOLE2); - v4 = (signed int)((unsigned __int64)(391146079i64 * ((char*)v3 - (char*)items)) >> 32) >> 9; - result = (unsigned int)((unsigned __int64)(391146079i64 * ((char*)v3 - (char*)items)) >> 32) >> 31; - item->itemFlags[1] = result + v4; - }*/ -} - void ControlTeleporter(short itemNumber) { ItemInfo* item = &g_Level.Items[itemNumber]; @@ -30,149 +20,6 @@ void ControlTeleporter(short itemNumber) if (!TriggerActive(item)) return; - /*if (item->triggerFlags == 512) - { - if (item->itemFlags[2]) - { - Lara.Puzzles[1] = 1; - RemoveActiveItem(itemNumber); - item->flags &= 0xC1FF; - } - else - { - item->itemFlags[0] += 2; - - if (item->itemFlags[0] <= 255) - { - int flags = item->itemFlags[0] >> 3; - if (flags >= 4) - { - if (flags > 31) - flags = 31; - } - else - { - flags = 4; - } - - ItemInfo* targetItem = &g_Level.Items[item->itemFlags[1]]; - SoundEffect(SFX_TR5_TELEPORT, &targetItem->pos, SoundEnvironment::Land); - - if (GlobalCounter & 1) - { - Vector3i src; - pos.x = targetItem->pos.Position.x; - pos.y = targetItem->pos.Position.y - 496; - pos.z = targetItem->pos.Position.z + 472; - - int dl = 4 * item->itemFlags[0] + 256; - - Vector3i dest; - dest.x = src.x + GetRandomControl() % dl - (dl >> 1); - dest.y = src.y + GetRandomControl() % dl - (dl >> 1); - dest.z = src.z + GetRandomControl() % dl - (dl >> 1); - - int color = (item->itemFlags[0] >> 2) | (((item->itemFlags[0] - (GetRandomControl() % (item->itemFlags[0] >> 1))) | (item->itemFlags[0] << 8)) << 8); - color |= 0x18; // BYTE1 - - //TriggerEnergyArc(&src, &dest, (GetRandomControl() & 0x1F) + 16, color, 15, 40, 5); - - v20 = v16; - v21 = v12 & 0xFFFFFFFE; - LOBYTE(v20) = v16 & 0xFE; - BYTE1(v21) |= 0x80u; - TriggerLightningGlow(src.x, src.y, src.z, (item->itemFlags[0] >> 3) | ((v20 | (v21 << 8)) << 7)); - v22 = GetRandomControl(); - SpawnDynamicLight(src.x, src.y, src.z, (v22 & 3) + (item->itemFlags[0] >> 5) + 8, v12, v16, v13); - } - LOBYTE(v3) = GetRandomControl(); - if (v3 & 1) - { - v23 = item->itemFlags[0]; - v24 = item->itemFlags[0]; - v25 = GetRandomControl(); - - auto R = v23; - auto G = v24 - v25 % (v24 >> 1); - auto B = v24 >> 2; - Weather.Flash(R, G, B, 0.03f); - - LOBYTE(v3) = SoundEffect(SFX_TR5_TELEPORT_CRACKLES, nullptr); - } - if (!(GlobalCounter & 3)) - { - v26 = GetRandomControl(); - v27 = 0; - v28 = v26 & 3; - v29 = 0; - if (v28) - { - if (v28 == 1) - v29 = 512; - else - v27 = v28 != 2 ? 512 : -512; - } - else - { - v29 = -512; - } - v30 = item->itemFlags[0]; - v31 = &g_Level.Items[item->itemFlags[1]]; - src.Position.x = v29 + v31->pos.Position.x; - src.Position.y = v31->pos.Position.y - 2328; - src.zPos = v27 + v31->pos.Position.z; - *(_DWORD*)& src.xRot = v31->pos.Position.x; - v32 = item->itemFlags[0]; - *(_DWORD*)& src.zRot = v31->pos.Position.y - 496; - v45 = v31->pos.Position.z + 472; - v33 = (v30 >> 2) | (((v30 - GetRandomControl() % (v30 >> 1)) | ((v32 | 0x2400) << 8)) << 8); - v34 = GetRandomControl(); - TriggerEnergyArc((Vector3i*)& src, (Vector3i*)& src.xRot, (v34 & 0xF) + 16, v33, 13, 56, 5); - v35* = GetFreeParticle(); - v35->On = 1; - v36 = item->itemFlags[0]; - v35->dR = v36; - v35->sR = v36; - v37 = item->itemFlags[0] >> 1; - v35->dG = v37; - v35->sG = v37; - v38 = item->itemFlags[0]; - v35->ColFadeSpeed = 20; - v38 >>= 2; - v35->dB = v38; - v35->sB = v38; - v35->FadeToBlack = 4; - v35->Life = 24; - v35->sLife = 24; - v35->blendMode = BlendMode::Additive; - v35->x = src.Position.x; - v35->y = src.Position.y; - v35->z = src.zPos; - v35->Zvel = 0; - v35->Yvel = 0; - v35->Xvel = 0; - v35->Flags = 10; - v39 = objects[458].mesh_index; - v35->Scalar = 3; - v35->MaxYvel = 0; - v35->Def = v39 + 11; - v35->Gravity = 0; - v3 = (GetRandomControl() & 3) + 24; - v35->dSize = v3; - v35->sSize = v3; - v35->Size = v3; - } - return v3; - } - FlashFadeR = 255; - FlashFadeG = 255; - FlashFadeB = 64; - FlashFader = 32; - item->itemFlags[2] = 1; - SoundEffect(SFX_TR5_TELEPORT_FLASH, nullptr, SoundEnvironment::Land); - } - }*/ - Lara.Control.IsLocked = false; if (item->TriggerFlags == 666) @@ -192,16 +39,19 @@ void ControlTeleporter(short itemNumber) else { Camera.fixedCamera = true; + LaraItem->DisableInterpolation = true; LaraItem->Pose.Position.x = item->Pose.Position.x; LaraItem->Pose.Position.z = item->Pose.Position.z; LaraItem->Pose.Orientation.y = item->Pose.Orientation.y - ANGLE(180.0f); - short roomNumber = item->RoomNumber; - FloorInfo* floor = GetFloor(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, &roomNumber); - LaraItem->Pose.Position.y = GetFloorHeight(floor, item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z); + auto& pointColl = GetPointCollision(*item); + LaraItem->Pose.Position.y = pointColl.GetPosition().y; - if (LaraItem->RoomNumber != roomNumber) - ItemNewRoom(LaraItem->Index, roomNumber); + if (LaraItem->RoomNumber != pointColl.GetRoomNumber()) + { + ItemNewRoom(LaraItem->Index, pointColl.GetRoomNumber()); + LaraItem->Location.RoomNumber = pointColl.GetRoomNumber(); + } if (item->Flags & IFLAG_INVISIBLE) { diff --git a/TombEngine/Objects/TR5/Object/tr5_teleporter.h b/TombEngine/Objects/TR5/Object/tr5_teleporter.h index 547ddcaba..dde7fc827 100644 --- a/TombEngine/Objects/TR5/Object/tr5_teleporter.h +++ b/TombEngine/Objects/TR5/Object/tr5_teleporter.h @@ -1,4 +1,3 @@ #pragma once -void InitializeTeleporter(short itemNumber); void ControlTeleporter(short itemNumber); diff --git a/TombEngine/Objects/TR5/Trap/MovingLaser.cpp b/TombEngine/Objects/TR5/Trap/MovingLaser.cpp new file mode 100644 index 000000000..830d14746 --- /dev/null +++ b/TombEngine/Objects/TR5/Trap/MovingLaser.cpp @@ -0,0 +1,146 @@ +#include "framework.h" +#include "Objects/TR5/Trap/MovingLaser.h" + +#include "Game/animation.h" +#include "Game/collision/collide_item.h" +#include "Game/collision/collide_room.h" +#include "Game/collision/Point.h" +#include "Game/collision/Sphere.h" +#include "Game/control/control.h" +#include "Game/effects/effects.h" +#include "Game/effects/light.h" +#include "Game/items.h" +#include "Game/Lara/lara.h" +#include "Sound/sound.h" +#include "Specific/level.h" + +using namespace TEN::Collision::Sphere; + +namespace TEN::Entities::Traps +{ + constexpr auto MOVING_LASER_DAMAGE = 100; + constexpr auto MOVING_LASER_VELOCITY_MIN = 1.0f; + constexpr auto MOVING_LASER_ACCEL = 1.0f; + constexpr auto MOVING_LASER_PAUSE_FRAME_COUNT = 30; + + enum class MovingLaserFlags + { + Velocity, + PauseTimer, + DirectionSign, + DistanceTraveled, + VelocityCalc + }; + + void InitializeMovingLaser(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + item.ItemFlags[(int)MovingLaserFlags::DirectionSign] = 1; + item.ItemFlags[(int)MovingLaserFlags::Velocity] = 10; + + // Offset by 1/4 block to make it dangerous at sector edges. + item.Pose.Translate(item.Pose.Orientation, -BLOCK(0.25f)); + } + + void ControlMovingLaser(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + + if (!TriggerActive(&item)) + return; + + // Calculate distances. + float moveDist = BLOCK(item.TriggerFlags) + BLOCK(0.5f); + float distPerFrame = (BLOCK(item.ItemFlags[(int)MovingLaserFlags::Velocity]) * 0.25f) / (float)FPS; + + item.Animation.ActiveState = 0; + + // TODO: Use SpawnDynamicPointLight(). + SpawnDynamicLight( + item.Pose.Position.x, item.Pose.Position.y - 64, item.Pose.Position.z, (Random::GenerateInt() % 2) + 8, + (Random::GenerateInt() % 4) + 24, Random::GenerateInt() % 4, Random::GenerateInt() % 2); + /*auto lightPos = item.Pose.Position.ToVector3() + Vector3(0.0f, -64, 0.0f); + auto lightColor = Color(Random::GenerateFloat(0.1f, 0.2f), Random::GenerateFloat(0.0f, 0.01f), Random::GenerateFloat(Random::GenerateFloat(0.0f, 0.01f))); + float lightFalloff = ?? + SpawnDynamicPointLight(lightPos, lightPos, lightFalloff);*/ + + // TODO: Demagic. + // Used for flicker. + item.MeshBits = -1 - (GetRandomControl() & 20); + + if (item.TriggerFlags == 0) + { + AnimateItem(&item); + return; + } + + if (item.ItemFlags[(int)MovingLaserFlags::PauseTimer] > 0) + { + item.ItemFlags[(int)MovingLaserFlags::PauseTimer]--; + if (item.ItemFlags[(int)MovingLaserFlags::PauseTimer] == 0) + { + item.ItemFlags[(int)MovingLaserFlags::DirectionSign] *= -1; + item.ItemFlags[(int)MovingLaserFlags::DistanceTraveled] = 0; + } + + AnimateItem(&item); + return; + } + + item.Pose.Translate(item.Pose.Orientation, (item.ItemFlags[(int)MovingLaserFlags::DirectionSign] * item.ItemFlags[(int)MovingLaserFlags::VelocityCalc])); + + item.ItemFlags[(int)MovingLaserFlags::DistanceTraveled] += item.ItemFlags[(int)MovingLaserFlags::VelocityCalc]; + + if (item.ItemFlags[(int)MovingLaserFlags::DistanceTraveled] < (moveDist - BLOCK(0.5f))) + { + item.ItemFlags[(int)MovingLaserFlags::VelocityCalc] = std::min(distPerFrame, item.ItemFlags[(int)MovingLaserFlags::VelocityCalc] + MOVING_LASER_ACCEL); + } + else + { + item.ItemFlags[(int)MovingLaserFlags::VelocityCalc] = std::max(MOVING_LASER_VELOCITY_MIN, item.ItemFlags[(int)MovingLaserFlags::VelocityCalc] - MOVING_LASER_ACCEL); + } + + if (item.ItemFlags[(int)MovingLaserFlags::DistanceTraveled] >= moveDist) + { + item.ItemFlags[(int)MovingLaserFlags::PauseTimer] = MOVING_LASER_PAUSE_FRAME_COUNT; + } + + if (item.ItemFlags[(int)MovingLaserFlags::PauseTimer] == 0) + { + SoundEffect(SFX_TR5_MOVING_LASER_LOOP, &item.Pose, SoundEnvironment::Always); + } + + // Update room if necessary. + int roomNumber = GetPointCollision(item).GetRoomNumber(); + if (roomNumber != item.RoomNumber) + ItemNewRoom(itemNumber, roomNumber); + + AnimateItem(&item); + } + + void CollideMovingLaser(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll) + { + auto& item = g_Level.Items[itemNumber]; + + // Collide with objects. + if (item.Status == ITEM_ACTIVE) + { + if (!TestBoundsCollide(&item, playerItem, coll->Setup.Radius)) + return; + + HandleItemSphereCollision(item, *playerItem); + } + else if (item.Status != ITEM_INVISIBLE) + { + ObjectCollision(itemNumber, playerItem, coll); + } + + // Damage player. + if (TestBoundsCollide(&item, playerItem, coll->Setup.Radius)) + { + DoDamage(playerItem, MOVING_LASER_DAMAGE); + DoLotsOfBlood(playerItem->Pose.Position.x, playerItem->Pose.Position.y + CLICK(3), playerItem->Pose.Position.z, 4, playerItem->Pose.Orientation.y, playerItem->RoomNumber, 3); + playerItem->TouchBits.ClearAll(); + } + } +} diff --git a/TombEngine/Objects/TR5/Trap/MovingLaser.h b/TombEngine/Objects/TR5/Trap/MovingLaser.h new file mode 100644 index 000000000..5884c63cf --- /dev/null +++ b/TombEngine/Objects/TR5/Trap/MovingLaser.h @@ -0,0 +1,11 @@ +#pragma once + +struct CollisionInfo; +struct ItemInfo; + +namespace TEN::Entities::Traps +{ + void InitializeMovingLaser(short itemNumber); + void ControlMovingLaser(short itemNumber); + void CollideMovingLaser(short itemNumber, ItemInfo* item, CollisionInfo* coll); +} diff --git a/TombEngine/Objects/TR5/tr5_objects.cpp b/TombEngine/Objects/TR5/tr5_objects.cpp index 794f4da20..76c70133f 100644 --- a/TombEngine/Objects/TR5/tr5_objects.cpp +++ b/TombEngine/Objects/TR5/tr5_objects.cpp @@ -42,6 +42,7 @@ #include "Objects/TR5/Emitter/tr5_spider_emitter.h" #include "Objects/TR5/Emitter/tr5_smoke_emitter.h" #include "Objects/TR5/Emitter/Waterfall.h" +#include "Objects/Effects/Fireflies.h" // Objects #include "Objects/TR5/Light/tr5_light.h" @@ -57,10 +58,11 @@ // Traps #include "Objects/Effects/EmberEmitter.h" -#include "Objects/Effects/tr5_electricity.h" #include "Objects/TR5/Trap/LaserBarrier.h" #include "Objects/TR5/Trap/LaserBeam.h" +#include "Objects/TR5/Trap/MovingLaser.h" #include "Objects/TR5/Trap/ZipLine.h" +#include "Objects/Effects/tr5_electricity.h" #include "Objects/TR5/Object/tr5_rollingball.h" #include "Objects/TR5/Trap/tr5_ventilator.h" #include "Objects/TR5/Trap/tr5_romehammer.h" @@ -80,6 +82,7 @@ using namespace TEN::Effects::WaterfallEmitter; using namespace TEN::Entities::Creatures::TR5; using namespace TEN::Entities::Switches; using namespace TEN::Entities::Traps; +using namespace TEN::Effects::Fireflies; static void StartEntity(ObjectInfo *obj) { @@ -771,7 +774,6 @@ static void StartObject(ObjectInfo *obj) obj = &Objects[ID_TELEPORTER]; if (obj->loaded) { - obj->Initialize = InitializeTeleporter; obj->control = ControlTeleporter; obj->drawRoutine = nullptr; } @@ -795,6 +797,14 @@ static void StartObject(ObjectInfo *obj) obj->control = ControlEmberEmitter; } + obj = &Objects[ID_FIREFLY_EMITTER]; + if (obj->loaded) + { + obj->Initialize = InitializeFireflySwarm; + obj->control = ControlFireflySwarm; + obj->drawRoutine = NULL; + } + obj = &Objects[ID_GEN_SLOT1]; if (obj->loaded) { @@ -963,6 +973,15 @@ static void StartTrap(ObjectInfo *obj) obj->drawRoutine = nullptr; obj->usingDrawAnimatingItem = false; } + + obj = &Objects[ID_MOVING_LASER]; + if (obj->loaded) + { + obj->Initialize = InitializeMovingLaser; + obj->control = ControlMovingLaser; + obj->collision = CollideMovingLaser; + obj->SetHitEffect(true); + } } static void StartSwitch(ObjectInfo *obj) diff --git a/TombEngine/Objects/Utils/VehicleHelpers.cpp b/TombEngine/Objects/Utils/VehicleHelpers.cpp index 85ae29007..d17ca1ae3 100644 --- a/TombEngine/Objects/Utils/VehicleHelpers.cpp +++ b/TombEngine/Objects/Utils/VehicleHelpers.cpp @@ -300,17 +300,17 @@ namespace TEN::Entities::Vehicles void ModulateVehicleTurnRateX(short* turnRate, short accelRate, short minTurnRate, short maxTurnRate) { - *turnRate = ModulateVehicleTurnRate(*turnRate, accelRate, minTurnRate, maxTurnRate, -AxisMap[(int)InputAxis::Move].y); + *turnRate = ModulateVehicleTurnRate(*turnRate, accelRate, minTurnRate, maxTurnRate, -AxisMap[InputAxisID::Move].y); } void ModulateVehicleTurnRateY(short* turnRate, short accelRate, short minTurnRate, short maxTurnRate) { - *turnRate = ModulateVehicleTurnRate(*turnRate, accelRate, minTurnRate, maxTurnRate, AxisMap[(int)InputAxis::Move].x); + *turnRate = ModulateVehicleTurnRate(*turnRate, accelRate, minTurnRate, maxTurnRate, AxisMap[InputAxisID::Move].x); } void ModulateVehicleLean(ItemInfo* vehicleItem, short baseRate, short maxAngle) { - float axisCoeff = AxisMap[(int)InputAxis::Move].x; + float axisCoeff = AxisMap[InputAxisID::Move].x; int sign = copysign(1, axisCoeff); short maxAngleNormalized = maxAngle * axisCoeff; vehicleItem->Pose.Orientation.z += std::min(baseRate, abs(maxAngleNormalized - vehicleItem->Pose.Orientation.z) / 3) * sign; @@ -385,14 +385,14 @@ namespace TEN::Entities::Vehicles vehicleItem.Index, (int)tagLeft, positions.first, dir, orient2D, COLOR_START, COLOR_END, 0.0f, life, vel, expRate, 0, - StreamerFeatherType::Right, BlendMode::Additive); + StreamerFeatherMode::Right, BlendMode::Additive); // Spawn right wake. StreamerEffect.Spawn( vehicleItem.Index, (int)tagRight, positions.second, dir, orient2D, COLOR_START, COLOR_END, 0.0f, life, vel, expRate, 0, - StreamerFeatherType::Left, BlendMode::Additive); + StreamerFeatherMode::Left, BlendMode::Additive); } void HandleVehicleSpeedometer(float vel, float velMax) diff --git a/TombEngine/Objects/game_object_ids.h b/TombEngine/Objects/game_object_ids.h index 1aa0ebdb1..e724861e3 100644 --- a/TombEngine/Objects/game_object_ids.h +++ b/TombEngine/Objects/game_object_ids.h @@ -371,6 +371,9 @@ enum GAME_OBJECT_ID : short ID_SWINGING_BLADE, ID_ELECTRIC_BALL, ID_ELECTRIC_BALL_IMPACT_POINT, + ID_THOR_HAMMER_HANDLE, + ID_THOR_HAMMER_HEAD, + ID_MOVING_LASER, ID_PUZZLE_ITEM1 = 500, ID_PUZZLE_ITEM2, @@ -627,10 +630,10 @@ enum GAME_OBJECT_ID : short ID_SHOOT_SWITCH3, ID_SHOOT_SWITCH4, ID_AIRLOCK_SWITCH, - ID_UNDERWATER_WALL_SWITCH_1, - ID_UNDERWATER_WALL_SWITCH_2, - ID_UNDERWATER_CEILING_SWITCH_1, - ID_UNDERWATER_CEILING_SWITCH_2, + ID_UNDERWATER_WALL_SWITCH1, + ID_UNDERWATER_WALL_SWITCH2, + ID_UNDERWATER_CEILING_SWITCH1, + ID_UNDERWATER_CEILING_SWITCH2, ID_TURN_SWITCH, ID_COG_SWITCH, ID_LEVER_SWITCH, @@ -743,7 +746,7 @@ enum GAME_OBJECT_ID : short ID_INVENTORY_SUNGLASSES, ID_INVENTORY_KEYS, ID_INVENTORY_HEADPHONES, - ID_INVENTORY_POLAROID, + ID_INVENTORY_PHOTO, ID_SMOKE_EMITTER_WHITE = 1020, ID_SMOKE_EMITTER_BLACK, @@ -814,6 +817,7 @@ enum GAME_OBJECT_ID : short ID_CORPSE, ID_WRAITH_TRAP, ID_WATERFALL_EMITTER, + ID_FIREFLY_EMITTER, ID_MESHSWAP1 = 1100, ID_MESHSWAP2, @@ -976,9 +980,10 @@ enum GAME_OBJECT_ID : short ID_BRIDGE_CUSTOM, ID_HORIZON = 1350, - ID_BINOCULAR_GRAPHICS, - ID_TARGET_GRAPHICS, - ID_SKY_GRAPHICS, + + // Sprite sequences. + + ID_SKY_GRAPHICS = 1353, ID_DEFAULT_SPRITES, ID_MISC_SPRITES, ID_CUSTOM_SPRITES, @@ -993,20 +998,20 @@ enum GAME_OBJECT_ID : short ID_SKIDOO_SNOW_TRAIL_SPRITES, ID_KAYAK_PADDLE_TRAIL_SPRITE, ID_KAYAK_WAKE_SPRTIES, - ID_BINOCULAR_GRAPHIC, - ID_LASER_SIGHT_GRAPHIC, - ID_CAUSTICS_TEXTURES, - ID_BAR_BORDER_GRAPHIC, + ID_BINOCULAR_GRAPHICS, + ID_LASERSIGHT_GRAPHICS, + ID_CAUSTIC_TEXTURES, + ID_BAR_BORDER_GRAPHICS, ID_HEALTH_BAR_TEXTURE, ID_AIR_BAR_TEXTURE, ID_DASH_BAR_TEXTURE, ID_SFX_BAR_TEXTURE, ID_WATERFALL_SPRITES, - // 1379 - ID_CROSSHAIR = 1380, - ID_SPEEDOMETER, - ID_CUSTOM_BAR_GRAPHIC, - ID_CUSTOM_AMMO_GRAPHIC, + ID_FIREFLY_SPRITES, + ID_CROSSHAIR_GRAPHICS, + ID_SPEEDOMETER_GRAPHICS, + ID_CUSTOM_BAR_GRAPHICS, + ID_CUSTOM_AMMO_GRAPHICS, ID_DIARY_SPRITES, ID_DIARY_ENTRY_SPRITES, ID_BLOOD_STAIN_SPRITES, @@ -1016,13 +1021,5 @@ enum GAME_OBJECT_ID : short ID_BLOOD_SPLASH_SPRITE_3, ID_BLOOD_DRIP_SPRITE, - ID_PANEL_BORDER = 1400, - ID_PANEL_MIDDLE, - ID_PANEL_CORNER, - ID_PANEL_DIAGONAL, - ID_PANEL_STRIP, - ID_PANEL_HALF_BORDER1, - ID_PANEL_HALF_BORDER2, - ID_PANEL_MIDDLE_CORNER, - ID_NUMBER_OBJECTS + ID_NUMBER_OBJECTS = 1408 // Compatibility. Remove this constant when slot count is nearing 1408. }; diff --git a/TombEngine/Renderer/ConstantBuffers/AnimatedBuffer.h b/TombEngine/Renderer/ConstantBuffers/AnimatedBuffer.h index f164dc90a..43c6db2b6 100644 --- a/TombEngine/Renderer/ConstantBuffers/AnimatedBuffer.h +++ b/TombEngine/Renderer/ConstantBuffers/AnimatedBuffer.h @@ -23,6 +23,6 @@ namespace TEN::Renderer::ConstantBuffers uint32_t NumFrames; uint32_t Fps; uint32_t Type; - uint32_t padding; + uint32_t Padding; }; } \ No newline at end of file diff --git a/TombEngine/Renderer/ConstantBuffers/CameraMatrixBuffer.h b/TombEngine/Renderer/ConstantBuffers/CameraMatrixBuffer.h index 9be9b953b..2ededb96b 100644 --- a/TombEngine/Renderer/ConstantBuffers/CameraMatrixBuffer.h +++ b/TombEngine/Renderer/ConstantBuffers/CameraMatrixBuffer.h @@ -37,8 +37,8 @@ namespace TEN::Renderer::ConstantBuffers //-- Vector4 FogColor; //-- - int FogMinDistance; - int FogMaxDistance; + float FogMinDistance; + float FogMaxDistance; float NearPlane; float FarPlane; //-- diff --git a/TombEngine/Renderer/ConstantBuffers/ItemBuffer.h b/TombEngine/Renderer/ConstantBuffers/ItemBuffer.h index f3b9c88c6..7715e183d 100644 --- a/TombEngine/Renderer/ConstantBuffers/ItemBuffer.h +++ b/TombEngine/Renderer/ConstantBuffers/ItemBuffer.h @@ -22,5 +22,6 @@ namespace TEN::Renderer::ConstantBuffers ShaderLight Lights[MAX_LIGHTS_PER_ITEM]; //-- int NumLights; + int Skinned; }; } \ No newline at end of file diff --git a/TombEngine/Renderer/ConstantBuffers/RoomBuffer.h b/TombEngine/Renderer/ConstantBuffers/RoomBuffer.h index d78a77965..c73f4f9ca 100644 --- a/TombEngine/Renderer/ConstantBuffers/RoomBuffer.h +++ b/TombEngine/Renderer/ConstantBuffers/RoomBuffer.h @@ -15,7 +15,7 @@ namespace TEN::Renderer::ConstantBuffers int Padding; //-- Vector2 CausticsStartUV; - Vector2 CausticsScale; + Vector2 CausticsSize; //-- Vector4 AmbientColor; //-- diff --git a/TombEngine/Renderer/Graphics/Texture2D.h b/TombEngine/Renderer/Graphics/Texture2D.h index 1608b7ea2..2a398def9 100644 --- a/TombEngine/Renderer/Graphics/Texture2D.h +++ b/TombEngine/Renderer/Graphics/Texture2D.h @@ -144,48 +144,6 @@ namespace TEN::Renderer::Graphics Height = desc.Height; } - Texture2D(ID3D11Device* device, ID3D11DeviceContext* context, ID3D11Texture2D* texture, int x, int y, int width, int height) - { - Width = width; - Height = height; - - D3D11_TEXTURE2D_DESC fromDesc = {}; - texture->GetDesc(&fromDesc); - - auto desc = D3D11_TEXTURE2D_DESC{}; - desc.Width = width; - desc.Height = height; - desc.Format = fromDesc.Format; - desc.CPUAccessFlags = 0; - desc.MiscFlags = 0; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Usage = D3D11_USAGE_DEFAULT; - - throwIfFailed(device->CreateTexture2D(&desc, nullptr, &Texture)); - - D3D11_BOX sourceRegion; - sourceRegion.left = x; - sourceRegion.right = x + width; - sourceRegion.top = y; - sourceRegion.bottom = y + height; - sourceRegion.front = 0; - sourceRegion.back = 1; - - context->CopySubresourceRegion(Texture.Get(), 0, 0, 0, 0, texture, 0, &sourceRegion); - - auto shaderDesc = D3D11_SHADER_RESOURCE_VIEW_DESC{}; - shaderDesc.Format = desc.Format; - shaderDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - shaderDesc.Texture2D.MostDetailedMip = 0; - shaderDesc.Texture2D.MipLevels = 1; - - throwIfFailed(device->CreateShaderResourceView(Texture.Get(), &shaderDesc, ShaderResourceView.GetAddressOf())); - } - ~Texture2D() = default; }; } diff --git a/TombEngine/Renderer/Graphics/Vertices/Vertex.h b/TombEngine/Renderer/Graphics/Vertices/Vertex.h index 0ee57b10b..0094fb5b2 100644 --- a/TombEngine/Renderer/Graphics/Vertices/Vertex.h +++ b/TombEngine/Renderer/Graphics/Vertices/Vertex.h @@ -12,11 +12,12 @@ namespace TEN::Renderer::Graphics::Vertices Vector3 Tangent = Vector3::Zero; Vector3 Binormal = Vector3::Zero; - unsigned int AnimationFrameOffset = 0; - Vector4 Effects = Vector4::Zero; - float Bone = 0.0f; - unsigned int IndexInPoly = 0; - unsigned int OriginalIndex = 0; - unsigned int Hash = 0; + unsigned int AnimationFrameOffset = 0; + Vector4 Effects = Vector4::Zero; + unsigned int BoneIndex[MAX_BONE_WEIGHTS] = { 0, 0, 0, 0 }; + float BoneWeight[MAX_BONE_WEIGHTS] = { 1, 0, 0, 0 }; + unsigned int IndexInPoly = 0; + unsigned int OriginalIndex = 0; + unsigned int Hash = 0; }; } diff --git a/TombEngine/Renderer/Renderer.cpp b/TombEngine/Renderer/Renderer.cpp index 39d3e5e76..c3f5da770 100644 --- a/TombEngine/Renderer/Renderer.cpp +++ b/TombEngine/Renderer/Renderer.cpp @@ -6,16 +6,17 @@ #include "Renderer/Structures/RendererRectangle.h" #include "Renderer/RenderView.h" #include "Renderer/RendererUtils.h" +#include "Renderer/Graphics/RenderTargetCube.h" #include "Renderer/Graphics/VertexBuffer.h" #include "Renderer/Structures/RendererHudBar.h" #include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h" #include "Specific/clock.h" -#include "Graphics/RenderTargetCube.h" namespace TEN::Renderer { using namespace TEN::Renderer::Structures; using namespace Utils; + Renderer g_Renderer; Renderer::Renderer() : @@ -61,6 +62,18 @@ namespace TEN::Renderer _isLocked = true; } + void Renderer::UpdateVideoTexture(Texture2D* texture) + { + _videoSprite.X = _videoSprite.Y = 0; + _videoSprite.Width = texture->Width; + _videoSprite.Height = texture->Height; + _videoSprite.UV[0] = Vector2(0,0); + _videoSprite.UV[1] = Vector2(1,0); + _videoSprite.UV[2] = Vector2(1,1); + _videoSprite.UV[3] = Vector2(0,1); + _videoSprite.Texture = texture; + } + void Renderer::ReloadShaders(bool recompileAAShaders) { try diff --git a/TombEngine/Renderer/Renderer.h b/TombEngine/Renderer/Renderer.h index e3d87f76c..de2aea3a2 100644 --- a/TombEngine/Renderer/Renderer.h +++ b/TombEngine/Renderer/Renderer.h @@ -231,6 +231,7 @@ namespace TEN::Renderer std::vector _moveablesTextures; std::vector _staticTextures; std::vector _spritesTextures; + RendererSprite _videoSprite; // Video texture is an unique case Matrix _playerWorldMatrix; @@ -340,7 +341,7 @@ namespace TEN::Renderer // Special effects - std::vector _causticTextures; + //std::vector _causticTextures; RendererMirror* _currentMirror = nullptr; // Transparency @@ -412,6 +413,7 @@ namespace TEN::Renderer void PrepareFires(RenderView& view); void PrepareParticles(RenderView& view); void PrepareSmokes(RenderView& view); + void PrepareFireflies(RenderView& view); void PrepareElectricity(RenderView& view); void PrepareHelicalLasers(RenderView& view); void PrepareWeatherParticles(RenderView& view); @@ -581,8 +583,11 @@ namespace TEN::Renderer static inline BlendMode GetBlendModeFromAlpha(BlendMode blendMode, float alpha) { - if (alpha < ALPHA_BLEND_THRESHOLD && (blendMode == BlendMode::Opaque || blendMode == BlendMode::FastAlphaBlend)) + if (alpha < ALPHA_BLEND_THRESHOLD && + (blendMode == BlendMode::Opaque || blendMode == BlendMode::AlphaTest || blendMode == BlendMode::FastAlphaBlend)) + { return BlendMode::AlphaBlend; + } return blendMode; } @@ -599,7 +604,7 @@ namespace TEN::Renderer RendererMesh* GetRendererMeshFromTrMesh(RendererObject* obj, MESH* meshPtr, short boneIndex, int isJoints, int isHairs, int* lastVertex, int* lastIndex); void DrawBar(float percent, const RendererHudBar& bar, GAME_OBJECT_ID textureSlot, int frame, bool poison); void Create(); - void Initialize(int w, int h, bool windowed, HWND handle); + void Initialize(const std::string& gameDir, int w, int h, bool windowed, HWND handle); void ReloadShaders(bool recompileAAShaders = false); void Render(float interpFactor); void RenderTitle(float interpFactor); @@ -623,6 +628,8 @@ namespace TEN::Renderer void AddDynamicSpotLight(const Vector3& pos, const Vector3& dir, float radius, float falloff, float distance, const Color& color, bool castShadows, int hash = 0); void RenderLoadingScreen(float percentage); void RenderFreezeMode(float interpFactor, bool staticBackground); + void RenderFullScreenTexture(ID3D11ShaderResourceView* texture, float aspect); + void UpdateVideoTexture(Texture2D* texture); void UpdateProgress(float value); void ToggleFullScreen(bool force = false); void SetFullScreen(); diff --git a/TombEngine/Renderer/RendererCompatibility.cpp b/TombEngine/Renderer/RendererCompatibility.cpp index e8cc46136..25c44ac36 100644 --- a/TombEngine/Renderer/RendererCompatibility.cpp +++ b/TombEngine/Renderer/RendererCompatibility.cpp @@ -68,14 +68,18 @@ namespace TEN::Renderer _animatedTextures[i] = tex; } - if (_animatedTextures.size() > 0) - TENLog("Generated " + std::to_string(_animatedTextures.size()) + " animated textures.", LogLevel::Info); - - std::transform(g_Level.AnimatedTexturesSequences.begin(), g_Level.AnimatedTexturesSequences.end(), std::back_inserter(_animatedTextureSets), [](ANIMATED_TEXTURES_SEQUENCE& sequence) { + std::transform(g_Level.AnimatedTexturesSequences.begin(), g_Level.AnimatedTexturesSequences.end(), std::back_inserter(_animatedTextureSets), [](ANIMATED_TEXTURES_SEQUENCE& sequence) + { RendererAnimatedTextureSet set{}; - set.NumTextures = sequence.numFrames; - std::transform(sequence.frames.begin(), sequence.frames.end(), std::back_inserter(set.Textures), [](ANIMATED_TEXTURES_FRAME& frm) { + + set.NumTextures = sequence.NumFrames; + set.Type = (AnimatedTextureType)sequence.Type; + set.Fps = sequence.Fps; + + std::transform(sequence.Frames.begin(), sequence.Frames.end(), std::back_inserter(set.Textures), [](ANIMATED_TEXTURES_FRAME& frm) + { RendererAnimatedTexture tex{}; + tex.UV[0].x = frm.x1; tex.UV[0].y = frm.y1; tex.UV[1].x = frm.x2; @@ -84,9 +88,21 @@ namespace TEN::Renderer tex.UV[2].y = frm.y3; tex.UV[3].x = frm.x4; tex.UV[3].y = frm.y4; + + float UMin = std::min({ tex.UV[0].x, tex.UV[1].x, tex.UV[2].x, tex.UV[3].x }); + float VMin = std::min({ tex.UV[0].y, tex.UV[1].y, tex.UV[2].y, tex.UV[3].y }); + float UMax = std::max({ tex.UV[0].x, tex.UV[1].x, tex.UV[2].x, tex.UV[3].x }); + float VMax = std::max({ tex.UV[0].y, tex.UV[1].y, tex.UV[2].y, tex.UV[3].y }); + + for (int i = 0; i < 4; ++i) + { + tex.NormalizedUV[i].x = (tex.UV[i].x - UMin) / (UMax - UMin); + tex.NormalizedUV[i].y = (tex.UV[i].y - VMin) / (VMax - VMin); + } + return tex; }); - set.Fps = sequence.Fps; + return set; }); @@ -348,7 +364,6 @@ namespace TEN::Renderer ((vertex->Position.x)* primes[0]) ^ ((unsigned int)std::hash{}(vertex->Position.y) * primes[1]) ^ (unsigned int)std::hash{}(vertex->Position.z) * primes[2]; - vertex->Bone = 0; lastVertex++; } @@ -681,9 +696,10 @@ namespace TEN::Renderer int y2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.y + skinBone->GlobalTranslation.y; int z2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.z + skinBone->GlobalTranslation.z; + // Joint vertex and skin mesh vertex are aligned, connect them. if (abs(x1 - x2) < 2 && abs(y1 - y2) < 2 && abs(z1 - z2) < 2) { - jointVertex->Bone = bonesToCheck[k]; + jointVertex->BoneIndex[0] = bonesToCheck[k]; jointVertex->Position = skinVertex->Position; jointVertex->Normal = skinVertex->Normal; @@ -699,6 +715,15 @@ namespace TEN::Renderer if (isDone) break; } + + // Joint vertex and skin mesh vertex are not connected, specify both bone weights for blending. + if (!isDone) + { + jointVertex->BoneIndex[0] = j; + jointVertex->BoneWeight[0] = 0.5f; + jointVertex->BoneIndex[1] = jointBone->Parent->Index; + jointVertex->BoneWeight[1] = 0.5f; + } } } } @@ -720,7 +745,7 @@ namespace TEN::Renderer for (int v1 = 0; v1 < currentBucket.NumVertices; v1++) { auto* currentVertex = &_moveablesVertices[currentBucket.StartVertex + v1]; - currentVertex->Bone = j + 1; + currentVertex->BoneIndex[0] = j + 1; // Link mesh 0 to root mesh. if (j == 0) @@ -752,7 +777,7 @@ namespace TEN::Renderer if ((parentVertex->OriginalIndex == vertices1[currentVertex->OriginalIndex] && isSecond) || (parentVertex->OriginalIndex == vertices0[currentVertex->OriginalIndex] && !isSecond)) { - currentVertex->Bone = 0; + currentVertex->BoneIndex[0] = 0; currentVertex->Position = parentVertex->Position; currentVertex->Normal = parentVertex->Normal; } @@ -784,7 +809,7 @@ namespace TEN::Renderer if (abs(x1 - x2) == 0 && abs(y1 - y2) == 0 && abs(z1 - z2) == 0) { - currentVertex->Bone = j; + currentVertex->BoneIndex[0] = j; currentVertex->Position = parentVertex->Position; currentVertex->Normal = parentVertex->Normal; break; @@ -882,25 +907,6 @@ namespace TEN::Renderer } _spriteSequences[SpriteSequencesIds[i]] = sequence; - - if (SpriteSequencesIds[i] == ID_CAUSTICS_TEXTURES) - { - _causticTextures.clear(); - for (int j = 0; j < sequence.SpritesList.size(); j++) - { - _causticTextures.push_back( - Texture2D( - _device.Get(), - _context.Get(), - sequence.SpritesList[j]->Texture->Texture.Get(), - sequence.SpritesList[j]->X, - sequence.SpritesList[j]->Y, - sequence.SpritesList[j]->Width, - sequence.SpritesList[j]->Height - ) - ); - } - } } } @@ -975,7 +981,7 @@ namespace TEN::Renderer vertex.Color.z = meshPtr->colors[v].z; vertex.Color.w = 1.0f; - vertex.Bone = meshPtr->bones[v]; + vertex.BoneIndex[0] = meshPtr->bones[v]; vertex.OriginalIndex = v; vertex.Effects = Vector4(meshPtr->effects[v].x, meshPtr->effects[v].y, meshPtr->effects[v].z, poly->shineStrength); diff --git a/TombEngine/Renderer/RendererDraw.cpp b/TombEngine/Renderer/RendererDraw.cpp index 3ac5d67fd..7472048ab 100644 --- a/TombEngine/Renderer/RendererDraw.cpp +++ b/TombEngine/Renderer/RendererDraw.cpp @@ -31,16 +31,16 @@ #include "Renderer/Structures/RendererSortableObject.h" #include "Specific/configuration.h" #include "Specific/level.h" +#include "Specific/trutils.h" #include "Specific/winmain.h" -using namespace std::chrono; using namespace TEN::Effects::Hair; -using namespace TEN::Entities::Creatures::TR3; -using namespace TEN::Entities::Generic; using namespace TEN::Hud; -using namespace TEN::Renderer::Structures; using namespace TEN::Effects::Environment; using namespace TEN::Effects::DisplaySprite; +using namespace TEN::Entities::Creatures::TR3; +using namespace TEN::Entities::Generic; +using namespace TEN::Renderer::Structures; extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL]; @@ -200,6 +200,7 @@ namespace TEN::Renderer _stItem.World = item->InterpolatedWorld; _stItem.Color = item->Color; _stItem.AmbientLight = item->AmbientLight; + _stItem.Skinned = item->ObjectID == GAME_OBJECT_ID::ID_LARA; // TODO: Implement for all skinned objects! memcpy(_stItem.BonesMatrices, item->InterpolatedAnimTransforms, sizeof(Matrix) * MAX_BONES); for (int k = 0; k < MAX_BONES; k++) _stItem.BoneLightModes[k] = (int)LightMode::Static; @@ -264,6 +265,9 @@ namespace TEN::Renderer objectID = gunshell->objectNumber; + if (!_moveableObjects[objectID].has_value()) + continue; + auto translation = Matrix::CreateTranslation(gunshell->pos.Position.ToVector3()); auto rotMatrix = gunshell->pos.Orientation.ToRotationMatrix(); auto worldMatrix = rotMatrix * translation; @@ -1746,6 +1750,7 @@ namespace TEN::Renderer PrepareDrips(view); PrepareExplosionParticles(view); PrepareElectricity(view); + PrepareFireflies(view); PrepareFires(view); PrepareFootprints(view); PrepareHelicalLasers(view); @@ -1825,7 +1830,7 @@ namespace TEN::Renderer cameraConstantBuffer.CameraUnderwater = g_Level.Rooms[cameraConstantBuffer.RoomNumber].flags & ENV_FLAG_WATER; cameraConstantBuffer.DualParaboloidView = Matrix::CreateLookAt(LaraItem->Pose.Position.ToVector3(), LaraItem->Pose.Position.ToVector3() + Vector3(0, 0, 1024), -Vector3::UnitY); - if (level.GetFogEnabled()) + if (level.GetFogMaxDistance() > 0) { auto fogColor = level.GetFogColor(); cameraConstantBuffer.FogColor = Vector4(fogColor.GetR() / 255.0f, fogColor.GetG() / 255.0f, fogColor.GetB() / 255.0f, 1.0f); @@ -1834,7 +1839,7 @@ namespace TEN::Renderer } else { - cameraConstantBuffer.FogMaxDistance = 0; + cameraConstantBuffer.FogMaxDistance = 0.0f; cameraConstantBuffer.FogColor = Vector4::Zero; } @@ -1935,6 +1940,8 @@ namespace TEN::Renderer void Renderer::RenderSimpleSceneToParaboloid(RenderTarget2D* renderTarget, Vector3 position, int emisphere) { + // TODO: Update the horizon draw code here once paraboloids are required. TrainWreck Feb 2, 2025. + // Reset GPU state SetBlendMode(BlendMode::Opaque); SetCullMode(CullMode::CounterClockwise); @@ -1984,10 +1991,10 @@ namespace TEN::Renderer view.FillConstantBuffer(cameraConstantBuffer); _cbCameraMatrices.UpdateData(cameraConstantBuffer, _context.Get()); - // Draw horizon and the sky + // Draw horizon and sky. auto* levelPtr = g_GameFlow->GetLevel(CurrentLevel); - if (levelPtr->Horizon) + if (levelPtr->GetHorizonEnabled(0) || levelPtr->GetHorizonEnabled(1)) { _shaders.Bind(Shader::RoomAmbientSky); @@ -2029,31 +2036,26 @@ namespace TEN::Renderer _context->ClearDepthStencilView(renderTarget->DepthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0); // Draw horizon. - if (_moveableObjects[ID_HORIZON].has_value()) + if (_moveableObjects[ID_HORIZON].has_value()) // FIXME: Replace with same function as in the main pipeline! { _context->IASetVertexBuffers(0, 1, _moveablesVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); _context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); - auto& moveableObj = *_moveableObjects[ID_HORIZON]; + const auto& moveableObj = *_moveableObjects[ID_HORIZON]; // FIXME: Replace with same function as in the main pipeline! _stStatic.World = Matrix::CreateTranslation(LaraItem->Pose.Position.ToVector3()); _stStatic.Color = Vector4::One; _stStatic.ApplyFogBulbs = 1; _cbStatic.UpdateData(_stStatic, _context.Get()); - for (int k = 0; k < moveableObj.ObjectMeshes.size(); k++) + for (const auto* mesh : moveableObj.ObjectMeshes) { - auto* meshPtr = moveableObj.ObjectMeshes[k]; - - for (auto& bucket : meshPtr->Buckets) + for (const auto& bucket : mesh->Buckets) { if (bucket.NumVertices == 0) - { continue; - } - BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[bucket.Texture]), - SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); // Always render horizon as alpha-blended surface. SetBlendMode(bucket.BlendMode == BlendMode::AlphaTest ? BlendMode::AlphaBlend : bucket.BlendMode); @@ -2074,8 +2076,8 @@ namespace TEN::Renderer _shaders.Bind(Shader::RoomAmbient); // Draw rooms - UINT stride = sizeof(Vertex); - UINT offset = 0; + unsigned int stride = sizeof(Vertex); + unsigned int offset = 0; // Bind vertex and index buffer. _context->IASetVertexBuffers(0, 1, _roomsVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); @@ -2084,8 +2086,8 @@ namespace TEN::Renderer for (int i = 0; i < _rooms.size(); i++) { int index = i; - RendererRoom* room = &_rooms[index]; - ROOM_INFO* nativeRoom = &g_Level.Rooms[room->RoomNumber]; + auto* room = &_rooms[index]; + auto* nativeRoom = &g_Level.Rooms[room->RoomNumber]; // Avoid drawing of too far rooms... Environment map is tiny, blurred, so very far rooms would not contribute to the // final pixel colors @@ -2106,9 +2108,7 @@ namespace TEN::Renderer for (auto& bucket : room->Buckets) { if (bucket.NumVertices == 0) - { continue; - } SetBlendMode(bucket.BlendMode); SetAlphaTest(AlphaTestMode::GreatherThan, ALPHA_TEST_THRESHOLD); @@ -2187,6 +2187,33 @@ namespace TEN::Renderer SetBlendMode(BlendMode::Opaque, true);*/ } + void Renderer::RenderFullScreenTexture(ID3D11ShaderResourceView* texture, float aspect) + { + if (texture == nullptr) + return; + + // Set basic render states. + SetBlendMode(BlendMode::Opaque); + SetCullMode(CullMode::CounterClockwise); + + // Clear screen + _context->ClearRenderTargetView(_backBuffer.RenderTargetView.Get(), Colors::Black); + _context->ClearDepthStencilView(_backBuffer.DepthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); + + // Bind back buffer. + _context->OMSetRenderTargets(1, _backBuffer.RenderTargetView.GetAddressOf(), _backBuffer.DepthStencilView.Get()); + _context->RSSetViewports(1, &_viewport); + ResetScissor(); + + // Draw full screen background. + DrawFullScreenQuad(texture, Vector3::One, true, aspect); + + ClearScene(); + + _context->ClearState(); + _swapChain->Present(1, 0); + } + void Renderer::DumpGameScene(SceneRenderMode renderMode) { RenderScene(&_dumpScreenRenderTarget, _gameCamera, renderMode); @@ -2393,6 +2420,7 @@ namespace TEN::Renderer _stItem.Color = item->Color; _stItem.AmbientLight = item->AmbientLight; + _stItem.Skinned = item->ObjectID == GAME_OBJECT_ID::ID_LARA; // TODO: Implement for all skinned objects! memcpy(_stItem.BonesMatrices, item->InterpolatedAnimTransforms, sizeof(Matrix) * MAX_BONES); for (int k = 0; k < moveableObj.ObjectMeshes.size(); k++) @@ -2580,6 +2608,12 @@ namespace TEN::Renderer if (!SetupBlendModeAndAlphaTest(bucket.BlendMode, rendererPass, p)) continue; + if (_staticTextures.size() <= bucket.Texture) + { + TENLog("Attempted to set incorrect static mesh texture atlas", LogLevel::Warning); + continue; + } + BindTexture(TextureRegister::ColorMap, &std::get<0>(_staticTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); @@ -2711,12 +2745,19 @@ namespace TEN::Renderer if (rendererPass != RendererPass::GBuffer) { // Bind caustics texture. - if (_causticTextures.size() > 0) + if (TEN::Utils::Contains(SpriteSequencesIds, (int)ID_CAUSTIC_TEXTURES)) { - int nmeshes = -Objects[ID_CAUSTICS_TEXTURES].nmeshes; - int meshIndex = Objects[ID_CAUSTICS_TEXTURES].meshIndex; - int causticsFrame = GlobalCounter % _causticTextures.size(); - BindTexture(TextureRegister::CausticsMap, &_causticTextures[causticsFrame], SamplerStateRegister::AnisotropicClamp); + int nmeshes = -Objects[ID_CAUSTIC_TEXTURES].nmeshes; + int meshIndex = Objects[ID_CAUSTIC_TEXTURES].meshIndex; + int causticsFrame = GlobalCounter % nmeshes; + auto causticsSprite = _spriteSequences[ID_CAUSTIC_TEXTURES].SpritesList[causticsFrame]; + + BindTexture(TextureRegister::CausticsMap, causticsSprite->Texture, SamplerStateRegister::AnisotropicClamp); + + _stRoom.CausticsSize = Vector2( + (float)causticsSprite->Width / (float)causticsSprite->Texture->Width, + (float)causticsSprite->Height / (float)causticsSprite->Texture->Height); + _stRoom.CausticsStartUV = causticsSprite->UV[0]; } // Set shadow map data and bind shadow map texture. @@ -2787,40 +2828,54 @@ namespace TEN::Renderer // Draw geometry. if (animated) { - BindTexture(TextureRegister::ColorMap, - &std::get<0>(_animatedTextures[bucket.Texture]), - SamplerStateRegister::AnisotropicClamp); - BindTexture(TextureRegister::NormalMap, - &std::get<1>(_animatedTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); + const auto& set = _animatedTextureSets[bucket.Texture]; - const auto& set = _animatedTextureSets[bucket.Texture]; - _stAnimated.NumFrames = set.NumTextures; - _stAnimated.Type = 0; - _stAnimated.Fps = set.Fps; - - for (unsigned char j = 0; j < set.NumTextures; j++) + // Stream video texture, if video playback is active, otherwise show original texture. + if (set.Type == AnimatedTextureType::Video && _videoSprite.Texture && _videoSprite.Texture->Texture) { - if (j >= _stAnimated.Textures.size()) - { - TENLog("Animated frame " + std::to_string(j) + " out of bounds. Too many frames in sequence."); - break; - } + _stAnimated.Type = 0; // Dummy type, should be set to 0 to avoid incorrect UV mapping. + _stAnimated.Fps = 1; + _stAnimated.NumFrames = 1; - _stAnimated.Textures[j].TopLeft = set.Textures[j].UV[0]; - _stAnimated.Textures[j].TopRight = set.Textures[j].UV[1]; - _stAnimated.Textures[j].BottomRight = set.Textures[j].UV[2]; - _stAnimated.Textures[j].BottomLeft = set.Textures[j].UV[3]; + BindTexture(TextureRegister::ColorMap, _videoSprite.Texture, SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::NormalMap, &std::get<1>(_animatedTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); + + // Use normalized UVs, because we are showing the whole video texture on a single face. + _stAnimated.Textures[0].TopLeft = set.Textures[0].NormalizedUV[0]; + _stAnimated.Textures[0].TopRight = set.Textures[0].NormalizedUV[1]; + _stAnimated.Textures[0].BottomRight = set.Textures[0].NormalizedUV[2]; + _stAnimated.Textures[0].BottomLeft = set.Textures[0].NormalizedUV[3]; } + else + { + _stAnimated.Type = (int)set.Type; + _stAnimated.Fps = set.Fps; + _stAnimated.NumFrames = set.NumTextures; + + BindTexture(TextureRegister::ColorMap, &std::get<0>(_animatedTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::NormalMap, &std::get<1>(_animatedTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); + + for (unsigned char j = 0; j < set.NumTextures; j++) + { + if (j >= _stAnimated.Textures.size()) + { + TENLog("Animated frame " + std::to_string(j) + " out of bounds. Too many frames in sequence."); + break; + } + + _stAnimated.Textures[j].TopLeft = set.Textures[j].UV[0]; + _stAnimated.Textures[j].TopRight = set.Textures[j].UV[1]; + _stAnimated.Textures[j].BottomRight = set.Textures[j].UV[2]; + _stAnimated.Textures[j].BottomLeft = set.Textures[j].UV[3]; + } + } + _cbAnimated.UpdateData(_stAnimated, _context.Get()); } else { - BindTexture( - TextureRegister::ColorMap, &std::get<0>(_roomTextures[bucket.Texture]), - SamplerStateRegister::AnisotropicClamp); - BindTexture( - TextureRegister::NormalMap, &std::get<1>(_roomTextures[bucket.Texture]), - SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::ColorMap, &std::get<0>(_roomTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::NormalMap, &std::get<1>(_roomTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); } DrawIndexedTriangles(bucket.NumIndices, bucket.StartIndex, 0); @@ -2853,7 +2908,7 @@ namespace TEN::Renderer } } - if (!levelPtr->Horizon || !anyOutsideRooms) + if ((!levelPtr->GetHorizonEnabled(0) && !levelPtr->GetHorizonEnabled(1)) || !anyOutsideRooms) return; if (Lara.Control.Look.OpticRange != 0) @@ -2873,21 +2928,23 @@ namespace TEN::Renderer SetBlendMode(BlendMode::Additive); - for (int s = 0; s < 2; s++) + for (int layer = 0; layer < 2; layer++) { + if (Vector3(Weather.SkyColor(layer)) == Vector3::Zero) + continue; + for (int i = 0; i < 2; i++) { - auto weather = TEN::Effects::Environment::Weather; auto translation = Matrix::CreateTranslation( - renderView.Camera.WorldPosition.x + weather.SkyPosition(s) - i * SKY_SIZE, + renderView.Camera.WorldPosition.x + Weather.SkyPosition(layer) - i * SKY_SIZE, renderView.Camera.WorldPosition.y - 1536.0f, renderView.Camera.WorldPosition.z); auto world = rotation * translation; _stStatic.World = (rotation * translation); - _stStatic.Color = weather.SkyColor(s); - _stStatic.ApplyFogBulbs = s == 0 ? 1 : 0; + _stStatic.Color = Weather.SkyColor(layer); + _stStatic.ApplyFogBulbs = layer == 0 ? 1 : 0; _cbStatic.UpdateData(_stStatic, _context.Get()); DrawIndexedTriangles(SKY_INDICES_COUNT, 0, 0); @@ -3036,8 +3093,11 @@ namespace TEN::Renderer } // Draw horizon. - if (_moveableObjects[ID_HORIZON].has_value()) + for (int layer = 0; layer < 2; layer++) { + if (!levelPtr->GetHorizonEnabled(layer) || levelPtr->GetHorizonTransparency(layer) <= EPSILON) + continue; + SetDepthState(DepthState::None); SetBlendMode(BlendMode::Opaque); SetCullMode(CullMode::CounterClockwise); @@ -3047,29 +3107,31 @@ namespace TEN::Renderer _shaders.Bind(Shader::Sky); - auto& moveableObj = *_moveableObjects[ID_HORIZON]; + auto pos = Vector3::Lerp(levelPtr->GetHorizonPrevPosition(layer), levelPtr->GetHorizonPosition(layer), GetInterpolationFactor()); + auto orient = EulerAngles::Lerp(levelPtr->GetHorizonPrevOrientation(layer), levelPtr->GetHorizonOrientation(layer), GetInterpolationFactor()); + auto rotMatrix = orient.ToRotationMatrix(); + auto translationMatrix = Matrix::CreateTranslation(pos); + auto cameraMatrix = Matrix::CreateTranslation(renderView.Camera.WorldPosition); - _stStatic.World = Matrix::CreateTranslation(renderView.Camera.WorldPosition); - _stStatic.Color = Vector4::One; + float alpha = levelPtr->GetHorizonTransparency(layer); + + _stStatic.World = rotMatrix * translationMatrix * cameraMatrix; + _stStatic.Color = Color(1.0f, 1.0f, 1.0f, alpha); _stStatic.ApplyFogBulbs = 1; _cbStatic.UpdateData(_stStatic, _context.Get()); - for (int k = 0; k < moveableObj.ObjectMeshes.size(); k++) + const auto& moveableObj = *_moveableObjects[levelPtr->GetHorizonObjectID(layer)]; + for (const auto* mesh : moveableObj.ObjectMeshes) { - auto* meshPtr = moveableObj.ObjectMeshes[k]; - - for (auto& bucket : meshPtr->Buckets) + for (const auto& bucket : mesh->Buckets) { if (bucket.NumVertices == 0) - { continue; - } - BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[bucket.Texture]), - SamplerStateRegister::AnisotropicClamp); + BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp); // Always render horizon as alpha-blended surface. - SetBlendMode(bucket.BlendMode == BlendMode::AlphaTest ? BlendMode::AlphaBlend : bucket.BlendMode); + SetBlendMode(GetBlendModeFromAlpha((bucket.BlendMode == BlendMode::AlphaTest) ? BlendMode::AlphaBlend : bucket.BlendMode, alpha)); SetAlphaTest(AlphaTestMode::None, ALPHA_TEST_THRESHOLD); // Draw vertices. @@ -3230,7 +3292,7 @@ namespace TEN::Renderer } if (blendMode == BlendMode::Opaque) - { + { SetBlendMode(BlendMode::Opaque); SetAlphaTest(AlphaTestMode::None, 1.0f); } @@ -3594,6 +3656,7 @@ namespace TEN::Renderer _stItem.World = world; _stItem.Color = objectInfo->Item->Color; _stItem.AmbientLight = objectInfo->Item->AmbientLight; + _stItem.Skinned = objectInfo->Item->ObjectID == GAME_OBJECT_ID::ID_LARA; // TODO: Implement for all skinned objects! memcpy(_stItem.BonesMatrices, objectInfo->Item->InterpolatedAnimTransforms, sizeof(Matrix) * MAX_BONES); const auto& moveableObj = *_moveableObjects[objectInfo->Item->ObjectID]; diff --git a/TombEngine/Renderer/RendererDraw2D.cpp b/TombEngine/Renderer/RendererDraw2D.cpp index 8dd4434a8..5f5751d82 100644 --- a/TombEngine/Renderer/RendererDraw2D.cpp +++ b/TombEngine/Renderer/RendererDraw2D.cpp @@ -119,7 +119,7 @@ namespace TEN::Renderer void Renderer::DrawBar(float percent, const RendererHudBar& bar, GAME_OBJECT_ID textureSlot, int frame, bool isPoisoned) { - if (!CheckIfSlotExists(ID_BAR_BORDER_GRAPHIC, "Bar rendering")) + if (!CheckIfSlotExists(ID_BAR_BORDER_GRAPHICS, "Bar rendering")) return; unsigned int strides = sizeof(Vertex); @@ -141,7 +141,7 @@ namespace TEN::Renderer BindConstantBufferVS(ConstantBufferRegister::Hud, _cbHUD.get()); - RendererSprite* borderSprite = &_sprites[Objects[ID_BAR_BORDER_GRAPHIC].meshIndex]; + RendererSprite* borderSprite = &_sprites[Objects[ID_BAR_BORDER_GRAPHICS].meshIndex]; _stHUDBar.BarStartUV = borderSprite->UV[0]; _stHUDBar.BarScale = Vector2(borderSprite->Width / (float)borderSprite->Texture->Width, borderSprite->Height / (float)borderSprite->Texture->Height); _cbHUDBar.UpdateData(_stHUDBar, _context.Get()); @@ -266,11 +266,11 @@ namespace TEN::Renderer if (Lara.Control.Look.OpticRange != 0 && !Lara.Control.Look.IsUsingLasersight) { - DrawFullScreenSprite(&_sprites[Objects[ID_BINOCULAR_GRAPHIC].meshIndex], Vector3::One, false); + DrawFullScreenSprite(&_sprites[Objects[ID_BINOCULAR_GRAPHICS].meshIndex], Vector3::One, false); } else if (Lara.Control.Look.OpticRange != 0 && Lara.Control.Look.IsUsingLasersight) { - DrawFullScreenSprite(&_sprites[Objects[ID_LASER_SIGHT_GRAPHIC].meshIndex], Vector3::One); + DrawFullScreenSprite(&_sprites[Objects[ID_LASERSIGHT_GRAPHICS].meshIndex], Vector3::One); SetBlendMode(BlendMode::Opaque); @@ -407,7 +407,7 @@ namespace TEN::Renderer _primitiveBatch->End(); } - void Renderer::DrawFullScreenQuad(ID3D11ShaderResourceView* texture, Vector3 color, bool fit) + void Renderer::DrawFullScreenQuad(ID3D11ShaderResourceView* texture, Vector3 color, bool fit, float customAspect) { constexpr auto VERTEX_COUNT = 4; constexpr auto UV_RANGE = std::pair(Vector2(0.0f), Vector2(1.0f)); @@ -424,7 +424,7 @@ namespace TEN::Renderer texture2DPtr->GetDesc(&desc); float screenAspect = float(_screenWidth) / float(_screenHeight); - float imageAspect = float(desc.Width) / float(desc.Height); + float imageAspect = customAspect == 0.0f ? float(desc.Width) / float(desc.Height) : customAspect; if (screenAspect > imageAspect) { @@ -584,7 +584,11 @@ namespace TEN::Renderer for (const auto& displaySprite : DisplaySprites) { - const auto& sprite = _sprites[Objects[displaySprite.ObjectID].meshIndex + displaySprite.SpriteID]; + // If sprite is a video texture, bypass it if texture is inactive. + if (displaySprite.SpriteID == VIDEO_SPRITE_ID && (_videoSprite.Texture == nullptr || _videoSprite.Texture->Texture == nullptr)) + continue; + + const auto& sprite = displaySprite.SpriteID == VIDEO_SPRITE_ID ? _videoSprite : _sprites[Objects[displaySprite.ObjectID].meshIndex + displaySprite.SpriteID]; // Calculate sprite aspect ratio. float spriteAspect = (float)sprite.Width / (float)sprite.Height; diff --git a/TombEngine/Renderer/RendererDrawEffect.cpp b/TombEngine/Renderer/RendererDrawEffect.cpp index b88c2b123..ef79b1ddc 100644 --- a/TombEngine/Renderer/RendererDrawEffect.cpp +++ b/TombEngine/Renderer/RendererDrawEffect.cpp @@ -35,6 +35,7 @@ #include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h" #include "Specific/level.h" #include "Structures/RendererSpriteBucket.h" +#include "Objects/Effects/Fireflies.h" using namespace TEN::Effects::Blood; using namespace TEN::Effects::Bubble; @@ -48,6 +49,7 @@ using namespace TEN::Effects::Streamer; using namespace TEN::Entities::Creatures::TR5; using namespace TEN::Entities::Traps; using namespace TEN::Math; +using namespace TEN::Effects::Fireflies; extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE]; extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE]; @@ -133,10 +135,10 @@ namespace TEN::Renderer auto color = Vector4::Lerp(segment.PrevColor, segment.Color, GetInterpolationFactor()); auto prevColor = Vector4::Lerp(prevSegment.PrevColor, prevSegment.Color, GetInterpolationFactor()); - switch (streamer.GetFeatherType()) + switch (streamer.GetFeatherMode()) { default: - case StreamerFeatherType::None: + case StreamerFeatherMode::None: AddColoredQuad( vertex0, vertex1, prevVertex1, @@ -148,7 +150,7 @@ namespace TEN::Renderer streamer.GetBlendMode(), view); break; - case StreamerFeatherType::Center: + case StreamerFeatherMode::Center: { auto center = (vertex0 + vertex1) / 2; auto prevCenter = (prevVertex0 + prevVertex1) / 2; @@ -164,14 +166,14 @@ namespace TEN::Renderer } break; - case StreamerFeatherType::Left: + case StreamerFeatherMode::Left: AddColoredQuad( vertex0, vertex1, prevVertex1, prevVertex0, color, Vector4::Zero, Vector4::Zero, prevColor, streamer.GetBlendMode(), view); break; - case StreamerFeatherType::Right: + case StreamerFeatherMode::Right: AddColoredQuad( vertex0, vertex1, prevVertex1, prevVertex0, Vector4::Zero, color, prevColor, Vector4::Zero, @@ -329,6 +331,49 @@ namespace TEN::Renderer } } + void Renderer::PrepareFireflies(RenderView& view) + { + if (!Objects[ID_FIREFLY_EMITTER].loaded) + return; + + for (auto& firefly : FireflySwarm) + { + if (!firefly.on) + continue; + + + if (!CheckIfSlotExists(ID_SPARK_SPRITE, "Particle rendering")) + continue; + + auto axis = Vector3(0,0,0); + axis.Normalize(); + + + firefly.scalar = 3; + firefly.size = 3; + + auto pos = Vector3::Lerp( + Vector3(firefly.PrevX, firefly.PrevY, firefly.PrevZ), + Vector3(firefly.Position.x, firefly.Position.y, firefly.Position.z), + GetInterpolationFactor()); + + pos = Vector3(firefly.Position.x, firefly.Position.y, firefly.Position.z); + + // Disallow sprites out of bounds. + int spriteIndex = Objects[firefly.SpriteSeqID].meshIndex + firefly.SpriteID; + spriteIndex = std::clamp(spriteIndex, 0, (int)_sprites.size()); + + AddSpriteBillboard( + &_sprites[spriteIndex], + pos, + Color(firefly.r / (float)UCHAR_MAX, firefly.g / (float)UCHAR_MAX, firefly.b / (float)UCHAR_MAX, 1.0f), + TO_RAD(firefly.rotAng << 4), firefly.scalar, + Vector2(firefly.size, firefly.size), + firefly.blendMode, true, view); + + } + } + void Renderer::PrepareSmokes(RenderView& view) { for (const auto& smoke : SmokeSparks) @@ -509,13 +554,19 @@ namespace TEN::Renderer pos += _items[particle.fxObj].InterpolatedPosition; } } + + // If sprite is a video texture, bypass it if texture is inactive. + if (particle.SpriteID == VIDEO_SPRITE_ID && (_videoSprite.Texture == nullptr || _videoSprite.Texture->Texture == nullptr)) + continue; // Disallow sprites out of bounds. int spriteIndex = Objects[particle.SpriteSeqID].meshIndex + particle.SpriteID; spriteIndex = std::clamp(spriteIndex, 0, (int)_sprites.size()); + auto* sprite = particle.SpriteID == VIDEO_SPRITE_ID ? &_videoSprite : &_sprites[spriteIndex]; + AddSpriteBillboard( - &_sprites[spriteIndex], + sprite, pos, Color(particle.r / (float)UCHAR_MAX, particle.g / (float)UCHAR_MAX, particle.b / (float)UCHAR_MAX, 1.0f), TO_RAD(particle.rotAng << 4), particle.scalar, @@ -957,10 +1008,24 @@ namespace TEN::Renderer if (Lara.Control.Look.OpticRange > 0 && _currentMirror == nullptr) return false; + if (Lara.Control.Weapon.GunType == LaraWeaponType::Flare) + return false; + const auto& settings = g_GameFlow->GetSettings()->Weapons[(int)Lara.Control.Weapon.GunType - 1]; if (!settings.MuzzleFlash) return false; + // Use MP5 flash if available. + auto gunflash = GAME_OBJECT_ID::ID_GUN_FLASH; + if (Lara.Control.Weapon.GunType == LaraWeaponType::HK && Objects[GAME_OBJECT_ID::ID_GUN_FLASH2].loaded) + gunflash = GAME_OBJECT_ID::ID_GUN_FLASH2; + + if (!_moveableObjects[gunflash].has_value()) + return false; + + const auto& flashMoveable = *_moveableObjects[gunflash]; + const auto& flashMesh = *flashMoveable.ObjectMeshes[0]; + _shaders.Bind(Shader::Statics); unsigned int stride = sizeof(Vertex); @@ -979,100 +1044,54 @@ namespace TEN::Renderer _stStatic.LightMode = (int)LightMode::Static; BindStaticLights(itemPtr->LightsToDraw); - short length = 0; - short zOffset = 0; - short rotationX = 0; - SetAlphaTest(AlphaTestMode::GreatherThan, ALPHA_TEST_THRESHOLD); SetBlendMode(BlendMode::Additive); - if (Lara.Control.Weapon.GunType != LaraWeaponType::Flare && - Lara.Control.Weapon.GunType != LaraWeaponType::Crossbow) + for (const auto& flashBucket : flashMesh.Buckets) { - switch (Lara.Control.Weapon.GunType) + if (flashBucket.BlendMode == BlendMode::Opaque) + continue; + + if (flashBucket.Polygons.size() == 0) + continue; + + BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[flashBucket.Texture]), SamplerStateRegister::AnisotropicClamp); + + auto meshOffset = g_Level.Frames[GetAnimData(gunflash, 0).FramePtr].Offset; + auto offset = settings.MuzzleOffset + Vector3(meshOffset.x, meshOffset.z, meshOffset.y); // Offsets are inverted because of bone orientation. + + auto tMatrix = Matrix::CreateTranslation(offset); + auto rotMatrix = Matrix::CreateRotationX(TO_RAD(Lara.Control.Weapon.GunType == LaraWeaponType::Pistol ? -16830 : -14560)); // HACK + + auto worldMatrix = Matrix::Identity; + if (Lara.LeftArm.GunFlash) { - case LaraWeaponType::Revolver: - length = 192; - zOffset = 68; - rotationX = -14560; - break; + worldMatrix = itemPtr->AnimTransforms[LM_LHAND] * itemPtr->World; + worldMatrix = tMatrix * worldMatrix; + worldMatrix = rotMatrix * worldMatrix; + ReflectMatrixOptionally(worldMatrix); - case LaraWeaponType::Uzi: - length = 190; - zOffset = 50; - rotationX = -14560; - break; + _stStatic.World = worldMatrix; + _cbStatic.UpdateData(_stStatic, _context.Get()); - case LaraWeaponType::HK: - case LaraWeaponType::Shotgun: - length = 300; - zOffset = 92; - rotationX = -14560; - break; + DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); - default: - case LaraWeaponType::Pistol: - length = 180; - zOffset = 40; - rotationX = -16830; - break; + _numMoveablesDrawCalls++; } - // Use MP5 flash if available. - auto gunflash = GAME_OBJECT_ID::ID_GUN_FLASH; - if (Lara.Control.Weapon.GunType == LaraWeaponType::HK && Objects[GAME_OBJECT_ID::ID_GUN_FLASH2].loaded) + if (Lara.RightArm.GunFlash) { - gunflash = GAME_OBJECT_ID::ID_GUN_FLASH2; - length += 20; - zOffset += 10; - } + worldMatrix = itemPtr->AnimTransforms[LM_RHAND] * itemPtr->World; + worldMatrix = tMatrix * worldMatrix; + worldMatrix = rotMatrix * worldMatrix; + ReflectMatrixOptionally(worldMatrix); - const auto& flashMoveable = *_moveableObjects[gunflash]; - const auto& flashMesh = *flashMoveable.ObjectMeshes[0]; + _stStatic.World = worldMatrix; + _cbStatic.UpdateData(_stStatic, _context.Get()); - for (const auto& flashBucket : flashMesh.Buckets) - { - if (flashBucket.BlendMode == BlendMode::Opaque) - continue; + DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); - if (flashBucket.Polygons.size() == 0) - continue; - - BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[flashBucket.Texture]), SamplerStateRegister::AnisotropicClamp); - - auto tMatrix = Matrix::CreateTranslation(0, length, zOffset); - auto rotMatrix = Matrix::CreateRotationX(TO_RAD(rotationX)); - - auto worldMatrix = Matrix::Identity; - if (Lara.LeftArm.GunFlash) - { - worldMatrix = itemPtr->AnimTransforms[LM_LHAND] * itemPtr->World; - worldMatrix = tMatrix * worldMatrix; - worldMatrix = rotMatrix * worldMatrix; - ReflectMatrixOptionally(worldMatrix); - - _stStatic.World = worldMatrix; - _cbStatic.UpdateData(_stStatic, _context.Get()); - - DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); - - _numMoveablesDrawCalls++; - } - - if (Lara.RightArm.GunFlash) - { - worldMatrix = itemPtr->AnimTransforms[LM_RHAND] * itemPtr->World; - worldMatrix = tMatrix * worldMatrix; - worldMatrix = rotMatrix * worldMatrix; - ReflectMatrixOptionally(worldMatrix); - - _stStatic.World = worldMatrix; - _cbStatic.UpdateData(_stStatic, _context.Get()); - - DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); - - _numMoveablesDrawCalls++; - } + _numMoveablesDrawCalls++; } } diff --git a/TombEngine/Renderer/RendererDrawMenu.cpp b/TombEngine/Renderer/RendererDrawMenu.cpp index 14c265a76..403501f30 100644 --- a/TombEngine/Renderer/RendererDrawMenu.cpp +++ b/TombEngine/Renderer/RendererDrawMenu.cpp @@ -12,6 +12,7 @@ #include "Math/Math.h" #include "Scripting/Internal/TEN/Flow//Level/FlowLevel.h" #include "Specific/configuration.h" +#include "Specific/Input/InputAction.h" #include "Specific/level.h" #include "Specific/trutils.h" #include "Specific/winmain.h" @@ -315,8 +316,11 @@ namespace TEN::Renderer } else { - int index = Bindings[1][k] ? Bindings[1][k] : Bindings[0][k]; - AddString(MenuRightSideEntry, y, g_KeyNames[index].c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); + int defaultKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Default, (InputActionID)k); + int userKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Custom, (InputActionID)k); + + int key = userKeyID ? userKeyID : defaultKeyID; + AddString(MenuRightSideEntry, y, GetKeyName(key).c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); } if (k < (GeneralActionStrings.size() - 1)) @@ -365,8 +369,11 @@ namespace TEN::Renderer } else { - int index = Bindings[1][baseIndex + k] ? Bindings[1][baseIndex + k] : Bindings[0][baseIndex + k]; - AddString(MenuRightSideEntry, y, g_KeyNames[index].c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); + int defaultKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Default, (InputActionID)(baseIndex + k)); + int userKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Custom, (InputActionID)(baseIndex + k)); + + int key = userKeyID ? userKeyID : defaultKeyID; + AddString(MenuRightSideEntry, y, GetKeyName(key).c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); } if (k < (VehicleActionStrings.size() - 1)) @@ -421,8 +428,11 @@ namespace TEN::Renderer } else { - int index = Bindings[1][baseIndex + k] ? Bindings[1][baseIndex + k] : Bindings[0][baseIndex + k]; - AddString(MenuRightSideEntry, y, g_KeyNames[index].c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); + int defaultKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Default, (InputActionID)(baseIndex + k)); + int userKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Custom, (InputActionID)(baseIndex + k)); + + int key = userKeyID ? userKeyID : defaultKeyID; + AddString(MenuRightSideEntry, y, GetKeyName(key).c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); } if (k < (QuickActionStrings.size() - 1)) @@ -470,8 +480,11 @@ namespace TEN::Renderer } else { - int index = Bindings[1][baseIndex + k] ? Bindings[1][baseIndex + k] : Bindings[0][baseIndex + k]; - AddString(MenuRightSideEntry, y, g_KeyNames[index].c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); + int defaultKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Default, (InputActionID)(baseIndex + k)); + int userKeyID = g_Bindings.GetBoundKeyID(InputDeviceID::Custom, (InputActionID)(baseIndex + k)); + + int key = userKeyID ? userKeyID : defaultKeyID; + AddString(MenuRightSideEntry, y, GetKeyName(key).c_str(), PRINTSTRING_COLOR_ORANGE, SF(false)); } if (k < (MenuActionStrings.size() - 1)) @@ -890,7 +903,7 @@ namespace TEN::Renderer if (!texture.Texture) return; - int timeout = 10; + int timeout = 20; float currentFade = FADE_FACTOR; while (timeout || currentFade > 0.0f) @@ -1318,7 +1331,7 @@ namespace TEN::Renderer PrintDebugMessage("RoomNumber: %d", LaraItem->RoomNumber); PrintDebugMessage("PathfindingBoxID: %d", LaraItem->BoxNumber); PrintDebugMessage((Lara.Context.WaterSurfaceDist == -NO_HEIGHT ? "WaterSurfaceDist: N/A" : "WaterSurfaceDist: %d"), Lara.Context.WaterSurfaceDist); - PrintDebugMessage("Room Position: %d, %d, %d, %d", room.Position.z, room.Position.z, room.Position.z + BLOCK(room.XSize), room.Position.z + BLOCK(room.ZSize)); + PrintDebugMessage("Room Bounds: (%d, %d), (%d, %d)", room.Position.x, room.Position.z, room.Position.x + BLOCK(room.XSize), room.Position.z + BLOCK(room.ZSize)); PrintDebugMessage("Room.y, minFloor, maxCeiling: %d, %d, %d ", room.Position.y, room.BottomHeight, room.TopHeight); PrintDebugMessage("Camera Position: %d, %d, %d", Camera.pos.x, Camera.pos.y, Camera.pos.z); PrintDebugMessage("Camera LookAt: %d, %d, %d", Camera.target.x, Camera.target.y, Camera.target.z); @@ -1347,7 +1360,7 @@ namespace TEN::Renderer auto heldActions = BitField((int)In::Count); auto releasedActions = BitField((int)In::Count); - for (const auto& action : ActionMap) + for (const auto& [actionID, action] : ActionMap) { if (action.IsClicked()) clickedActions.Set((int)action.GetID()); @@ -1363,9 +1376,9 @@ namespace TEN::Renderer PrintDebugMessage(("Clicked actions: " + clickedActions.ToString()).c_str()); PrintDebugMessage(("Held actions: " + heldActions.ToString()).c_str()); PrintDebugMessage(("Released actions: " + releasedActions.ToString()).c_str()); - PrintDebugMessage("Move axes: %.3f, %.3f", AxisMap[(int)InputAxis::Move].x, AxisMap[(int)InputAxis::Move].y); - PrintDebugMessage("Camera axes: %.3f, %.3f", AxisMap[(int)InputAxis::Camera].x, AxisMap[(int)InputAxis::Camera].y); - PrintDebugMessage("Mouse axes: %.3f, %.3f", AxisMap[(int)InputAxis::Mouse].x, AxisMap[(int)InputAxis::Mouse].y); + PrintDebugMessage("Move axes: %.3f, %.3f", AxisMap[InputAxisID::Move].x, AxisMap[InputAxisID::Move].y); + PrintDebugMessage("Camera axes: %.3f, %.3f", AxisMap[InputAxisID::Camera].x, AxisMap[InputAxisID::Camera].y); + PrintDebugMessage("Mouse axes: %.3f, %.3f", AxisMap[InputAxisID::Mouse].x, AxisMap[InputAxisID::Mouse].y); PrintDebugMessage("Cursor pos: %.3f, %.3f", GetMouse2DPosition().x, GetMouse2DPosition().y); } break; diff --git a/TombEngine/Renderer/RendererEnums.h b/TombEngine/Renderer/RendererEnums.h index b0320eba8..1d005ccfd 100644 --- a/TombEngine/Renderer/RendererEnums.h +++ b/TombEngine/Renderer/RendererEnums.h @@ -38,6 +38,7 @@ constexpr auto ALPHA_BLEND_THRESHOLD = 1.0f - EPSILON; constexpr auto FAST_ALPHA_BLEND_THRESHOLD = 0.5f; constexpr auto MAX_BONES = 32; +constexpr auto MAX_BONE_WEIGHTS = 4; constexpr auto DISPLAY_SPACE_RES = Vector2(800.0f, 600.0f); constexpr auto REFERENCE_FONT_SIZE = 35.0f; diff --git a/TombEngine/Renderer/RendererFrame.cpp b/TombEngine/Renderer/RendererFrame.cpp index 0d4d2318a..d8d0fcdb0 100644 --- a/TombEngine/Renderer/RendererFrame.cpp +++ b/TombEngine/Renderer/RendererFrame.cpp @@ -5,6 +5,7 @@ #include "Game/camera.h" #include "Game/collision/Sphere.h" #include "Game/effects/effects.h" +#include "Game/effects/weather.h" #include "Game/items.h" #include "Game/Lara/lara.h" #include "Game/Setup.h" @@ -16,8 +17,9 @@ #include "Specific/level.h" #include "Specific/trutils.h" -using namespace TEN::Entities::Effects; using namespace TEN::Collision::Sphere; +using namespace TEN::Effects::Environment; +using namespace TEN::Entities::Effects; using namespace TEN::Math; using namespace TEN::Utils; @@ -401,6 +403,9 @@ namespace TEN::Renderer if (item.Status == ITEM_INVISIBLE) continue; + if (item.Model.Color.w < EPSILON) + continue; + if (item.ObjectNumber == ID_LARA && (SpotcamOverlay || SpotcamDontDrawLara)) continue; @@ -417,12 +422,15 @@ namespace TEN::Renderer // Clip object by frustum only if it doesn't cast shadows and is not in mirror room, // otherwise disappearing shadows or reflections may be seen if object gets out of frustum. + bool inFrustum = true; + if (!isRoomReflected && obj.ShadowType == ShadowMode::None) { + inFrustum = false; + // Get all spheres and check if frustum intersects any of them. auto spheres = GetSpheres(itemNumber); - bool inFrustum = false; for (int i = 0; !inFrustum, i < spheres.size(); i++) { // Blow up sphere radius by half for cases of too small calculated spheres. @@ -430,8 +438,8 @@ namespace TEN::Renderer inFrustum = true; } - if (!inFrustum) - continue; + // NOTE: removed continue loop here if not in frustum, + // for updating first positions and animations data } auto& newItem = _items[itemNumber]; @@ -449,7 +457,11 @@ namespace TEN::Renderer // Renderer slot has no interpolation flag set in case it is fetched for first time (e.g. item first time in frustum). newItem.DisableInterpolation = item.DisableInterpolation || newItem.DisableInterpolation; - if (newItem.DisableInterpolation) + // Disable interpolation when object has traveled significant distance. + // Needed because when object goes out of frustum, previous position doesn't update. + bool posChanged = Vector3::Distance(newItem.PrevPosition, newItem.Position) > BLOCK(1); + + if (newItem.DisableInterpolation || posChanged) { // NOTE: Interpolation always returns same result. newItem.PrevPosition = newItem.Position; @@ -467,16 +479,23 @@ namespace TEN::Renderer // Force interpolation only for player in player freeze mode. bool forceValue = g_GameFlow->CurrentFreezeMode == FreezeMode::Player && item.ObjectNumber == ID_LARA; + float interpFactor = GetInterpolationFactor(forceValue); - newItem.InterpolatedPosition = Vector3::Lerp(newItem.PrevPosition, newItem.Position, GetInterpolationFactor(forceValue)); - newItem.InterpolatedTranslation = Matrix::Lerp(newItem.PrevTranslation, newItem.Translation, GetInterpolationFactor(forceValue)); - newItem.InterpolatedRotation = Matrix::Lerp(newItem.InterpolatedRotation, newItem.Rotation, GetInterpolationFactor(forceValue)); - newItem.InterpolatedScale = Matrix::Lerp(newItem.InterpolatedScale, newItem.Scale, GetInterpolationFactor(forceValue)); - newItem.InterpolatedWorld = Matrix::Lerp(newItem.PrevWorld, newItem.World, GetInterpolationFactor(forceValue)); + newItem.InterpolatedPosition = Vector3::Lerp(newItem.PrevPosition, newItem.Position, interpFactor); + newItem.InterpolatedTranslation = Matrix::Lerp(newItem.PrevTranslation, newItem.Translation, interpFactor); + newItem.InterpolatedRotation = Matrix::Lerp(newItem.InterpolatedRotation, newItem.Rotation, interpFactor); + newItem.InterpolatedScale = Matrix::Lerp(newItem.InterpolatedScale, newItem.Scale, interpFactor); + newItem.InterpolatedWorld = Matrix::Lerp(newItem.PrevWorld, newItem.World, interpFactor); for (int j = 0; j < MAX_BONES; j++) newItem.InterpolatedAnimTransforms[j] = Matrix::Lerp(newItem.PrevAnimTransforms[j], newItem.AnimTransforms[j], GetInterpolationFactor(forceValue)); + // NOTE: now at least positions and animations are updated, + // because even off-screen the correct position is required + // by GetJointPosition functions and similars + if (!inFrustum) + continue; + CalculateLightFades(&newItem); CollectLightsForItem(&newItem); @@ -517,6 +536,9 @@ namespace TEN::Renderer if (!(nativeMesh->flags & StaticMeshFlags::SM_VISIBLE)) continue; + if (nativeMesh->color.w < EPSILON) + continue; + if (!_staticObjects[Statics.GetIndex(mesh->ObjectNumber)].has_value()) continue; @@ -813,7 +835,7 @@ namespace TEN::Renderer } // Light already on a list - if (std::find(renderView.LightsToDraw.begin(), renderView.LightsToDraw.end(), light) != renderView.LightsToDraw.end()) + if (TEN::Utils::Contains(renderView.LightsToDraw, light)) { continue; } diff --git a/TombEngine/Renderer/RendererHelper.cpp b/TombEngine/Renderer/RendererHelper.cpp index 671d41bda..cefc7879d 100644 --- a/TombEngine/Renderer/RendererHelper.cpp +++ b/TombEngine/Renderer/RendererHelper.cpp @@ -619,7 +619,7 @@ namespace TEN::Renderer time(&rawtime); auto time = localtime(&rawtime); - strftime(buffer, sizeof(buffer), "/TEN-%d-%m-%Y-%H-%M-%S.png", time); + strftime(buffer, sizeof(buffer), "/TEN-%Y-%m-%d_%H-%M-%S.png", time); auto screenPath = g_GameFlow->GetGameDir() + "Screenshots"; diff --git a/TombEngine/Renderer/RendererInit.cpp b/TombEngine/Renderer/RendererInit.cpp index 46fac3c2f..27136fabd 100644 --- a/TombEngine/Renderer/RendererInit.cpp +++ b/TombEngine/Renderer/RendererInit.cpp @@ -12,21 +12,24 @@ #include "Specific/configuration.h" #include "Specific/memory/Vector.h" #include "Specific/trutils.h" +#include "Specific/Video/Video.h" #include "Specific/winmain.h" extern GameConfiguration g_Configuration; using namespace TEN::Renderer::Utils; +using namespace TEN::Video; namespace TEN::Renderer { - void Renderer::Initialize(int w, int h, bool windowed, HWND handle) + void Renderer::Initialize(const std::string& gameDir, int w, int h, bool windowed, HWND handle) { TENLog("Initializing DX11...", LogLevel::Info); _screenWidth = w; _screenHeight = h; _isWindowed = windowed; + InitializeScreen(w, h, handle, false); InitializeCommonTextures(); @@ -39,22 +42,29 @@ namespace TEN::Renderer // Initialize input layout using first vertex shader. D3D11_INPUT_ELEMENT_DESC inputLayoutItems[] = { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "BINORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "ANIMATIONFRAMEOFFSET", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "EFFECTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "BLENDINDICES", 0, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "POLYINDEX", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "DRAWINDEX", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "HASH", 0, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BINORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "ANIMATIONFRAMEOFFSET", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "EFFECTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEINDICES", 0, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEINDICES", 1, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEINDICES", 2, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEINDICES", 3, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHTS", 0, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHTS", 1, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHTS", 2, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHTS", 3, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "POLYINDEX", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "DRAWINDEX", 0, DXGI_FORMAT_R32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "HASH", 0, DXGI_FORMAT_R32_SINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const auto& roomShader = _shaders.Get(Shader::Rooms); - Utils::throwIfFailed(_device->CreateInputLayout(inputLayoutItems, 12, roomShader.Vertex.Blob->GetBufferPointer(), roomShader.Vertex.Blob->GetBufferSize(), &_inputLayout)); + Utils::throwIfFailed(_device->CreateInputLayout(inputLayoutItems, 19, roomShader.Vertex.Blob->GetBufferPointer(), roomShader.Vertex.Blob->GetBufferSize(), &_inputLayout)); // Initialize constant buffers. _cbCameraMatrices = CreateConstantBuffer(); @@ -133,11 +143,11 @@ namespace TEN::Renderer blendStateDesc.AlphaToCoverageEnable = false; blendStateDesc.IndependentBlendEnable = false; blendStateDesc.RenderTarget[0].BlendEnable = true; - blendStateDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - blendStateDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - blendStateDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_REV_SUBTRACT; - blendStateDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; - blendStateDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_DEST_ALPHA; + blendStateDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_INV_DEST_COLOR; + blendStateDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_COLOR; + blendStateDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendStateDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendStateDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blendStateDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendStateDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; Utils::throwIfFailed(_device->CreateBlendState(&blendStateDesc, _excludeBlendState.GetAddressOf())); @@ -230,6 +240,9 @@ namespace TEN::Renderer _sortedPolygonsIndices.reserve(MAX_TRANSPARENT_VERTICES); _sortedPolygonsVertexBuffer = VertexBuffer(_device.Get(), MAX_TRANSPARENT_VERTICES, _sortedPolygonsVertices); _sortedPolygonsIndexBuffer = IndexBuffer(_device.Get(), MAX_TRANSPARENT_VERTICES, _sortedPolygonsIndices); + + // Initialize video player. + g_VideoPlayer.Initialize(gameDir, _device.Get(), _context.Get()); } void Renderer::InitializePostProcess() diff --git a/TombEngine/Renderer/RendererLara.cpp b/TombEngine/Renderer/RendererLara.cpp index 6ed781f8b..f73b4f5d7 100644 --- a/TombEngine/Renderer/RendererLara.cpp +++ b/TombEngine/Renderer/RendererLara.cpp @@ -312,6 +312,7 @@ void Renderer::DrawLara(RenderView& view, RendererPass rendererPass) _stItem.Color = item->Color; _stItem.AmbientLight = item->AmbientLight; + _stItem.Skinned = true; memcpy(_stItem.BonesMatrices, item->InterpolatedAnimTransforms, laraObj.AnimationTransforms.size() * sizeof(Matrix)); for (int k = 0; k < laraSkin.ObjectMeshes.size(); k++) { @@ -353,6 +354,7 @@ void Renderer::DrawLaraHair(RendererItem* itemToDraw, RendererRoom* room, Render _stItem.World = Matrix::Identity; _stItem.BonesMatrices[0] = itemToDraw->InterpolatedAnimTransforms[HairUnit::GetRootMeshID(i)] * itemToDraw->InterpolatedWorld; + _stItem.Skinned = false; ReflectMatrixOptionally(_stItem.BonesMatrices[0]); for (int i = 0; i < unit.Segments.size(); i++) diff --git a/TombEngine/Renderer/Structures/RendererAnimatedTexture.h b/TombEngine/Renderer/Structures/RendererAnimatedTexture.h index a31c9aa7d..587ec089c 100644 --- a/TombEngine/Renderer/Structures/RendererAnimatedTexture.h +++ b/TombEngine/Renderer/Structures/RendererAnimatedTexture.h @@ -8,5 +8,6 @@ namespace TEN::Renderer::Structures struct RendererAnimatedTexture { Vector2 UV[4]; + Vector2 NormalizedUV[4]; }; } diff --git a/TombEngine/Renderer/Structures/RendererAnimatedTextureSet.h b/TombEngine/Renderer/Structures/RendererAnimatedTextureSet.h index 65cbad469..19273a92e 100644 --- a/TombEngine/Renderer/Structures/RendererAnimatedTextureSet.h +++ b/TombEngine/Renderer/Structures/RendererAnimatedTextureSet.h @@ -6,10 +6,18 @@ namespace TEN::Renderer::Structures { using namespace DirectX::SimpleMath; + enum class AnimatedTextureType + { + Frames, + UVRotate, + Video + }; + struct RendererAnimatedTextureSet { - int NumTextures; - int Fps; + AnimatedTextureType Type = AnimatedTextureType::Frames; + int NumTextures = 0; + int Fps = 0; std::vector Textures; }; } diff --git a/TombEngine/Renderer/Structures/RendererHudBar.h b/TombEngine/Renderer/Structures/RendererHudBar.h index 74bfc9651..0e81c70a5 100644 --- a/TombEngine/Renderer/Structures/RendererHudBar.h +++ b/TombEngine/Renderer/Structures/RendererHudBar.h @@ -155,8 +155,6 @@ namespace TEN::Renderer::Structures vertices[i].Position = barVertices[i]; vertices[i].Color = colors[i]; vertices[i].UV = barUVs[i]; - vertices[i].Normal = Vector3::Zero; - vertices[i].Bone = 0.0f; } InnerVertexBuffer = VertexBuffer(devicePtr, (int)vertices.size(), &vertices[0]); @@ -168,8 +166,6 @@ namespace TEN::Renderer::Structures borderVertices[i].Position = barBorderVertices[i]; borderVertices[i].Color = Vector4::One; borderVertices[i].UV = barBorderUVs[i]; - borderVertices[i].Normal = Vector3::Zero; - borderVertices[i].Bone = 0.0f; } VertexBufferBorder = VertexBuffer(devicePtr, (int)borderVertices.size(), &borderVertices[0]); diff --git a/TombEngine/Renderer/Structures/RendererSprite.h b/TombEngine/Renderer/Structures/RendererSprite.h index 629974d65..105c89931 100644 --- a/TombEngine/Renderer/Structures/RendererSprite.h +++ b/TombEngine/Renderer/Structures/RendererSprite.h @@ -7,6 +7,8 @@ namespace TEN::Renderer::Structures using namespace TEN::Renderer::Graphics; using namespace DirectX::SimpleMath; + constexpr int VIDEO_SPRITE_ID = NO_VALUE; + struct RendererSprite { int Index; diff --git a/TombEngine/Renderer/Structures/RendererSprite2D.h b/TombEngine/Renderer/Structures/RendererSprite2D.h index 2e0dda9ed..50c4ecb01 100644 --- a/TombEngine/Renderer/Structures/RendererSprite2D.h +++ b/TombEngine/Renderer/Structures/RendererSprite2D.h @@ -1,24 +1,22 @@ -#pragma once -#include -#include "Renderer/Structures/RendererSprite.h" -#include "Renderer/RendererEnums.h" - -namespace TEN::Renderer::Structures -{ - using namespace DirectX::SimpleMath; - - struct RendererDisplaySpriteToDraw - { - const RendererSprite* SpritePtr = nullptr; - - Vector2 Position = Vector2::Zero; - short Orientation = 0; - Vector2 Size = Vector2::Zero; - Vector4 Color = Vector4::Zero; - - int Priority = 0; - BlendMode BlendMode = BlendMode::AlphaBlend; - - Vector2 AspectCorrection = Vector2::One; - }; -} +#pragma once + +#include "Renderer/Structures/RendererSprite.h" +#include "Renderer/RendererEnums.h" + +namespace TEN::Renderer::Structures +{ + struct RendererDisplaySpriteToDraw + { + const RendererSprite* SpritePtr = nullptr; + + Vector2 Position = Vector2::Zero; + short Orientation = 0; + Vector2 Size = Vector2::Zero; + Vector4 Color = Vector4::Zero; + + int Priority = 0; + BlendMode BlendMode = BlendMode::AlphaBlend; + + Vector2 AspectCorrection = Vector2::One; + }; +} diff --git a/TombEngine/Resources.rc b/TombEngine/Resources.rc index 0fa0b9c9e..46163b7a4 100644 --- a/TombEngine/Resources.rc +++ b/TombEngine/Resources.rc @@ -28,7 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL VS_VERSION_INFO VERSIONINFO FILEVERSION TEN_MAJOR_VERSION,TEN_MINOR_VERSION,TEN_BUILD_NUMBER,TEN_REVISION_NUMBER - PRODUCTVERSION TE_MAJOR_VERSION,TE_MINOR_VERSION,TE_BUILD_NUMBER,TE_REVISION_NUMBER + PRODUCTVERSION TEN_MAJOR_VERSION, TEN_MINOR_VERSION, TEN_BUILD_NUMBER, TEN_REVISION_NUMBER FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -49,7 +49,7 @@ BEGIN VALUE "OriginalFilename", "TombEngine.exe" VALUE "ProductName", "Tomb Engine" VALUE "FileVersion", TEN_VERSION_STRING - VALUE "ProductVersion", TE_VERSION_STRING + VALUE "ProductVersion", TEN_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/TombEngine/Resources/title.bin b/TombEngine/Resources/title.bin index 2ec566646..a68304d00 100644 Binary files a/TombEngine/Resources/title.bin and b/TombEngine/Resources/title.bin differ diff --git a/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h b/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h index e5a96489f..0933423ce 100644 --- a/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h +++ b/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h @@ -13,6 +13,7 @@ public: FreezeMode CurrentFreezeMode = FreezeMode::None; std::string IntroImagePath = {}; + std::string IntroVideoPath = {}; std::string TitleScreenImagePath = {}; int SelectedLevelForNewGame = 0; diff --git a/TombEngine/Scripting/Include/ScriptInterfaceGame.h b/TombEngine/Scripting/Include/ScriptInterfaceGame.h index 73b0be0ee..121cbe2f2 100644 --- a/TombEngine/Scripting/Include/ScriptInterfaceGame.h +++ b/TombEngine/Scripting/Include/ScriptInterfaceGame.h @@ -62,6 +62,7 @@ public: virtual void OnUseItem(GAME_OBJECT_ID objectNumber) = 0; virtual void OnFreeze() = 0; + virtual void AddConsoleInput(const std::string& input) = 0; virtual void ShortenTENCalls() = 0; virtual void FreeLevelScripts() = 0; virtual void ResetScripts(bool clearGameVars) = 0; diff --git a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h index 484f3a45f..67d976b63 100644 --- a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h +++ b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h @@ -22,9 +22,6 @@ enum class LaraType class ScriptInterfaceLevel { public: - bool Horizon = false; - bool Rumble = false; - std::string NameStringKey = {}; std::string FileName = {}; std::string ScriptFileName = {}; @@ -36,18 +33,27 @@ public: virtual short GetSkyLayerSpeed(int index) const = 0; virtual LaraType GetLaraType() const = 0; virtual bool GetStormEnabled() const = 0; + virtual bool GetRumbleEnabled() const = 0; virtual float GetWeatherStrength() const = 0; virtual WeatherType GetWeatherType() const = 0; virtual RGBAColor8Byte GetSkyLayerColor(int index) const = 0; - virtual bool GetFogEnabled() const = 0; virtual RGBAColor8Byte GetFogColor() const = 0; - virtual short GetFogMinDistance() const = 0; - virtual short GetFogMaxDistance() const = 0; + virtual float GetFogMinDistance() const = 0; + virtual float GetFogMaxDistance() const = 0; virtual short GetFarView() const = 0; virtual int GetSecrets() const = 0; virtual std::string GetAmbientTrack() const = 0; virtual bool GetResetHubEnabled() const = 0; + // Horizon getters + virtual bool GetHorizonEnabled(int index) const = 0; + virtual GAME_OBJECT_ID GetHorizonObjectID(int index) const = 0; + virtual float GetHorizonTransparency(int index) const = 0; + virtual Vector3 GetHorizonPosition(int index) const = 0; + virtual EulerAngles GetHorizonOrientation(int index) const = 0; + virtual Vector3 GetHorizonPrevPosition(int index) const = 0; + virtual EulerAngles GetHorizonPrevOrientation(int index) const = 0; + // Lens flare getters virtual bool GetLensFlareEnabled() const = 0; virtual int GetLensFlareSunSpriteID() const = 0; @@ -56,8 +62,6 @@ public: virtual Color GetLensFlareColor() const = 0; // Starfield getters - virtual bool GetStarfieldStarsEnabled() const = 0; - virtual bool GetStarfieldMeteorsEnabled() const = 0; virtual int GetStarfieldStarCount() const = 0; virtual int GetStarfieldMeteorCount() const = 0; virtual int GetStarfieldMeteorSpawnDensity() const = 0; diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h index 6b250364b..32e859c77 100644 --- a/TombEngine/Scripting/Internal/ReservedScriptNames.h +++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h @@ -220,6 +220,7 @@ static constexpr char ScriptReserved_AddLevel[] = "AddLevel"; static constexpr char ScriptReserved_GetLevel[] = "GetLevel"; static constexpr char ScriptReserved_GetCurrentLevel[] = "GetCurrentLevel"; static constexpr char ScriptReserved_SetIntroImagePath[] = "SetIntroImagePath"; +static constexpr char ScriptReserved_SetIntroVideoPath[] = "SetIntroVideoPath"; static constexpr char ScriptReserved_SetTitleScreenImagePath[] = "SetTitleScreenImagePath"; static constexpr char ScriptReserved_SetFarView[] = "SetFarView"; static constexpr char ScriptReserved_SetAnimations[] = "SetAnimations"; @@ -237,6 +238,7 @@ static constexpr char ScriptReserved_DeleteSaveGame[] = "DeleteSaveGame"; static constexpr char ScriptReserved_DoesSaveGameExist[] = "DoesSaveGameExist"; static constexpr char ScriptReserved_GetSecretCount[] = "GetSecretCount"; static constexpr char ScriptReserved_SetSecretCount[] = "SetSecretCount"; +static constexpr char ScriptReserved_GetTotalSecretCount[] = "GetTotalSecretCount"; static constexpr char ScriptReserved_SetTotalSecretCount[] = "SetTotalSecretCount"; static constexpr char ScriptReserved_AddSecret[] = "AddSecret"; static constexpr char ScriptReserved_EnableFlyCheat[] = "EnableFlyCheat"; @@ -312,6 +314,7 @@ static constexpr char ScriptReserved_EnableEvent[] = "EnableEvent"; static constexpr char ScriptReserved_DisableEvent[] = "DisableEvent"; static constexpr char ScriptReserved_EmitParticle[] = "EmitParticle"; +static constexpr char ScriptReserved_EmitAdvancedParticle[] = "EmitAdvancedParticle"; static constexpr char ScriptReserved_EmitLightningArc[] = "EmitLightningArc"; static constexpr char ScriptReserved_EmitShockwave[] = "EmitShockwave"; static constexpr char ScriptReserved_EmitLight[] = "EmitLight"; @@ -319,9 +322,11 @@ static constexpr char ScriptReserved_EmitSpotLight[] = "EmitSpotLight"; static constexpr char ScriptReserved_EmitBlood[] = "EmitBlood"; static constexpr char ScriptReserved_EmitAirBubble[] = "EmitAirBubble"; static constexpr char ScriptReserved_EmitFire[] = "EmitFire"; +static constexpr char ScriptReserved_EmitStreamer[] = "EmitStreamer"; static constexpr char ScriptReserved_MakeExplosion[] = "MakeExplosion"; static constexpr char ScriptReserved_MakeEarthquake[] = "MakeEarthquake"; -static constexpr char ScriptReserved_GetWind[] = "GetWind"; + +static constexpr char ScriptReserved_GetWind[] = "GetWind"; static constexpr char ScriptReserved_Vibrate[] = "Vibrate"; static constexpr char ScriptReserved_FlashScreen[] = "FlashScreen"; static constexpr char ScriptReserved_FadeIn[] = "FadeIn"; @@ -348,6 +353,12 @@ static constexpr char ScriptReserved_KeyClearAll[] = "KeyClearAll"; static constexpr char ScriptReserved_FlipMap[] = "FlipMap"; static constexpr char ScriptReserved_GetFlipMapStatus[] = "GetFlipMapStatus"; +static constexpr char ScriptReserved_PlayVideo[] = "PlayVideo"; +static constexpr char ScriptReserved_StopVideo[] = "StopVideo"; +static constexpr char ScriptReserved_IsVideoPlaying[] = "IsVideoPlaying"; +static constexpr char ScriptReserved_GetVideoPosition[] = "GetVideoPosition"; +static constexpr char ScriptReserved_SetVideoPosition[] = "SetVideoPosition"; +static constexpr char ScriptReserved_GetVideoDominantColor[] = "GetVideoDominantColor"; static constexpr char ScriptReserved_PlayFlyby[] = "PlayFlyby"; static constexpr char ScriptReserved_GetFlybyPosition[] = "GetFlybyPosition"; static constexpr char ScriptReserved_GetFlybyRotation[] = "GetFlybyRotation"; @@ -357,15 +368,17 @@ static constexpr char ScriptReserved_ResetObjCamera[] = "ResetObjCamera"; static constexpr char ScriptReserved_UndrawWeapon[] = "UndrawWeapon"; static constexpr char ScriptReserved_GetHandStatus[] = "GetHandStatus"; static constexpr char ScriptReserved_GetWeaponType[] = "GetWeaponType"; -static constexpr char ScriptReserved_ThrowAwayTorch[] = "ThrowAwayTorch"; +static constexpr char ScriptReserved_PlayerDiscardTorch[] = "DiscardTorch"; static constexpr char ScriptReserved_SetWeaponType[] = "SetWeaponType"; -static constexpr char ScriptReserved_TorchIsLit[] = "TorchIsLit"; +static constexpr char ScriptReserved_PlayerIsTorchLit[] = "IsTorchLit"; static constexpr char ScriptReserved_PrintLog[] = "PrintLog"; static constexpr char ScriptReserved_PickMoveable[] = "PickMoveableByDisplayPosition"; static constexpr char ScriptReserved_PickStatic[] = "PickStaticByDisplayPosition"; static constexpr char ScriptReserved_GetDisplayPosition[] = "GetDisplayPosition"; static constexpr char ScriptReserved_GetCursorDisplayPosition[] = "GetCursorDisplayPosition"; // Deprecated static constexpr char ScriptReserved_GetMouseDisplayPosition[] = "GetMouseDisplayPosition"; +static constexpr char ScriptReserved_PlayerInteract[] = "Interact"; +static constexpr char ScriptReserved_PlayerTestInteraction[] = "TestInteraction"; // Tables static constexpr char ScriptReserved_ObjID[] = "ObjID"; @@ -384,6 +397,8 @@ static constexpr char ScriptReserved_EndReason[] = "EndReason"; static constexpr char ScriptReserved_EventType[] = "EventType"; static constexpr char ScriptReserved_AlignMode[] = "AlignMode"; static constexpr char ScriptReserved_ScaleMode[] = "ScaleMode"; +static constexpr char ScriptReserved_ParticleAnimationType[] = "ParticleAnimationType"; +static constexpr char ScriptReserved_FeatherMode[] = "StreamerFeatherMode"; static constexpr char ScriptReserved_LevelVars[] = "LevelVars"; static constexpr char ScriptReserved_GameVars[] = "GameVars"; @@ -398,6 +413,35 @@ static constexpr char ScriptReserved_LogLevelError[] = "ERROR"; // Internal static constexpr char ScriptReserved_LaraObject[] = "LaraObject"; +// ========= +// COLLISION +// ========= + +constexpr char ScriptReserved_Collision[] = "Collision"; + +constexpr char ScriptReserved_Probe[] = "Probe"; +constexpr char ScriptReserved_ProbeGetCeilingHeight[] = "GetCeilingHeight"; +constexpr char ScriptReserved_ProbeGetCeilingMaterialType[] = "GetCeilingMaterialType"; +constexpr char ScriptReserved_ProbeGetCeilingNormal[] = "GetCeilingNormal"; +constexpr char ScriptReserved_ProbeGetFloorHeight[] = "GetFloorHeight"; +constexpr char ScriptReserved_ProbeGetFloorMaterialType[] = "GetFloorMaterialType"; +constexpr char ScriptReserved_ProbeGetFloorNormal[] = "GetFloorNormal"; +constexpr char ScriptReserved_ProbeGetPosition[] = "GetPosition"; +constexpr char ScriptReserved_ProbeGetRoom[] = "GetRoom"; +constexpr char ScriptReserved_ProbeGetRoomName[] = "GetRoomName"; +constexpr char ScriptReserved_ProbeGetRoomNumber[] = "GetRoomNumber"; +constexpr char ScriptReserved_ProbeGetWaterSurfaceHeight[] = "GetWaterSurfaceHeight"; +constexpr char ScriptReserved_ProbeIsClimbableWall[] = "IsClimbableWall"; +constexpr char ScriptReserved_ProbeIsDeathTile[] = "IsDeathTile"; +constexpr char ScriptReserved_ProbeIsInsideSolidGeometry[] = "IsInsideSolidGeometry"; +constexpr char ScriptReserved_ProbeIsMonkeySwing[] = "IsMonkeySwing"; +constexpr char ScriptReserved_ProbeIsSteepCeiling[] = "IsSteepCeiling"; +constexpr char ScriptReserved_ProbeIsSteepFloor[] = "IsSteepFloor"; +constexpr char ScriptReserved_ProbeIsWall[] = "IsWall"; +constexpr char ScriptReserved_ProbePreview[] = "Preview"; + +constexpr char ScriptReserved_MaterialType[] = "MaterialType"; + // ======= // OBJECTS // ======= @@ -439,6 +483,7 @@ constexpr char ScriptReserved_StaticGetPosition[] = "GetPosition"; constexpr char ScriptReserved_StaticGetRotation[] = "GetRotation"; constexpr char ScriptReserved_StaticGetScale[] = "GetScale"; constexpr char ScriptReserved_StaticGetSlot[] = "GetSlot"; +constexpr char ScriptReserved_StaticGetCollidable[] = "GetCollidable"; constexpr char ScriptReserved_StaticGetSolid[] = "GetSolid"; constexpr char ScriptReserved_StaticSetColor[] = "SetColor"; constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHP"; @@ -448,37 +493,9 @@ constexpr char ScriptReserved_StaticSetRotation[] = "SetRotation"; constexpr char ScriptReserved_StaticSetScale[] = "SetScale"; constexpr char ScriptReserved_StaticSetSlot[] = "SetSlot"; constexpr char ScriptReserved_StaticSetSolid[] = "SetSolid"; +constexpr char ScriptReserved_StaticSetCollidable[] = "SetCollidable"; constexpr char ScriptReserved_StaticShatter[] = "Shatter"; -// ========= -// COLLISION -// ========= - -constexpr char ScriptReserved_Collision[] = "Collision"; - -constexpr char ScriptReserved_Probe[] = "Probe"; -constexpr char ScriptReserved_ProbeGetCeilingHeight[] = "GetCeilingHeight"; -constexpr char ScriptReserved_ProbeGetCeilingMaterialType[] = "GetCeilingMaterialType"; -constexpr char ScriptReserved_ProbeGetCeilingNormal[] = "GetCeilingNormal"; -constexpr char ScriptReserved_ProbeGetFloorHeight[] = "GetFloorHeight"; -constexpr char ScriptReserved_ProbeGetFloorMaterialType[] = "GetFloorMaterialType"; -constexpr char ScriptReserved_ProbeGetFloorNormal[] = "GetFloorNormal"; -constexpr char ScriptReserved_ProbeGetPosition[] = "GetPosition"; -constexpr char ScriptReserved_ProbeGetRoom[] = "GetRoom"; -constexpr char ScriptReserved_ProbeGetRoomName[] = "GetRoomName"; -constexpr char ScriptReserved_ProbeGetRoomNumber[] = "GetRoomNumber"; -constexpr char ScriptReserved_ProbeGetWaterSurfaceHeight[] = "GetWaterSurfaceHeight"; -constexpr char ScriptReserved_ProbeIsClimbableWall[] = "IsClimbableWall"; -constexpr char ScriptReserved_ProbeIsDeathTile[] = "IsDeathTile"; -constexpr char ScriptReserved_ProbeIsInsideSolidGeometry[] = "IsInsideSolidGeometry"; -constexpr char ScriptReserved_ProbeIsMonkeySwing[] = "IsMonkeySwing"; -constexpr char ScriptReserved_ProbeIsSteepCeiling[] = "IsSteepCeiling"; -constexpr char ScriptReserved_ProbeIsSteepFloor[] = "IsSteepFloor"; -constexpr char ScriptReserved_ProbeIsWall[] = "IsWall"; -constexpr char ScriptReserved_ProbePreview[] = "Preview"; - -constexpr char ScriptReserved_MaterialType[] = "MaterialType"; - // ===== // TYPES // ===== diff --git a/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h b/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h index 434a41a20..a23f2d348 100644 --- a/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h +++ b/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h @@ -7,6 +7,9 @@ // @pragma nostrip /// Table of MaterialType constants. +//
                                                      +// Corresponds to Tomb Editor texture sound material types. +// To be used with @{Collision.Probe.GetFloorMaterialType} and @{Collision.Probe.GetCeilingMaterialType}. // // - `MUD` // - `SNOW` diff --git a/TombEngine/Scripting/Internal/TEN/Collision/Probe.cpp b/TombEngine/Scripting/Internal/TEN/Collision/Probe.cpp index 392410c40..b7295b7b9 100644 --- a/TombEngine/Scripting/Internal/TEN/Collision/Probe.cpp +++ b/TombEngine/Scripting/Internal/TEN/Collision/Probe.cpp @@ -26,6 +26,7 @@ namespace TEN::Scripting::Collision void Probe::Register(sol::table& parent) { using ctors = sol::constructors< + Probe(const Vec3&), Probe(const Vec3&, int), Probe(const Vec3&, int, const Vec3&, float), Probe(const Vec3&, int, const Rotation&, float), @@ -65,13 +66,17 @@ namespace TEN::Scripting::Collision /// Create a Probe at a specified world position in a room. // @function Probe // @tparam Vec3 pos World position. - // @tparam int roomNumber[opt] Room number. Must be used if probing a position in an overlapping room. + // @tparam[opt] int roomNumber Room number. Must be used if probing a position in an overlapping room. // @treturn Probe A new Probe. - Probe::Probe(const Vec3& pos, TypeOrNil roomNumber) + Probe::Probe(const Vec3& pos) { auto convertedPos = pos.ToVector3i(); - int roomNumberValue = ValueOr(roomNumber, FindRoomNumber(convertedPos)); - _pointCollision = GetPointCollision(convertedPos, roomNumberValue); + _pointCollision = GetPointCollision(convertedPos, FindRoomNumber(convertedPos)); + } + + Probe::Probe(const Vec3& pos, int roomNumber) + { + _pointCollision = GetPointCollision(pos.ToVector3i(), roomNumber); } /// Create a Probe that casts from an origin world position in a room in a given direction for a specified distance. @@ -326,9 +331,9 @@ namespace TEN::Scripting::Collision // @function Preview void Probe::Preview() { - constexpr auto TARGET_RADIUS = 100.0f; - constexpr auto SPHERE_RADIUS = TARGET_RADIUS * 0.6f; - constexpr auto COLOR = Color(1.0f, 1.0f, 1.0f, 0.4f); + constexpr auto TARGET_RADIUS = BLOCK(0.08f); + constexpr auto SPHERE_RADIUS = TARGET_RADIUS * 0.4f; + constexpr auto COLOR = Color(1.0f, 1.0f, 0.8f, 0.2f); constexpr auto DEBUG_PAGE = RendererDebugPage::CollisionStats; auto pos = _pointCollision.GetPosition().ToVector3(); diff --git a/TombEngine/Scripting/Internal/TEN/Collision/Probe.h b/TombEngine/Scripting/Internal/TEN/Collision/Probe.h index 86fb90459..d96a78ed8 100644 --- a/TombEngine/Scripting/Internal/TEN/Collision/Probe.h +++ b/TombEngine/Scripting/Internal/TEN/Collision/Probe.h @@ -31,7 +31,8 @@ namespace TEN::Scripting::Collision // Constructors Probe() = default; - Probe(const Vec3& pos, TypeOrNil roomNumber); + Probe(const Vec3& pos); + Probe(const Vec3& pos, int roomNumber); Probe(const Vec3& origin, int roomNumber, const Vec3& dir, float dist); Probe(const Vec3& origin, int roomNumber, const Rotation& rot, float dist); Probe(const Vec3& origin, int roomNumber, const Rotation& rot, const Vec3& relOffset); diff --git a/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h index af1c1c4f7..744efb496 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h +++ b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h @@ -2,26 +2,28 @@ #include "Renderer/RendererEnums.h" -/// Constants for blend mode IDs. -// @enum Effects.BlendID -// @pragma nostrip - -/// Table of Effects.BlendID constants. -// -// - `OPAQUE` -// - `ALPHA_TEST` -// - `ADDITIVE` -// - `NO_DEPTH_TEST` -// - `SUBTRACTIVE` -// - `EXCLUDE` -// - `SCREEN` -// - `LIGHTEN` -// - `ALPHA_BLEND` -// -// @table Effects.BlendID - namespace TEN::Scripting::Effects { + /// Constants for blend mode IDs. + // @enum Effects.BlendID + // @pragma nostrip + + /// Table of Effects.BlendID constants. + //
                                                      + // All blending modes except `OPAQUE`, `ADDITIVE` and `ALPHA_BLEND` will use depth sorting for applicable polygons. + // This may reduce engine performance, so it is preferable to minimize usage of other blending modes. + // + // - `OPAQUE` - No transparency. + // - `ALPHA_TEST` - So called "magenta transparency", every pixel can be either fully transparent or opaque. + // - `ADDITIVE` - Standard additive blending. + // - `SUBTRACTIVE` - Subtractive blending, with brighter texture areas making everything darker behind them. + // - `EXCLUDE` - Produces "inversion" effect. + // - `SCREEN` - Similar to `ADDITIVE`, but without excessive overbright. + // - `LIGHTEN` - Similar to `SCREEN`, but with a little different blending formula. + // - `ALPHA_BLEND` - True alpha blending. Should be used for textures with gradually changing alpha values. + // + // @table Effects.BlendID + static const auto BLEND_IDS = std::unordered_map { { "OPAQUE", BlendMode::Opaque }, diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h b/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h index 27d4e9bf1..93e3cd54b 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h +++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h @@ -2,26 +2,26 @@ #include "Game/items.h" -/// Constants for effect IDs. -// @enum Effects.EffectID -// @pragma nostrip - -/// Table of Effects.EffectID constants. -// To be used with @{Objects.Moveable.SetEffect} and @{Objects.Moveable.GetEffect} functions. -// -// - `NONE` -// - `FIRE` -// - `SPARKS` -// - `SMOKE` -// - `ELECTRIC_IGNITE` -// - `RED_IGNITE` -// - `CADAVER` -// - `CUSTOM` -// -// @table Effects.EffectID - namespace TEN::Scripting::Effects { + /// Constants for effect IDs. + // @enum Effects.EffectID + // @pragma nostrip + + /// Table of Effects.EffectID constants. + // To be used with @{Objects.Moveable.SetEffect} and @{Objects.Moveable.GetEffect} functions. + // + // - `NONE` + // - `FIRE` + // - `SPARKS` + // - `SMOKE` + // - `ELECTRIC_IGNITE` + // - `RED_IGNITE` + // - `CADAVER` + // - `CUSTOM` + // + // @table Effects.EffectID + static const auto EFFECT_IDS = std::unordered_map { { "NONE", EffectType::None }, @@ -37,3 +37,4 @@ namespace TEN::Scripting::Effects { "REDIGNITE", EffectType::RedIgnite } }; } + diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp index ef2105625..6463e6e3f 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp +++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp @@ -10,6 +10,7 @@ #include "Game/effects/Electricity.h" #include "Game/effects/explosion.h" #include "Game/effects/spark.h" +#include "Game/effects/Streamer.h" #include "Game/effects/tomb4fx.h" #include "Game/effects/weather.h" #include "Game/Setup.h" @@ -20,12 +21,16 @@ #include "Scripting/Internal/ScriptUtil.h" #include "Scripting/Internal/TEN/Effects/BlendIDs.h" #include "Scripting/Internal/TEN/Effects/EffectIDs.h" +#include "Scripting/Internal/TEN/Effects/ParticleAnimTypes.h" +#include "Scripting/Internal/TEN/Effects/FeatherModes.h" #include "Scripting/Internal/TEN/Types/Color/Color.h" +#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h" #include "Scripting/Internal/TEN/Types/Vec3/Vec3.h" #include "Scripting/Internal/TEN/Types/Vec2/Vec2.h" #include "Sound/sound.h" #include "Specific/clock.h" #include "Specific/trutils.h" +#include /// Functions to generate effects. // @tentable Effects @@ -37,26 +42,30 @@ using namespace TEN::Effects::Electricity; using namespace TEN::Effects::Environment; using namespace TEN::Effects::Explosion; using namespace TEN::Effects::Spark; +using namespace TEN::Effects::Streamer; using namespace TEN::Math; using namespace TEN::Scripting::Types; -namespace TEN::Scripting::Effects +namespace TEN::Scripting::Effects { - ///Emit a lightning arc. - //@function EmitLightningArc - //@tparam Vec3 src - //@tparam Vec3 dest - //@tparam Color color (default Color(255, 255, 255)) - //@tparam float lifetime Lifetime in seconds. Clamped to [0, 4.233] for now because of strange internal maths. (default 1.0) - //@tparam int amplitude "strength" of the lightning - the higher the value, the "taller" the arcs. Clamped to [1, 255]. (default 20) - //@tparam int beamWidth Clamped to [1, 127]. (default 2) - //@tparam int detail Higher numbers equal more segments, but it's not a 1:1 correlation. Clamped to [1, 127]. (default 10) - //@tparam bool smooth If true, the arc will have large, smooth curves; if false, it will have small, jagged spikes. (default false) - //@tparam bool endDrift If true, the end of the arc will be able to gradually drift away from its destination in a random direction (default false) - static void EmitLightningArc(Vec3 src, Vec3 dest, TypeOrNil color, TypeOrNil lifetime, TypeOrNil amplitude, TypeOrNil beamWidth, TypeOrNil segments, TypeOrNil smooth, TypeOrNil endDrift) + /// Emit a lightning arc. + // @function EmitLightningArc + // @tparam Vec3 origin + // @tparam Vec3 target + // @tparam[opt=Color(255, 255, 255)] Color color. + // @tparam[opt=1] float life Lifetime in seconds. Clamped to [0, 4.233] for now because of strange internal maths. + // @tparam[opt=20] int amplitude Strength of the lightning - the higher the value, the "taller" the arcs. Clamped to [1, 255]. + // @tparam[opt=2] int beamWidth Beam width. Clamped to [1, 127]. + // @tparam[opt=10] int detail Higher numbers equal more segments, but it's not a 1:1 correlation. Clamped to [1, 127]. + // @tparam[opt=false] bool smooth If true, the arc will have large, smooth curves; if false, it will have small, jagged spikes. + // @tparam[opt=false] bool endDrift If true, the end of the arc will be able to gradually drift away from its destination in a random direction. + static void EmitLightningArc(const Vec3& origin, const Vec3& target, TypeOrNil color, TypeOrNil life, TypeOrNil amplitude, + TypeOrNil beamWidth, TypeOrNil segments, TypeOrNil smooth, TypeOrNil endDrift) { - auto p1 = Vector3(src.x, src.y, src.z); - auto p2 = Vector3(dest.x, dest.y, dest.z); + constexpr auto LIFE_SEC_MAX = 4.233f; + + auto convertedOrigin = origin.ToVector3(); + auto convertedTarget = target.ToVector3(); int segs = ValueOr(segments, 10); @@ -69,21 +78,20 @@ namespace TEN::Scripting::Effects // Nearest number of milliseconds equating to approx 254, the max even byte value for "life". // This takes into account a "hardcoded" FPS of 30 and the fact that // lightning loses two "life" each frame. - constexpr auto kMaxLifeSeconds = 4.233f; - float life = ValueOr(lifetime, 1.0f); - life = std::clamp(life, 0.0f, kMaxLifeSeconds); + float convertedLife = ValueOr(life, 1.0f); + convertedLife = std::clamp(convertedLife, 0.0f, LIFE_SEC_MAX); constexpr float secsPerFrame = 1.0f / (float)FPS; // This will put us in the range [0, 127] - int lifeInFrames = (int)round(life / secsPerFrame); + int lifeInFrames = (int)round(convertedLife / secsPerFrame); // Multiply by two since a) lightning loses two "life" each frame, and b) it must be // an even number to avoid overshooting a value of 0 and wrapping around. byte byteLife = lifeInFrames * 2; int amp = ValueOr(amplitude, 20); - byte byteAmplitude = std::clamp(amp, 1, 255); + byte byteAmp = std::clamp(amp, 1, 255); bool isSmooth = ValueOr(smooth, false); bool isDrift = ValueOr(endDrift, false); @@ -95,46 +103,45 @@ namespace TEN::Scripting::Effects if(isDrift) flags |= 2; - ScriptColor col = ValueOr(color, ScriptColor( 255, 255, 255 )); + auto convertedColor = ValueOr(color, ScriptColor( 255, 255, 255 )); - SpawnElectricity(p1, p2, byteAmplitude, col.GetR(), col.GetG(), col.GetB(), byteLife, flags, width, segs); + SpawnElectricity(convertedOrigin, convertedTarget, byteAmp, convertedColor.GetR(), convertedColor.GetG(), convertedColor.GetB(), byteLife, flags, width, segs); } /// Emit a particle. // @function EmitParticle // @tparam Vec3 pos World position. - // @tparam Vec3 vel Velocity. - // @tparam int spriteID ID of the sprite in the sprite sequence object. - // @tparam float gravity Specifies if the particle will fall over time. Positive values ascend, negative values descend. Recommended range: [-1000 and 1000]. __Default: 0__ - // @tparam float rotVel Rotational velocity in degrees. __Default: 0__ - // @tparam Color startColor Color at start of life. __Default: Color(255, 255, 255)__ - // @tparam Color endColor Color to fade toward. This will finish long before the end of the particle's life due to internal math. __Default: Color(255, 255, 255)__ - // @tparam Effects.BlendID blendMode Render blend mode. __TEN.Effects.BlendID.ALPHABLEND__ - // @tparam float startSize Size at start of life. __Default: 10__ - // @tparam float endSize Size at end of life. The particle will linearly shrink or grow toward this size over its lifespan. __Default: 0__ - // @tparam float life Lifespan in seconds. __Default: 2__ - // @tparam bool applyDamage Specify if the particle will harm the player on collision. __Default: false__ - // @tparam bool applyPoison Specify if the particle will poison the player on collision. __Default: false__ - // @tparam Objects.ObjID spriteSeqID ID of the sprite sequence object. __Default: Objects.ObjID.DEFAULT_SPRITES__ - // @tparam float startRot Rotation at start of life. __Default: random__ + // @tparam Vec3 vel Directional velocity. + // @tparam int spriteID Sprite ID in the sprite sequence slot. + // @tparam[opt=0] float gravity Effect of gravity. Positive value ascends, negative value descends. + // @tparam[opt=0] float rotVel Rotational velocity in degrees. + // @tparam[opt=Color(255, 255, 255)] Color startColor Color at start of life. + // @tparam[opt=Color(255, 255, 255)] Color endColor Color at end of life. This will finish long before the end of the particle's life due to internal math. + // @tparam[opt=TEN.Effects.BlendID.ALPHA_BLEND] Effects.BlendID blendMode Render blend mode. + // @tparam[opt=10] float startSize Size at start of life. + // @tparam[opt=0] float endSize Size at end of life. + // @tparam[opt=2] float life Lifespan in seconds. + // @tparam[opt=false] bool damage Harm the player on collision. + // @tparam[opt=false] bool poison Poison the player on collision. + // @tparam[opt=Objects.ObjID.DEFAULT_SPRITES] Objects.ObjID.SpriteConstants spriteSeqID Sprite sequence slot ID. + // @tparam[opt=random] float startRot Rotation at start of life. // @usage // EmitParticle( - // pos, - // Vec3(math.random(), math.random(), math.random()), - // 22, -- spriteID - // 0, -- gravity - // -2, -- rotVel - // Color(255, 0, 0), -- startColor - // Color(0, 255, 0), -- endColor - // TEN.Effects.BlendID.ADDITIVE, -- blendMode - // 15, -- startSize - // 50, -- endSize - // 20, -- life - // false, -- applyDamage - // true, -- applyPoison - // Objects.ObjID.DEFAULT_SPRITES, -- spriteSeqID - // 180 -- startRot - // ) + // pos, + // Vec3(math.random(), math.random(), math.random()), + // 22, -- spriteID + // 0, -- gravity + // -2, -- rotVel + // Color(255, 0, 0), -- startColor + // Color(0, 255, 0), -- endColor + // TEN.Effects.BlendID.ADDITIVE, -- blendMode + // 15, -- startSize + // 50, -- endSize + // 20, -- life + // false, -- damage + // true, -- poison + // Objects.ObjID.DEFAULT_SPRITES, -- spriteSeqID + // 180) -- startRot static void EmitParticle(const Vec3& pos, const Vec3& vel, int spriteID, TypeOrNil gravity, TypeOrNil rotVel, TypeOrNil startColor, TypeOrNil endColor, TypeOrNil blendMode, TypeOrNil startSize, TypeOrNil endSize, TypeOrNil life, @@ -204,24 +211,205 @@ namespace TEN::Scripting::Effects bool convertedApplyDamage = ValueOr(applyDamage, false); if (convertedApplyDamage) + { part.flags |= SP_DAMAGE; + part.damage = 2; + } // TODO: Add option to turn off wind. if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WIND, part.roomNumber)) part.flags |= SP_WIND; } + + /// Emit a particle with extensive configuration options, including sprite sequence animation, lights, sounds, and damage effects. + // @function EmitAdvancedParticle + // @tparam ParticleData particleData Table containing particle data. + // @usage + // local particle = + // { + // pos = GetMoveableByName("camera_target_6"):GetPosition(), + // vel = Vec3(0, 0, 10), + // spriteSeqID = TEN.Objects.ObjID.CUSTOM_BAR_GRAPHIC, + // spriteID = 0, + // life = 10, + // maxYVel = 0, + // gravity = 0, + // friction = 10, + // startRot = 0, + // rotVel = 0, + // startSize = 80, + // endSize = 80, + // startColor = TEN.Color(128, 128, 128), + // endColor = TEN.Color(128, 128, 128), + // blendMode = TEN.Effects.BlendID.ADDITIVE, + // wind = false, + // damage = true, + // poison = false, + // burn = false, + // damageHit = 80, + // soundID = 197, + // light = true, + // lightRadius = 6, + // lightFlicker = 5, + // animated = true, + // frameRate = 0.25, + // animType = TEN.Effects.ParticleAnimationType.LOOP, + // } + // EmitAdvancedParticle(particle) + + /// Structure for EmitAdvancedParticle table. + // @table ParticleData + // @tfield Vec3 pos World position. + // @tfield Vec3 vel Directional velocity in world units per second. + // @tfield[opt=Objects.ObjID.DEFAULT_SPRITES] Objects.ObjID.SpriteConstants spriteSeqID Sprite sequence slot ID. + // @tfield[opt=0] int spriteID Sprite ID in the sprite sequence slot. + // @tfield[opt=2] float life Lifespan in seconds. + // @tfield[opt=0] float maxYVel Maximum vertical velocity in world units per second. + // @tfield[opt=0] float gravity Effect of gravity in world units per second. Positive value ascend, negative value descend. + // @tfield[opt=0] float friction Friction affecting velocity over time in world units per second. + // @tfield[opt=random] float startRot Rotation at start of life. + // @tfield[opt=0] float rotVel Rotational velocity in degrees per second. + // @tfield[opt=10] float startSize Size at start of life. + // @tfield[opt=0] float endSize Size at end of life. + // @tfield[opt=Color(255, 255, 255)] Color startColor Color at start of life. + // @tfield[opt=Color(255, 255, 255)] Color endColor Color at end of life. Note that this will finish long before the end of life due to internal math. + // @tfield[opt=TEN.Effects.BlendID.ALPHA_BLEND] Effects.BlendID blendMode Render blend mode. + // @tfield[opt=false] bool damage Harm the player on collision. + // @tfield[opt=false] bool poison Poison the player on collision. + // @tfield[opt=false] bool burn Burn the player on collision. + // @tfield[opt=false] bool wind Affect position by wind in outside rooms. + // @tfield[opt=2] int damageHit Player damage amount on collision. + // @tfield[opt=false] bool light Emit a colored light. __Caution__: Recommended only for a single particle. Too many particles with lights can overwhelm the lighting system. + // @tfield[opt=0] int lightRadius Light radius in 1/4 blocks. + // @tfield[opt=0] int lightFlicker Interval at which the light should flicker. + // @tfield[opt] int soundID Sound ID to play. __Caution__: Recommended only for a single particle. Too many particles with sounds can overwhelm the sound system. + // @tfield[opt=false] bool animated Play animates sprite sequence. + // @tfield[opt=TEN.Effects.ParticleAnimationType.LOOP] Effects.ParticleAnimationType animType Animation type of the sprite sequence. + // @tfield[opt=1] float frameRate Sprite sequence animation framerate. + static void EmitAdvancedParticle(const sol::table& table) + { + constexpr auto DEFAULT_START_SIZE = 10.0f; + constexpr auto DEFAULT_LIFE = 2.0f; + + auto convertedSpriteSeqID = table.get_or("spriteSeqID", ID_DEFAULT_SPRITES); + if (!CheckIfSlotExists(convertedSpriteSeqID, "EmitParticle() script function.")) + return; + + auto& part = *GetFreeParticle(); + + part.on = true; + part.SpriteSeqID = convertedSpriteSeqID; + part.SpriteID = table.get_or("spriteID", 0); + + auto bMode = table.get_or("blendMode", BlendMode::AlphaBlend); + part.blendMode = bMode; + + auto pos = (Vec3)table["pos"]; + part.x = pos.x; + part.y = pos.y; + part.z = pos.z; + part.roomNumber = FindRoomNumber(pos.ToVector3i()); + + auto vel = ((Vec3)table["vel"]) / (float)FPS; + part.xVel = short(vel.x * 32); + part.yVel = short(vel.y * 32); + part.zVel = short(vel.z * 32); + + float startRot = table.get_or("startRot", TO_DEGREES(Random::GenerateAngle())); + float rotVel = table.get_or("rotVel", 0.0f) / (float)FPS; + part.rotAng = ANGLE(startRot) >> 4; + part.rotAdd = ANGLE(rotVel) >> 4; + + part.sSize = + part.size = table.get_or("startSize", DEFAULT_START_SIZE); + part.dSize = table.get_or("endSize", 0.0f); + part.scalar = 2; + + part.gravity = (short)(std::clamp(table.get_or("gravity", 0.0f), SHRT_MIN, SHRT_MAX) / (float)FPS); + part.friction = table.get_or("friction", 0.0f) / (float)FPS; + part.maxYvel = table.get_or("maxYVel", 0.0f) / (float)FPS; + + auto convertedStartColor = table.get_or("startColor", ScriptColor(255, 255, 255)); + part.sR = convertedStartColor.GetR(); + part.sG = convertedStartColor.GetG(); + part.sB = convertedStartColor.GetB(); + + auto convertedEndColor = table.get_or("endColor", ScriptColor(255, 255, 255)); + part.dR = convertedEndColor.GetR(); + part.dG = convertedEndColor.GetG(); + part.dB = convertedEndColor.GetB(); + + float convertedLife = std::max(0.1f, (float)table.get_or("life", DEFAULT_LIFE)); + part.life = + part.sLife = (int)round(convertedLife / (1.0f / (float)FPS)); + part.colFadeSpeed = part.life / 2; + part.fadeToBlack = part.life / 3; + + part.flags = SP_SCALE | SP_ROTATE | SP_DEF | SP_EXPDEF; + + part.damage = table.get_or("damageHit", 2); + + bool convertedApplyPoison = table.get_or("poison", false); + if (convertedApplyPoison) + part.flags |= SP_POISON; + + bool convertedApplyDamage = table.get_or("damage", false); + if (convertedApplyDamage) + part.flags |= SP_DAMAGE; + + bool convertedApplyBurn = table.get_or("burn", false); + if (convertedApplyBurn) + part.flags |= SP_FIRE; + + int convertedSoundID = table.get_or("soundID", NO_VALUE); + if (convertedSoundID != NO_VALUE) + { + part.flags |= SP_SOUND; + part.sound = convertedSoundID; + } + bool convertedApplyLight = table.get_or("light", false); + if (convertedApplyLight) + { + part.flags |= SP_LIGHT; + int lightRadius = table.get_or("lightRadius", 0); + part.lightRadius = lightRadius * BLOCK(0.25f); + int flicker = table.get_or("lightFlicker", 0); + + if (flicker > 0) + { + part.lightFlicker = table.get_or("lightFlicker", 0); + part.lightFlickerS = table.get_or("lightFlicker", 0); + } + } + bool animatedSpr = table.get_or("animated", false); + if (animatedSpr) + { + auto applyAnim = (ParticleAnimType)table.get_or("animType", ParticleAnimType::Loop); + float applyFramerate = table.get_or("frameRate", 1.0f); + part.flags |= SP_ANIMATED; + part.framerate = applyFramerate; + part.animationType = ParticleAnimType(std::clamp(int(applyAnim), int(ParticleAnimType::None), int(ParticleAnimType::LifetimeSpread))); + + } + + bool convertedApplyWind = table.get_or("wind", false); + if (convertedApplyWind) + { + if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WIND, part.roomNumber)) + part.flags |= SP_WIND; + } + } -/***Emit a shockwave, similar to that seen when a harpy projectile hits something. - @function EmitShockwave - @tparam Vec3 pos Origin position - @tparam int innerRadius (default 0) Initial inner radius of the shockwave circle - 128 will be approx a click, 512 approx a block - @tparam int outerRadius (default 128) Initial outer radius of the shockwave circle - @tparam Color color (default Color(255, 255, 255)) - @tparam float lifetime (default 1.0) Lifetime in seconds (max 8.5 because of inner maths weirdness) - @tparam int speed (default 50) Initial speed of the shockwave's expansion (the shockwave will always slow as it goes) - @tparam int angle (default 0) Angle about the X axis - a value of 90 will cause the shockwave to be entirely vertical - @tparam bool hurtsLara (default false) If true, the shockwave will hurt Lara, with the damage being relative to the shockwave's current speed -*/ + /// Emit a shockwave, similar to that seen when a harpy projectile hits something. + // @function EmitShockwave + // @tparam Vec3 pos Origin Position. + // @tparam[opt=0] int innerRadius Initial inner radius of the shockwave circle - 128 will be approx a click, 512 approx a block. + // @tparam[opt=128] int outerRadius Initial outer radius of the shockwave circle. + // @tparam[opt=Color(255, 255, 255)] Color color Color. + // @tparam[opt=1.0] float lifetime Lifetime in seconds (max 8.5 because of inner maths weirdness). + // @tparam[opt=50] int speed Initial speed of the shockwave's expansion (the shockwave will always slow as it goes). + // @tparam[opt=0] int angle Angle about the X axis - a value of 90 will cause the shockwave to be entirely vertical. + // @tparam[opt=false] bool hurtsLara If true, the shockwave will hurt Lara, with the damage being relative to the shockwave's current speed. static void EmitShockwave(Vec3 pos, TypeOrNil innerRadius, TypeOrNil outerRadius, TypeOrNil col, TypeOrNil lifetime, TypeOrNil speed, TypeOrNil angle, TypeOrNil hurtPlayer) { @@ -252,15 +440,14 @@ namespace TEN::Scripting::Effects (short)doDamage, true, false, false, (int)ShockwaveStyle::Normal); } -/***Emit dynamic light that lasts for a single frame. - * If you want a light that sticks around, you must call this each frame. -@function EmitLight -@tparam Vec3 pos position of the light -@tparam[opt] Color color light color (default Color(255, 255, 255)) -@tparam[opt] int radius measured in "clicks" or 256 world units (default 20) -@tparam[opt] bool shadows determines whether light should generate dynamic shadows for applicable moveables (default is false) -@tparam[opt] string name if provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights) -*/ + /// Emit dynamic light that lasts for a single frame. + // If you want a light that sticks around, you must call this each frame. + // @function EmitLight + // @tparam Vec3 pos position of the light + // @tparam[opt=Color(255, 255, 255)] Color color light color. + // @tparam[opt=20] int radius Measured in "clicks" or 256 world units. + // @tparam[opt=false] bool shadows Determines whether light should generate dynamic shadows for applicable moveables. + // @tparam[opt] string name If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). static void EmitLight(Vec3 pos, TypeOrNil col, TypeOrNil radius, TypeOrNil castShadows, TypeOrNil name) { auto color = ValueOr(col, ScriptColor(255, 255, 255)); @@ -268,18 +455,17 @@ namespace TEN::Scripting::Effects SpawnDynamicPointLight(pos.ToVector3(), color, rad, ValueOr(castShadows, false), GetHash(ValueOr(name, std::string()))); } -/***Emit dynamic directional spotlight that lasts for a single frame. -* If you want a light that sticks around, you must call this each frame. -@function EmitSpotLight -@tparam Vec3 pos position of the light -@tparam Vec3 dir normal which indicates light direction -@tparam[opt] Color color (default Color(255, 255, 255)) -@tparam[opt] int radius overall radius at the endpoint of a light cone, measured in "clicks" or 256 world units (default 10) -@tparam[opt] int falloff radius, at which light starts to fade out, measured in "clicks" (default 5) -@tparam[opt] int distance distance, at which light cone fades out, measured in "clicks" (default 20) -@tparam[opt] bool shadows determines whether light should generate dynamic shadows for applicable moveables (default is false) -@tparam[opt] string name if provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights) -*/ + /// Emit dynamic directional spotlight that lasts for a single frame. + // If you want a light that sticks around, you must call this each frame. + // @function EmitSpotLight + // @tparam Vec3 pos position of the light + // @tparam Vec3 dir normal which indicates light direction + // @tparam[opt=Color(255, 255, 255)] Color color Color. + // @tparam[opt=10] int radius Overall radius at the endpoint of a light cone, measured in "clicks" or 256 world units. + // @tparam[opt=5] int falloff Radius, at which light starts to fade out, measured in "clicks". + // @tparam[opt=20] int distance Distance, at which light cone fades out, measured in "clicks". + // @tparam[opt=false] bool shadows Determines whether light should generate dynamic shadows for applicable moveables. + // @tparam[opt] string name If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). static void EmitSpotLight(Vec3 pos, Vec3 dir, TypeOrNil col, TypeOrNil radius, TypeOrNil falloff, TypeOrNil distance, TypeOrNil castShadows, TypeOrNil name) { auto color = ValueOr(col, ScriptColor(255, 255, 255)); @@ -289,21 +475,20 @@ namespace TEN::Scripting::Effects SpawnDynamicSpotLight(pos.ToVector3(), dir.ToVector3(), color, rad, fallOff, dist, ValueOr(castShadows, false), GetHash(ValueOr(name, std::string()))); } -/***Emit blood. -@function EmitBlood -@tparam Vec3 pos -@tparam int count (default 1) amount of blood. -*/ + /// Emit blood. + // @function EmitBlood + // @tparam Vec3 pos + // @tparam[opt=1] int count Sprite count. static void EmitBlood(const Vec3& pos, TypeOrNil count) { TriggerBlood(pos.x, pos.y, pos.z, -1, ValueOr(count, 1)); } - /// Emit air bubble in a water room. + /// Emit an air bubble in a water room. // @function EmitAirBubble // @tparam Vec3 pos World position where the effect will be spawned. Must be in a water room. - // @tparam[opt] float size Sprite size. __Default: 32__ - // @tparam[opt] float amp Oscillation amplitude. __Default: 32__ + // @tparam[opt=32] float size Sprite size. + // @tparam[opt=32] float amp Oscillation amplitude. static void EmitAirBubble(const Vec3& pos, TypeOrNil size, TypeOrNil amp) { constexpr auto DEFAULT_SIZE = 128.0f; @@ -315,31 +500,28 @@ namespace TEN::Scripting::Effects SpawnBubble(pos.ToVector3(), roomNumber, convertedSize, convertedAmp); } -/***Emit fire for one frame. Will not hurt player. Call this each frame if you want a continuous fire. -@function EmitFire -@tparam Vec3 pos -@tparam float size (default 1.0) -*/ + /// Emit fire for one frame. Will not hurt player. Call this each frame if you want a continuous fire. + // @function EmitFire + // @tparam Vec3 pos Position. + // @tparam[opt=1] float size Fire size. static void EmitFire(const Vec3& pos, TypeOrNil size) { - AddFire(pos.x, pos.y, pos.z, FindRoomNumber(Vector3i(pos.x, pos.y, pos.z)), ValueOr(size, 1)); + AddFire(pos.x, pos.y, pos.z, FindRoomNumber(pos.ToVector3i()), ValueOr(size, 1)); } -/***Make an explosion. Does not har, player -@function MakeExplosion -@tparam Vec3 pos -@tparam float size (default 512.0) this will not be the size of the sprites, but rather the distance between the origin and any additional sprites -@tparam bool shockwave (default false) if true, create a very faint white shockwave which will not harm player -*/ + /// Make an explosion. Does not hurt Lara + // @function MakeExplosion + // @tparam Vec3 pos + // @tparam[opt=512] float size This will not be the size of the sprites, but rather the distance between the origin and any additional sprites. + // @tparam[opt=false] bool shockwave If true, create a very faint white shockwave which will not hurt Lara. static void MakeExplosion(Vec3 pos, TypeOrNil size, TypeOrNil shockwave) { TriggerExplosion(Vector3(pos.x, pos.y, pos.z), ValueOr(size, 512.0f), true, false, ValueOr(shockwave, false), FindRoomNumber(Vector3i(pos.x, pos.y, pos.z))); } -/***Make an earthquake -@function MakeEarthquake -@tparam int strength (default 100) How strong should the earthquake be? Increasing this value also increases the lifespan of the earthquake. -*/ + /// Make an earthquake + // @function MakeEarthquake + // @tparam[opt=100] int strength How strong should the earthquake be? Increasing this value also increases the lifespan of the earthquake. static void Earthquake(TypeOrNil strength) { int str = ValueOr(strength, 100); @@ -355,25 +537,78 @@ namespace TEN::Scripting::Effects return Vec3(Weather.Wind()); } + /// Emit an extending streamer effect. + // @function EmitStreamer + // @tparam Moveable mov Moveable object with which to associate the effect. + // @tparam int tag Numeric tag with which to associate the effect on the moveable. + // @tparam Vec3 pos World position. + // @tparam Vec3 dir Direction vector of movement velocity. + // @tparam[opt=0] float rot Start rotation in degrees. + // @tparam[opt=Color(255, 255, 255)] Color startColor Color at the start of life. + // @tparam[opt=Color(0, 0, 0)] Color endColor Color at the end of life. + // @tparam[opt=0] float width Width in world units. + // @tparam[opt=1] float life Lifetime in seconds. + // @tparam[opt=0] float vel Movement velocity in world units per second. + // @tparam[opt=0] float expRate Width expansion rate in world units per second. + // @tparam[opt=0] float rotRate Rotation rate in degrees per second. + // @tparam[opt=Effects.StreamerFeatherMode.NONE] Effects.StreamerFeatherMode edgeFeatherMode Edge feather mode. + // @tparam[opt=Effects.StreamerFeatherMode.LEFT] Effects.StreamerFeatherMode lengthFeatherMode Length feather mode. _Not yet implemented._ + // @tparam[opt=Effects.BlendID.ALPHA_BLEND] Effects.BlendID blendID Renderer blend ID. + static void EmitStreamer(const Moveable& mov, TypeOrNil tag, const Vec3& pos, const Vec3& dir, TypeOrNil rot, TypeOrNil startColor, TypeOrNil endColor, + TypeOrNil width, TypeOrNil life, TypeOrNil vel, TypeOrNil expRate, TypeOrNil rotRate, + TypeOrNil edgeFeatherMode, TypeOrNil lengthFeatherMode, TypeOrNil blendID) + { + int movID = mov.GetIndex(); + int convertedTag = ValueOr(tag, 0); + auto convertedPos = pos.ToVector3(); + auto convertedDir = dir.ToVector3(); + auto convertedRot = ANGLE(ValueOr(rot, 0)); + auto convertedStartColor = ValueOr(startColor, ScriptColor(255, 255, 255, 255)); + auto convertedEndColor = ValueOr(endColor, ScriptColor(0, 0, 0, 0)); + + auto convertedWidth = ValueOr(width, 0.0f); + auto convertedLife = ValueOr(life, 1.0f); + auto convertedVel = ValueOr(vel, 0.0f) / (float)FPS; + auto convertedExpRate = ValueOr(expRate, 0.0f) / (float)FPS; + auto convertedRotRate = ANGLE(ValueOr(rotRate, 0.0f) / (float)FPS); + + auto convertedEdgeFeatherID = ValueOr(edgeFeatherMode, StreamerFeatherMode::None); + auto convertedLengthFeatherID = ValueOr(lengthFeatherMode, StreamerFeatherMode::Left); + auto convertedBlendID = ValueOr(blendID, BlendMode::AlphaBlend); + + StreamerEffect.Spawn( + movID, convertedTag, convertedPos, convertedDir, convertedRot, convertedStartColor, convertedEndColor, + convertedWidth, convertedLife, convertedVel, convertedExpRate, convertedRotRate, + convertedEdgeFeatherID, /*convertedLengthFeatherID, */convertedBlendID); + } + void Register(sol::state* state, sol::table& parent) { auto tableEffects = sol::table(state->lua_state(), sol::create); parent.set(ScriptReserved_Effects, tableEffects); + // Emitters tableEffects.set_function(ScriptReserved_EmitLightningArc, &EmitLightningArc); tableEffects.set_function(ScriptReserved_EmitParticle, &EmitParticle); + tableEffects.set_function(ScriptReserved_EmitAdvancedParticle, &EmitAdvancedParticle); tableEffects.set_function(ScriptReserved_EmitShockwave, &EmitShockwave); tableEffects.set_function(ScriptReserved_EmitLight, &EmitLight); tableEffects.set_function(ScriptReserved_EmitSpotLight, &EmitSpotLight); tableEffects.set_function(ScriptReserved_EmitBlood, &EmitBlood); tableEffects.set_function(ScriptReserved_EmitAirBubble, &EmitAirBubble); - tableEffects.set_function(ScriptReserved_MakeExplosion, &MakeExplosion); + tableEffects.set_function(ScriptReserved_EmitStreamer, &EmitStreamer); tableEffects.set_function(ScriptReserved_EmitFire, &EmitFire); + + tableEffects.set_function(ScriptReserved_MakeExplosion, &MakeExplosion); tableEffects.set_function(ScriptReserved_MakeEarthquake, &Earthquake); tableEffects.set_function(ScriptReserved_GetWind, &GetWind); - auto handler = LuaHandler{ state }; + auto handler = LuaHandler(state); handler.MakeReadOnlyTable(tableEffects, ScriptReserved_BlendID, BLEND_IDS); handler.MakeReadOnlyTable(tableEffects, ScriptReserved_EffectID, EFFECT_IDS); + handler.MakeReadOnlyTable(tableEffects, ScriptReserved_FeatherMode, FEATHER_MODES); + handler.MakeReadOnlyTable(tableEffects, ScriptReserved_ParticleAnimationType, PARTICLE_ANIM_TYPES); } } + + diff --git a/TombEngine/Scripting/Internal/TEN/Effects/FeatherModes.h b/TombEngine/Scripting/Internal/TEN/Effects/FeatherModes.h new file mode 100644 index 000000000..7c83d80b3 --- /dev/null +++ b/TombEngine/Scripting/Internal/TEN/Effects/FeatherModes.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Game/effects/Streamer.h" + +/// Constants for feather modes. +// @enum Effects.StreamerFeatherMode +// @pragma nostrip + +/// Table of Effects.StreamerFeatherMode constants. +// To be used with @{Effects.EmitStreamer} function. +// +// - `NONE` +// - `CENTER` +// - `LEFT` +// - `RIGHT` +// +// @table Effects.StreamerFeatherMode + +using namespace TEN::Effects::Streamer; + +namespace TEN::Scripting::Effects +{ + static const auto FEATHER_MODES = std::unordered_map + { + { "NONE", StreamerFeatherMode::None }, + { "CENTER", StreamerFeatherMode::Center }, + { "LEFT", StreamerFeatherMode::Left }, + { "RIGHT",StreamerFeatherMode::Right} + }; +} diff --git a/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h b/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h new file mode 100644 index 000000000..1adae829e --- /dev/null +++ b/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h @@ -0,0 +1,27 @@ +#pragma once + +#include "Game/effects/effects.h" + +namespace TEN::Scripting::Effects +{ + /// Constants for particle animation type constants. To be used with @{Effects.EmitAdvancedParticle} function. + // @enum Effects.ParticleAnimationType + // @pragma nostrip + + /// Table of Effects.ParticleAnimationType type constants. To be used with particles. + // + // - `LOOP` - Frames loop sequentially. + // - `ONE_SHOT` - Frames play once and freeze on the last frame. + // - `BACK_AND_FORTH` - Frames bounce back and forth. + // - `LIFE_TIME_SPREAD` - Frames are distributed over the particle's lifetime + // + // @table Effects.ParticleAnimationType + + static const auto PARTICLE_ANIM_TYPES = std::unordered_map + { + { "LOOP", ParticleAnimType::Loop }, + { "ONE_SHOT", ParticleAnimType::OneShot }, + { "BACK_AND_FORTH", ParticleAnimType::BackAndForth }, + { "LIFE_TIME_SPREAD", ParticleAnimType::LifetimeSpread } // TODO: Rename to LIFETIME_SPREAD. + }; +} diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h b/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h index e30361d5a..afb16ba0a 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h @@ -14,14 +14,14 @@ namespace TEN::Scripting // // The following constants are inside Flow.ErrorMode:
                                                      // - // - `TERMINATE` - print to the log file and return to the title level when any script error is hit. - // This is the one you will want to go for if you want to know IMMEDIATELY if something has gone wrong. + // - `TERMINATE` - Print to the log file and return to the title level when any script error is hit. + // This is the one you will want to go for if you want to know _immediately_ if something has gone wrong. // - // - `WARN` - print to the log file and continue running the application when a recoverable script error is hit. + // - `WARN` - Print to the log file and continue running the application when a recoverable script error is hit. // Choose this one if booting to the title level is too much for you. // - // - `SILENT` - do nothing when a recoverable script error is hit. - // Think __very__ carefully before using this setting. These error modes are here to help you to keep your scripts + // - `SILENT` - Do nothing when a recoverable script error is hit. + // Think _very_ carefully before using this setting. These error modes are here to help you to keep your scripts // working properly, but if you opt to ignore errors, you won't be alerted if you've misused a function or passed // an invalid argument. // diff --git a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp index 90369bdc6..bbdc1a579 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp @@ -56,47 +56,50 @@ ambient tracks. /*** Add a level to the Flow. @function AddLevel -@tparam Flow.Level level a level object +@tparam Flow.Level level A level object. */ tableFlow.set_function(ScriptReserved_AddLevel, &FlowHandler::AddLevel, this); -/*** Image to show when loading the game. -Must be a .jpg or .png image. +/*** Image to show when loading the game. Must be a .jpg or .png image. @function SetIntroImagePath -@tparam string path the path to the image, relative to the TombEngine exe +@tparam string path The path to the image, relative to the TombEngine executable. */ tableFlow.set_function(ScriptReserved_SetIntroImagePath, &FlowHandler::SetIntroImagePath, this); -/*** Image to show in the background of the title screen. -Must be a .jpg or .png image. -__(not yet implemented)__ +/*** Video to show when loading the game. Must be a common video format, such as mp4, mkv, mov or avi. +@function SetIntroVideoPath +@tparam string path the path to the video, relative to the TombEngine exe +*/ + tableFlow.set_function(ScriptReserved_SetIntroVideoPath, &FlowHandler::SetIntroVideoPath, this); + +/*** Image to show in the background of the title screen. Must be a .jpg or .png image. _Not yet implemented._ @function SetTitleScreenImagePath -@tparam string path the path to the image, relative to the TombEngine exe +@tparam string path The path to the image, relative to the TombEngine executable. */ tableFlow.set_function(ScriptReserved_SetTitleScreenImagePath, &FlowHandler::SetTitleScreenImagePath, this); /*** Enable or disable Lara drawing in title flyby. Must be true or false @function EnableLaraInTitle -@tparam bool enabled true or false +@tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableLaraInTitle, &FlowHandler::EnableLaraInTitle, this); /*** Enable or disable level selection in title flyby. Must be true or false @function EnableLevelSelect -@tparam bool enabled true or false +@tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableLevelSelect, &FlowHandler::EnableLevelSelect, this); /*** Enable or disable Home Level entry in the main menu. -@function EnableHomeLevel() +@function EnableHomeLevel @tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableHomeLevel, &FlowHandler::EnableHomeLevel, this); /*** Enable or disable saving and loading of savegames. -@function EnableLoadSave() +@function EnableLoadSave @tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableLoadSave, &FlowHandler::EnableLoadSave, this); @@ -106,7 +109,7 @@ Must be true or false */ /*** Enable or disable the fly cheat. -@function EnableFlyCheat() +@function EnableFlyCheat @tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableFlyCheat, &FlowHandler::EnableFlyCheat, this); @@ -114,29 +117,29 @@ Must be true or false /*** Enable or disable point texture filter. Must be true or false @function EnablePointFilter -@tparam bool enabled true or false +@tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnablePointFilter, &FlowHandler::EnablePointFilter, this); /*** Enable or disable mass pickup. Must be true or false @function EnableMassPickup -@tparam bool enabled true or false +@tparam bool enabled True or false. */ tableFlow.set_function(ScriptReserved_EnableMassPickup, &FlowHandler::EnableMassPickup, this); /*** Returns the level by index. Indices depend on the order in which AddLevel was called; the first added will -have an ID of 0, the second an ID of 1, and so on. +have an index of 0, the second an index of 1, and so on. @function GetLevel -@tparam int index of the level -@treturn Flow.Level the level indicated by the id +@tparam int index Index of the level. +@treturn Flow.Level The level indicated by the index. */ tableFlow.set_function(ScriptReserved_GetLevel, &FlowHandler::GetLevel, this); /*** Returns the level that the game control is running in that moment. @function GetCurrentLevel -@treturn Flow.Level the current level +@treturn Flow.Level The current level. */ tableFlow.set_function(ScriptReserved_GetCurrentLevel, &FlowHandler::GetCurrentLevel, this); @@ -145,38 +148,38 @@ If level index is not provided or is zero, jumps to next level. If level index i level count, jumps to title. If LARA\_START\_POS objects are present in level, player will be teleported to such object with OCB similar to provided second argument. @function EndLevel -@int[opt] index level index (default 0) -@int[opt] startPos player start position (default 0) +@int[opt=0] index Level index. +@int[opt=0] startPos Player start position in the next level. Should correspond to OCB of `Objects.ObjID.LARA_START_POS` object in the next level. */ tableFlow.set_function(ScriptReserved_EndLevel, &FlowHandler::EndLevel, this); /*** Get game or level statistics. For reference about statistics class, see @{Flow.Statistics}. @function GetStatistics -@tparam bool game if true, returns overall game statistics, otherwise returns current level statistics (default: false) -@treturn Flow.Statistics statistics structure representing game or level statistics +@tparam[opt=false] bool game If true, returns overall game statistics, otherwise returns current level statistics. +@treturn Flow.Statistics Statistics structure representing game or level statistics. */ tableFlow.set_function(ScriptReserved_GetStatistics, &FlowHandler::GetStatistics, this); /*** Set game or level statistics. For reference about statistics class, see @{Flow.Statistics}. @function SetStatistics -@tparam Flow.Statistics statistics statistic object to set -@tparam bool game if true, sets overall game statistics, otherwise sets current level statistics (default: false) +@tparam Flow.Statistics statistics Statistic object to set. +@tparam[opt=false] bool game If true, sets overall game statistics, otherwise sets current level statistics. */ tableFlow.set_function(ScriptReserved_SetStatistics, &FlowHandler::SetStatistics, this); /*** Get current game status, such as normal game loop, exiting to title, etc. @function GetGameStatus -@treturn Flow.GameStatus the current game status +@treturn Flow.GameStatus The current game status. */ tableFlow.set_function(ScriptReserved_GetGameStatus, &FlowHandler::GetGameStatus, this); /*** Get current freeze mode, such as none, full, spectator or player. @function GetFreezeMode -@treturn Flow.FreezeMode the current freeze mode +@treturn Flow.FreezeMode The current freeze mode. */ tableFlow.set_function(ScriptReserved_GetFreezeMode, &FlowHandler::GetFreezeMode, this); @@ -185,7 +188,7 @@ Set current freeze mode, such as none, full, spectator or player. Freeze mode specifies whether game is in normal mode or paused in a particular way to allow custom menu creation, photo mode or time freeze. @function SetFreezeMode -@tparam Flow.FreezeMode freezeMode new freeze mode to set. +@tparam Flow.FreezeMode freezeMode New freeze mode to set. */ tableFlow.set_function(ScriptReserved_SetFreezeMode, &FlowHandler::SetFreezeMode, this); @@ -228,7 +231,7 @@ Returns the player's current per-game secret count. /*** Sets the player's current per-game secret count. @function SetSecretCount -@tparam int count new secret count. +@tparam int count New secret count. */ tableFlow.set_function(ScriptReserved_SetSecretCount, &FlowHandler::SetSecretCount, this); @@ -236,20 +239,26 @@ Sets the player's current per-game secret count. Adds one secret to current level secret count and also plays secret music track. The index argument corresponds to the secret's unique ID, the same that would go in a secret trigger's Param. @function AddSecret -@tparam int index an index of current level's secret (must be from 0 to 31). +@tparam int index An index of current level's secret (must be from 0 to 31). */ tableFlow.set_function(ScriptReserved_AddSecret, &FlowHandler::AddSecret, this); -/*** Total number of secrets in game. +/*** Get total number of secrets in the game. +@function GetTotalSecretCount +@treturn int Total number of secrets in the game. +*/ + tableFlow.set_function(ScriptReserved_GetTotalSecretCount, &FlowHandler::GetTotalSecretCount, this); + +/*** Set total number of secrets in the game. Must be an integer value (0 means no secrets). @function SetTotalSecretCount -@tparam int total number of secrets +@tparam int count Total number of secrets in the game. */ tableFlow.set_function(ScriptReserved_SetTotalSecretCount, &FlowHandler::SetTotalSecretCount, this); /*** Do FlipMap with specific group ID. @function FlipMap -@tparam int flipmap (ID of flipmap group to actuvate / deactivate) +@tparam int flipmap ID of flipmap group to actuvate / deactivate. */ tableFlow.set_function(ScriptReserved_FlipMap, &FlowHandler::FlipMap, this); @@ -264,45 +273,46 @@ Must be an integer value (0 means no secrets). These functions are called in settings.lua, a file which holds global settings, such as system settings, flare color or animation movesets. @section settingslua */ + /*** Set provided settings table to an engine. @function SetSettings -@tparam Flow.Settings settings a settings table +@tparam Flow.Settings settings A settings table. */ tableFlow.set_function(ScriptReserved_SetSettings, &FlowHandler::SetSettings, this); + /*** Get settings table from an engine. @function GetSettings -@treturn Flow.Settings current settings table +@treturn Flow.Settings Current settings table. */ tableFlow.set_function(ScriptReserved_GetSettings, &FlowHandler::GetSettings, this); /*** strings.lua. -These functions used in strings.lua, which is generated by TombIDE. -You will not need to call them manually. +These functions used in strings.lua, which is generated by TombIDE. You will not need to call them manually. @section stringslua */ /*** Set string variable keys and their translations. @function SetStrings -@tparam tab table array-style table with strings +@tparam table table Array-style table with strings. */ tableFlow.set_function(ScriptReserved_SetStrings, &FlowHandler::SetStrings, this); /*** Get translated string. @function GetString -@tparam key string key for translated string +@tparam string key Key for translated string. */ tableFlow.set_function(ScriptReserved_GetString, &FlowHandler::GetString, this); /*** Check if translated string is present. @function IsStringPresent -@tparam key string key for translated string +@tparam string key Key for translated string. */ tableFlow.set_function(ScriptReserved_IsStringPresent, &FlowHandler::IsStringPresent, this); /*** Set language names for translations. Specify which translations in the strings table correspond to which languages. @function SetLanguageNames -@tparam tab table array-style table with language names +@tparam table table Array-style table with language names. */ tableFlow.set_function(ScriptReserved_SetLanguageNames, &FlowHandler::SetLanguageNames, this); @@ -317,6 +327,7 @@ Specify which translations in the strings table correspond to which languages. InventoryItem::Register(tableFlow); Settings::Register(tableFlow); Fog::Register(tableFlow); + Horizon::Register(tableFlow); LensFlare::Register(tableFlow); Starfield::Register(tableFlow); @@ -400,11 +411,22 @@ void FlowHandler::SetIntroImagePath(const std::string& path) IntroImagePath = path; } +void FlowHandler::SetIntroVideoPath(const std::string& path) +{ + IntroVideoPath = path; +} + void FlowHandler::SetTitleScreenImagePath(const std::string& path) { TitleScreenImagePath = path; } + +int FlowHandler::GetTotalSecretCount() +{ + return TotalNumberOfSecrets; +} + void FlowHandler::SetTotalSecretCount(int secretsNumber) { TotalNumberOfSecrets = secretsNumber; @@ -414,6 +436,8 @@ void FlowHandler::LoadFlowScript() { TENLog("Loading gameflow script, strings, and settings...", LogLevel::Info); + Levels.clear(); + _handler.ExecuteScript(_gameDir + "Scripts/Gameflow.lua"); _handler.ExecuteScript(_gameDir + "Scripts/SystemStrings.lua", true); _handler.ExecuteScript(_gameDir + "Scripts/Strings.lua", true); diff --git a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h index 17b496bfe..6d826f769 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h @@ -27,9 +27,6 @@ private: void PrepareInventoryObjects(); public: - int FogInDistance = 0; - int FogOutDistance = 0; - bool LevelSelect = true; bool HomeLevel = false; bool LoadSave = true; @@ -72,7 +69,9 @@ public: void SetSecretCount(int secretsNum); void AddSecret(int levelSecretIndex); void SetIntroImagePath(const std::string& path); + void SetIntroVideoPath(const std::string& path); void SetTitleScreenImagePath(const std::string& path); + int GetTotalSecretCount(); void SetTotalSecretCount(int secretsNumber); bool IsFlyCheatEnabled() const; void EnableFlyCheat(bool enable); diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp index 7cb1b424e..932db5bd2 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp @@ -6,7 +6,7 @@ using namespace TEN::Scripting::Types; /*** -Distance fog. +Represesnts distance fog. To be used with @{Flow.Level.fog} property. @tenprimitive Flow.Fog @pragma nostrip @@ -19,17 +19,17 @@ void Fog::Register(sol::table& parent) ctors(), sol::call_constructor, ctors(), - /// (@{Color}) RGB fog color + /// (@{Color}) RGB fog color. // @mem color "color", sol::property(&Fog::GetColor, &Fog::SetColor), - /// (int) min distance. - // This is the distance at which the fog starts. - // @mem minDistance* + /// (float) Minimum distance. + // This is the distance at which the fog starts (in sectors). + // @mem minDistance "minDistance", &Fog::MinDistance, - /// (int) max distance. - // This is the distance at which the fog reaches the maximum strength. + /// (float) Maximum distance. + // This is the distance at which the fog reaches the maximum strength (in sectors). // @mem maxDistance "maxDistance", &Fog::MaxDistance ); @@ -37,17 +37,16 @@ void Fog::Register(sol::table& parent) /*** @tparam Color color RGB color -@tparam int Min Distance fog starts (in Sectors) -@tparam int Max Distance fog ends (in Sectors) +@tparam int min Distance at which fog starts (in sectors). +@tparam int max Distance at which fog reaches the maximum strength (in sectors). @treturn Fog A fog object. @function Fog */ -Fog::Fog(ScriptColor const& col, short minDistance, short maxDistance) +Fog::Fog(ScriptColor const& col, float minDistance, float maxDistance) { SetColor(col); MinDistance = minDistance; MaxDistance = maxDistance; - Enabled = true; } void Fog::SetColor(ScriptColor const& col) diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h index e24dc3577..dc21d7c97 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h @@ -10,15 +10,14 @@ using namespace TEN::Scripting::Types; struct Fog { - bool Enabled{ false }; byte R{ 0 }; byte G{ 0 }; byte B{ 0 }; - short MinDistance{ 0 }; - short MaxDistance{ 0 }; + float MinDistance{ 0 }; + float MaxDistance{ 0 }; Fog() = default; - Fog(ScriptColor const& color, short minDistance, short maxDistance); + Fog(ScriptColor const& color, float minDistance, float maxDistance); void SetColor(ScriptColor const& color); ScriptColor GetColor() const; diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp new file mode 100644 index 000000000..ca27087c6 --- /dev/null +++ b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp @@ -0,0 +1,130 @@ +#include "framework.h" +#include "Scripting/Internal/TEN/Flow/Horizon/Horizon.h" + +#include "Objects/game_object_ids.h" +#include "Scripting/Internal/ReservedScriptNames.h" +#include "Scripting/Internal/ScriptUtil.h" +#include "Scripting/Internal/TEN/Types/Color/Color.h" +#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h" + +namespace TEN::Scripting +{ + /// Represents a horizon. To be used with @{Flow.Level.horizon1} and @{Flow.Level.horizon2} properties. + // + // @tenprimitive Flow.Horizon + // @pragma nostrip + + void Horizon::Register(sol::table& parent) + { + using ctors = sol::constructors< + Horizon(GAME_OBJECT_ID), + Horizon(bool)>; + + // Register type. + parent.new_usertype( + "Horizon", + ctors(), sol::call_constructor, ctors(), + + /// (bool) Horizon enabled state. + // If set to true, horizon will be visible. + // @mem enabled + "enabled", sol::property(&Horizon::GetEnabled, &Horizon::SetEnabled), + + /// (@{Objects.ObjID}) Horizon object ID. + // @mem objectID + "objectID", sol::property(&Horizon::GetObjectID, &Horizon::SetObjectID), + + /// (@{Vec3}) Horizon position. + // Specifies an offset from the camera origin. + // @mem position + "position", sol::property(&Horizon::GetPosition, &Horizon::SetPosition), + + /// (@{Rotation}) Horizon rotation. + // Specifies horizon rotation. + // @mem rotation + "rotation", sol::property(&Horizon::GetRotation, &Horizon::SetRotation), + + /// (float) Horizon transparency. + // Specifies horizon transparency on a range from 0 to 1. + // @mem transparency + "transparency", sol::property(&Horizon::GetTransparency, &Horizon::SetTransparency)); + } + + /// Create a horizon object. + // @function Horizon + // @tparam Objects.ObjID objectID Object ID for the horizon to use. + // @treturn Horizon A new Horizon object. + Horizon::Horizon(GAME_OBJECT_ID objectID) + { + _enabled = true; + _objectID = objectID; + } + + // Legacy constructor to maintain backwards compatibility. + Horizon::Horizon(bool enabled) + { + _enabled = enabled; + } + + bool Horizon::GetEnabled() const + { + return _enabled; + } + + GAME_OBJECT_ID Horizon::GetObjectID() const + { + return _objectID; + } + + const Vec3 Horizon::GetPosition() const + { + return _position; + } + + const Rotation Horizon::GetRotation() const + { + return _rotation; + } + + const float Horizon::GetTransparency() const + { + return _transparency; + } + + void Horizon::SetEnabled(bool value) + { + _enabled = value; + } + + void Horizon::SetObjectID(GAME_OBJECT_ID objectID) + { + _objectID = objectID; + } + + void Horizon::SetPosition(const Vec3& pos, TypeOrNil noInterpolation) + { + _prevPosition = ValueOr(noInterpolation, false) ? pos : _position; + _position = pos; + } + + void Horizon::SetRotation(const Rotation& rot, TypeOrNil noInterpolation) + { + _prevRotation = ValueOr(noInterpolation, false) ? rot : _rotation; + _rotation = rot; + } + + void Horizon::SetTransparency(float value) + { + _transparency = value; + } + + const Vec3 Horizon::GetPrevPosition() const + { + return _prevPosition; + } + + const Rotation Horizon::GetPrevRotation() const + { + return _prevRotation; + } +} diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.h b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.h new file mode 100644 index 000000000..02b1a5a69 --- /dev/null +++ b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.h @@ -0,0 +1,55 @@ +#pragma once + +#include "Objects/game_object_ids.h" +#include "Scripting/Internal/ScriptUtil.h" +#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h" +#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h" + +namespace TEN::Scripting +{ + class Horizon + { + public: + static void Register(sol::table& parent); + + private: + // Fields + + bool _enabled = false; + GAME_OBJECT_ID _objectID = GAME_OBJECT_ID::ID_HORIZON; + Vec3 _position = {}; + Rotation _rotation = {}; + float _scale = 1.0f; + float _transparency = 1.0f; + + Vec3 _prevPosition = {}; + Rotation _prevRotation = {}; + float _prevScale = 1.0f; + + public: + // Constructors + + Horizon() = default; + Horizon(bool enabled); + Horizon(GAME_OBJECT_ID objectID); + + // Getters + + bool GetEnabled() const; + GAME_OBJECT_ID GetObjectID() const; + const Vec3 GetPosition() const; + const Rotation GetRotation() const; + const float GetTransparency() const; + + const Vec3 GetPrevPosition() const; + const Rotation GetPrevRotation() const; + + // Setters + + void SetEnabled(bool value); + void SetObjectID(GAME_OBJECT_ID objectID); + void SetPosition(const Vec3& pos, TypeOrNil disableInterpolation); + void SetRotation(const Rotation& orient, TypeOrNil disableInterpolation); + void SetTransparency(float value); + }; +} \ No newline at end of file diff --git a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp index 5037763ca..91b4dcd09 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp @@ -4,24 +4,21 @@ #include "Scripting/Internal/ReservedScriptNames.h" #include "Scripting/Internal/ScriptAssert.h" -/*** -Represents the properties of an object as it appears in the inventory. - +/*** Represents the properties of an object as it appears in the inventory. To be used in @{Flow.Level.objects} list. @tenprimitive Flow.InventoryItem @pragma nostrip */ /*** Create an InventoryItem. @function InventoryItem - @tparam string nameKey key for the item's (localised) name.
                                                      -Corresponds to an entry in strings.lua. + @tparam string nameKey key for the item's (localised) name. Corresponds to an entry in strings.lua. @tparam Objects.ObjID objectID object ID of the inventory object to change @tparam float yOffset y-axis offset (positive values move the item down).
                                                      A value of about 100 will cause the item to display directly below its usual position. @tparam float scale item size (1 being standard size).
                                                      A value of 0.5 will cause the item to render at half the size, and a value of 2 will cause the item to render at twice the size. - @tparam Rotation rot rotation around x, y, and z axes + @tparam Rotation rot rotation around x, y, and z axes. @tparam RotationAxis axis Axis to rotate around when the item is observed at in the inventory.
                                                      Note that this is entirely separate from the `rot` field described above. Must one of the following: @@ -29,7 +26,7 @@ Must one of the following: Y Z e.g. `myItem.rotAxisWhenCurrent = RotationAxis.X` - @tparam int meshBits __Not currently implemented__ (will have no effect regardless of what you set it to) + @tparam int meshBits _Not currently implemented_ (will have no effect regardless of what you set it to). @tparam ItemAction action is this usable, equippable, combineable or examinable?
                                                      Must be one of: EQUIP @@ -37,7 +34,7 @@ Must be one of: COMBINE EXAMINE e.g. `myItem.action = ItemAction.EXAMINE` - @treturn InventoryItem an InventoryItem + @treturn InventoryItem an InventoryItem. */ InventoryItem::InventoryItem(const std::string& name, GAME_OBJECT_ID objectID, float yOffset, float scale, const Rotation& rot, RotationFlags rotFlags, int meshBits, ItemOptions action) : Name(name), diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp index fc777b61e..c46eb7429 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp @@ -8,7 +8,7 @@ using namespace TEN::Scripting::Types; -/// Represents a global lens flare (not to be confused with the lens flare object). +/// Represents a global lens flare (not to be confused with the lens flare object). To be used with @{Flow.Level.lensFlare} property. // // @tenprimitive Flow.LensFlare // @pragma nostrip @@ -25,23 +25,46 @@ namespace TEN::Scripting "LensFlare", ctors(), sol::call_constructor, ctors(), + /// (bool) Lens flare enabled state. + // If set to true, lens flare will be visible. + // @mem enabled + "enabled", sol::property(&LensFlare::GetEnabled, &LensFlare::SetEnabled), + + /// (int) Lens flare's sun sprite ID in DEFAULT_SPRITES sequence. + // @mem spriteID + "spriteID", sol::property(&LensFlare::GetSunSpriteID, &LensFlare::SetSunSpriteID), + + /// (float) Lens flare's pitch (vertical) angle in degrees. + // @mem pitch + "pitch", sol::property(&LensFlare::GetPitch, &LensFlare::SetPitch), + + /// (float) Lens flare's yaw (horizontal) angle in degrees. + // @mem yaw + "yaw", sol::property(&LensFlare::GetYaw, &LensFlare::SetYaw), + + /// (@{Color}) Lens flare's color. + // @mem color + "color", sol::property(&LensFlare::GetColor, &LensFlare::SetColor), + + // Compatibility. "GetSunSpriteID", &LensFlare::GetSunSpriteID, "GetPitch", &LensFlare::GetPitch, "GetYaw", &LensFlare::GetYaw, "GetColor", &LensFlare::GetColor, - "GetEnabled", &LensFlare::GetEnabledStatus, + "GetEnabled", &LensFlare::GetEnabled, "SetSunSpriteID", &LensFlare::SetSunSpriteID, "SetPitch", &LensFlare::SetPitch, "SetYaw", &LensFlare::SetYaw, - "SetColor", &LensFlare::SetColor); + "SetColor", &LensFlare::SetColor, + "SetEnabled", &LensFlare::SetEnabled); } /// Create a LensFlare object. // @function LensFlare - // @tparam float Pitch angle in degrees. - // @tparam float Yaw angle in degrees. - // @tparam Color Color. + // @tparam float pitch Pitch angle in degrees. + // @tparam float yaw Yaw angle in degrees. + // @tparam @{Color} color Color of the lensflare. // @treturn LensFlare A new LensFlare object. LensFlare::LensFlare(float pitch, float yaw, const ScriptColor& color) { @@ -50,48 +73,31 @@ namespace TEN::Scripting _rotation = Rotation(pitch, yaw, 0.0f); } - /// Get this lens flare's sun sprite ID. - // @function LensFlare:GetSunSpriteID - // @treturn int Sprite ID. int LensFlare::GetSunSpriteID() const { return _sunSpriteID; } - /// Get this lens flare's pitch angle in degrees. - // @function LensFlare:GetPitch - // @treturn float Pitch angle in degrees. float LensFlare::GetPitch() const { return _rotation.x; } - /// Get this lens flare's yaw angle in degrees. - // @function LensFlare:GetYaw - // @treturn float Yaw angle in degrees. float LensFlare::GetYaw() const { return _rotation.y; } - /// Get the lens flare's color. - // @function LensFlare:GetColor ScriptColor LensFlare::GetColor() const { return _color; } - /// Get this lens flare's enabled status. - // @function LensFlare:GetEnabled - // @treturn bool Enabled status. __true: enabled__, __false: disabled__ - bool LensFlare::GetEnabledStatus() const + bool LensFlare::GetEnabled() const { return _isEnabled; } - /// Set this lens flare's sun sprite ID. - // @function LensFlare:SetSunSpriteID - // @tparam int New sun sprite ID. void LensFlare::SetSunSpriteID(int spriteID) { // Sprite ID out of range; return early. @@ -104,27 +110,23 @@ namespace TEN::Scripting _sunSpriteID = spriteID; } - /// Set this lens flare's pitch angle. - // @function LensFlare:SetPitch - // @tparam float New pitch angle in degrees. void LensFlare::SetPitch(float pitch) { _rotation.x = pitch; } - /// Set this lens flare's yaw angle. - // @function LensFlare:SetYaw - // @tparam float New yaw angle in degrees. void LensFlare::SetYaw(float yaw) { _rotation.y = yaw; } - - /// Set this lens flare's color. - // @function LensFlare:SetColor - // @tparam Color New color. + void LensFlare::SetColor(const ScriptColor& color) { _color = color; } + + void LensFlare::SetEnabled(bool value) + { + _isEnabled = value; + } } diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h index d1585ac5d..bbf2f1cff 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h @@ -39,7 +39,7 @@ namespace TEN::Scripting float GetPitch() const; float GetYaw() const; ScriptColor GetColor() const; - bool GetEnabledStatus() const; + bool GetEnabled() const; // Setters @@ -47,5 +47,6 @@ namespace TEN::Scripting void SetPitch(float pitch); void SetYaw(float yaw); void SetColor(const ScriptColor& color); + void SetEnabled(bool value); }; } diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp index dc86d8c5e..a9a7bb7cf 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp @@ -13,10 +13,9 @@ These are things things which aren't present in the compiled level file itself. @pragma nostrip */ -/*** Make a new Level object. - @function Level - @treturn Level a Level object - */ +/// Make a new Level object. +//@function Level +//@treturn Level a Level object. void Level::Register(sol::table& parent) { // Register type. @@ -25,13 +24,12 @@ void Level::Register(sol::table& parent) sol::constructors(), sol::call_constructor, sol::constructors(), -/// (string) string key for the level's (localised) name. -// Corresponds to an entry in strings.lua. +/// (string) String key for the level's name. Corresponds to an entry in strings.lua. //@mem nameKey "nameKey", &Level::NameStringKey, /// (string) Level-specific Lua script file. -// Path of the Lua file holding the level's logic script, relative to the location of the tombengine executable +// Path of the Lua file holding the level's logic script, relative to the location of the Tomb Engine executable. //@mem scriptFile "scriptFile", &Level::ScriptFileName, @@ -41,72 +39,64 @@ void Level::Register(sol::table& parent) "levelFile", &Level::FileName, /// (string) Load screen image. -// Path of the level's load screen file (.png or .jpg), relative to the location of the tombengine executable +// Path of the level's load screen file (.png or .jpg), relative to the location of the Tomb Engine executable. //@mem loadScreenFile "loadScreenFile", &Level::LoadScreenFileName, -/// (string) initial ambient sound track to play. +/// (string) Initial ambient sound track to play. // This is the filename of the track __without__ the .wav extension. //@mem ambientTrack "ambientTrack", &Level::AmbientTrack, -/// (@{Flow.SkyLayer}) Primary sky layer +/// (@{Flow.SkyLayer}) Primary sky cloud layer. //@mem layer1 "layer1", &Level::Layer1, -/// (@{Flow.SkyLayer}) Secondary sky layer +/// (@{Flow.SkyLayer}) Secondary sky cloud layer. //@mem layer2 "layer2", &Level::Layer2, -/// (@{Flow.Starfield}) Starfield. +/// (@{Flow.Horizon}) Primary horizon object. +//@mem horizon1 + "horizon1", &Level::Horizon1, + "horizon", sol::property(&Level::GetHorizon1Enabled, &Level::SetHorizon1Enabled), // Compatibility. + +/// (@{Flow.Horizon}) Secondary horizon object. +//@mem horizon2 + "horizon2", &Level::Horizon2, + +/// (@{Flow.Starfield}) Starfield in the sky. // @mem starfield "starfield", &Level::Starfield, -/// (@{Flow.LensFlare}) Global lens flare . +/// (@{Flow.LensFlare}) Global lens flare. // @mem lensFlare "lensFlare", &Level::LensFlare, -/// (@{Flow.Fog}) omni fog RGB color and distance. -// As seen in TR4's Desert Railroad. -// If not provided, distance fog will be black. +/// (@{Flow.Fog}) Global distance fog, with specified RGB color and distance. +// If not provided, distance fog will not be visible. //@mem fog "fog", &Level::Fog, -/// (bool) Draw sky layer? (default: false) -//@mem horizon - "horizon", &Level::Horizon, - /// (bool) Enable flickering lightning in the sky. -// Equivalent to classic TRLE's LIGHTNING setting. As in the TRC Ireland levels. -// +// Equivalent to classic TRLE's lightning setting, as in the TRC Ireland levels or TR4 Cairo levels. //@mem storm "storm", &Level::Storm, /// (WeatherType) Choose weather effect. // Must be one of the values `WeatherType.None`, `WeatherType.Rain`, or `WeatherType.Snow`. -// //@mem weather "weather", &Level::Weather, /// (float) Choose weather strength. // Must be value between `0.1` and `1.0`. -// //@mem weatherStrength - "weatherStrength", sol::property(&Level::SetWeatherStrength), + "weatherStrength", &Level::WeatherStrength, -/*** (LaraType) Must be one of the LaraType values. -These are: +/*** (LaraType) Appearance of Lara. Must be either `LaraType.Normal` or `LaraType.Young`. +E.g. `myLevel.laraType = LaraType.Young` will make Lara appear as young (with two ponytails rendered). +This setting does not affect ability to use weapons or flares. - Normal - Young - Bunhead - Catsuit - Divesuit - Invisible - -e.g. `myLevel.laraType = LaraType.Divesuit` - - __(not yet fully implemented)__ @mem laraType*/ "laraType", &Level::Type, @@ -115,21 +105,24 @@ e.g. `myLevel.laraType = LaraType.Divesuit` //@mem rumble "rumble", &Level::Rumble, - "farView", sol::property(&Level::SetLevelFarView), +/// (int) The maximum draw distance for level. +// Given in sectors (blocks). Must be at least 4. +//@mem farView + "farView", &Level::LevelFarView, /// (bool) Reset hub data. // Resets the state for all previous levels, including items, flipmaps and statistics. //@mem resetHub "resetHub", &Level::ResetHub, -/// (table of @{Flow.InventoryItem}s) table of inventory object overrides +/// (table of @{Flow.InventoryItem}s) A table of inventory object layout overrides. //@mem objects "objects", &Level::InventoryObjects, -/// (short) Set Secrets for Level +/// (short) Set total secret count for current level. //@mem secrets - "secrets", sol::property(&Level::SetSecrets) - ); + "secrets", &Level::LevelSecrets + ); } void Level::SetWeatherStrength(float val) @@ -147,14 +140,6 @@ void Level::SetWeatherStrength(float val) } } -/*** (int) The maximum draw distance for level. -Given in sectors (blocks). -Must be at least 4. - -This is equivalent to TRNG's LevelFarView variable. - -@mem farView -*/ void Level::SetLevelFarView(short val) { static_assert(MIN_FAR_VIEW == 3200.0f, "Please update the comment, docs, and warning message if this number changes."); @@ -173,46 +158,25 @@ void Level::SetLevelFarView(short val) } } -RGBAColor8Byte Level::GetSkyLayerColor(int index) const +const SkyLayer& Level::GetSkyLayer(int index) const { TENAssert(index == 0 || index == 1, "Sky layer index must be 0 or 1."); + return (index == 0 ? Layer1 : Layer2); +} - if (index == 0) - { - return Layer1.GetColor(); - } - else - { - return Layer2.GetColor(); - } +RGBAColor8Byte Level::GetSkyLayerColor(int index) const +{ + return GetSkyLayer(index).GetColor(); } bool Level::GetSkyLayerEnabled(int index) const { - TENAssert(index == 0 || index == 1, "Sky layer index must be 0 or 1."); - - if (index == 0) - { - return Layer1.Enabled; - } - else - { - return Layer2.Enabled; - } + return GetSkyLayer(index).Enabled; } short Level::GetSkyLayerSpeed(int index) const { - TENAssert(index == 0 || index == 1, "Sky layer index must be 0 or 1."); - - if (index == 0) - { - return Layer1.CloudSpeed; - } - else - { - return Layer2.CloudSpeed; - } + return GetSkyLayer(index).CloudSpeed; } LaraType Level::GetLaraType() const @@ -230,9 +194,14 @@ bool Level::GetStormEnabled() const return Storm; } +bool Level::GetRumbleEnabled() const +{ + return Rumble; +} + float Level::GetWeatherStrength() const { - return WeatherStrength; + return WeatherStrength; } WeatherType Level::GetWeatherType() const @@ -240,22 +209,17 @@ WeatherType Level::GetWeatherType() const return Weather; } -bool Level::GetFogEnabled() const -{ - return Fog.Enabled; -} - RGBAColor8Byte Level::GetFogColor() const { return Fog.GetColor(); } -short Level::GetFogMinDistance() const +float Level::GetFogMinDistance() const { return Fog.MinDistance; } -short Level::GetFogMaxDistance() const +float Level::GetFogMaxDistance() const { return Fog.MaxDistance; } @@ -280,9 +244,60 @@ std::string Level::GetAmbientTrack() const return AmbientTrack; } +const TEN::Scripting::Horizon& Level::GetHorizon(int index) const +{ + TENAssert(index == 0 || index == 1, "Horizon index must be 0 or 1."); + return (index == 0 ? Horizon1 : Horizon2); +} + +bool Level::GetHorizon1Enabled() const +{ + return Horizon1.GetEnabled(); +} + +void Level::SetHorizon1Enabled(bool enabled) +{ + Horizon1.SetEnabled(enabled); +} + +bool Level::GetHorizonEnabled(int index) const +{ + return GetHorizon(index).GetEnabled(); +} + +GAME_OBJECT_ID Level::GetHorizonObjectID(int index) const +{ + return GetHorizon(index).GetObjectID(); +} + +float Level::GetHorizonTransparency(int index) const +{ + return GetHorizon(index).GetTransparency(); +} + +Vector3 Level::GetHorizonPosition(int index) const +{ + return GetHorizon(index).GetPosition().ToVector3(); +} + +EulerAngles Level::GetHorizonOrientation(int index) const +{ + return GetHorizon(index).GetRotation().ToEulerAngles(); +} + +Vector3 Level::GetHorizonPrevPosition(int index) const +{ + return GetHorizon(index).GetPrevPosition().ToVector3(); +} + +EulerAngles Level::GetHorizonPrevOrientation(int index) const +{ + return GetHorizon(index).GetPrevRotation().ToEulerAngles(); +} + bool Level::GetLensFlareEnabled() const { - return LensFlare.GetEnabledStatus(); + return LensFlare.GetEnabled(); } int Level::GetLensFlareSunSpriteID() const @@ -305,16 +320,6 @@ Color Level::GetLensFlareColor() const return LensFlare.GetColor(); } -bool Level::GetStarfieldStarsEnabled() const -{ - return Starfield.GetStarsEnabledStatus(); -} - -bool Level::GetStarfieldMeteorsEnabled() const -{ - return Starfield.GetMeteorsEnabledStatus(); -} - int Level::GetStarfieldStarCount() const { return Starfield.GetStarCount(); diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h index 13bcae96a..dda7e23a1 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h @@ -1,6 +1,7 @@ #pragma once -#include "Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h" +#include "Scripting/Internal/TEN/Flow/Horizon/Horizon.h" #include "Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h" +#include "Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h" #include "Scripting/Internal/TEN/Flow/Starfield/Starfield.h" #include "Scripting/Internal/TEN/Flow/Fog/Fog.h" #include "Scripting/Include/ScriptInterfaceLevel.h" @@ -27,18 +28,21 @@ static const std::unordered_map PLAYER_TYPES struct Level : public ScriptInterfaceLevel { - SkyLayer Layer1 = {}; - SkyLayer Layer2 = {}; Fog Fog = {}; int LevelFarView = 0; std::string AmbientTrack = {}; - LensFlare LensFlare = {}; - Starfield Starfield = {}; + SkyLayer Layer1 = {}; + SkyLayer Layer2 = {}; + TEN::Scripting::Horizon Horizon1 = {}; + TEN::Scripting::Horizon Horizon2 = {}; + TEN::Scripting::LensFlare LensFlare = {}; + TEN::Scripting::Starfield Starfield = {}; WeatherType Weather = WeatherType::None; float WeatherStrength = 1.0f; bool Storm = false; + bool Rumble = false; LaraType Type = LaraType::Normal; int LevelSecrets = 0; @@ -49,10 +53,10 @@ struct Level : public ScriptInterfaceLevel // TODO: Clean up this mess. RGBAColor8Byte GetFogColor() const override; - bool GetFogEnabled() const override; float GetWeatherStrength() const override; bool GetSkyLayerEnabled(int index) const override; bool GetStormEnabled() const override; + bool GetRumbleEnabled() const override; short GetSkyLayerSpeed(int index) const override; RGBAColor8Byte GetSkyLayerColor(int index) const override; LaraType GetLaraType() const override; @@ -60,14 +64,27 @@ struct Level : public ScriptInterfaceLevel void SetLevelFarView(short val); static void Register(sol::table& parent); WeatherType GetWeatherType() const override; - short GetFogMinDistance() const override; - short GetFogMaxDistance() const override; + float GetFogMinDistance() const override; + float GetFogMaxDistance() const override; short GetFarView() const override; void SetSecrets(int secrets); int GetSecrets() const override; std::string GetAmbientTrack() const override; bool GetResetHubEnabled() const override; + // Horizon getters + bool GetHorizonEnabled(int index) const override; + GAME_OBJECT_ID GetHorizonObjectID(int index) const override; + float GetHorizonTransparency(int index) const override; + Vector3 GetHorizonPosition(int index) const override; + EulerAngles GetHorizonOrientation(int index) const override; + Vector3 GetHorizonPrevPosition(int index) const override; + EulerAngles GetHorizonPrevOrientation(int index) const override; + + // Compatibility + bool GetHorizon1Enabled() const; + void SetHorizon1Enabled(bool enabled); + // Lens flare getters bool GetLensFlareEnabled() const override; int GetLensFlareSunSpriteID() const override; @@ -76,10 +93,12 @@ struct Level : public ScriptInterfaceLevel Color GetLensFlareColor() const override; // Starfield getters - bool GetStarfieldStarsEnabled() const override; - bool GetStarfieldMeteorsEnabled() const override; int GetStarfieldStarCount() const override; int GetStarfieldMeteorCount() const override; int GetStarfieldMeteorSpawnDensity() const override; float GetStarfieldMeteorVelocity() const override; + + // Utility + const SkyLayer& GetSkyLayer(int index) const; + const TEN::Scripting::Horizon& GetHorizon(int index) const; }; diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp index ba2cf5e71..a3bfc7afb 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp @@ -25,15 +25,15 @@ namespace TEN::Scripting // NOTE: Since Weapons array is bound to Lua directly and Lua accesses this array by native enum, where 0 is NONE, and 1 is PISTOLS, // 0 index is omitted due to Lua indexing arrays starting from 1. 1 must be subtracted from initializer index. - Weapons[(int)LaraWeaponType::Pistol - 1] = { 8.0f, BLOCK(8), 9, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 3, true, true, true, false }; - Weapons[(int)LaraWeaponType::Revolver - 1] = { 4.0f, BLOCK(8), 16, (int)BLOCK(0.65f), 21, 21, 6, ScriptColor(192, 128, 0), 9, 3, true, false, true, false }; - Weapons[(int)LaraWeaponType::Uzi - 1] = { 8.0f, BLOCK(8), 3, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 2, true, true, true, false }; - Weapons[(int)LaraWeaponType::Shotgun - 1] = { 10.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 3, 3, 6, ScriptColor(192, 128, 0), 12, 3, true, true, false, false }; - Weapons[(int)LaraWeaponType::HK - 1] = { 4.0f, BLOCK(12), 0, (int)BLOCK(0.50f), 4, 4, 30, ScriptColor(192, 128, 0), 12, 2, true, true, true, false }; - Weapons[(int)LaraWeaponType::Crossbow - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 5, 20, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false }; - Weapons[(int)LaraWeaponType::GrenadeLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 10, ScriptColor(192, 128, 0), 0, 0, true, false, false, false }; - Weapons[(int)LaraWeaponType::RocketLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 1, ScriptColor(192, 128, 0), 0, 0, true, false, false, false }; - Weapons[(int)LaraWeaponType::HarpoonGun - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 6, 6, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false }; + Weapons[(int)LaraWeaponType::Pistol - 1] = { 8.0f, BLOCK(8), 9, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 3, true, true, true, false, false, Vec3( 0, 120, 30) }; + Weapons[(int)LaraWeaponType::Revolver - 1] = { 4.0f, BLOCK(8), 16, (int)BLOCK(0.65f), 21, 21, 6, ScriptColor(192, 128, 0), 9, 3, true, false, true, false, false, Vec3(-10, 130, 65) }; + Weapons[(int)LaraWeaponType::Uzi - 1] = { 8.0f, BLOCK(8), 3, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 2, true, true, true, false, false, Vec3( 0, 110, 40) }; + Weapons[(int)LaraWeaponType::Shotgun - 1] = { 10.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 3, 3, 6, ScriptColor(192, 128, 0), 12, 3, true, true, false, false, false, Vec3( 0, 210, 40) }; + Weapons[(int)LaraWeaponType::HK - 1] = { 4.0f, BLOCK(12), 0, (int)BLOCK(0.50f), 4, 4, 30, ScriptColor(192, 128, 0), 12, 2, true, true, true, false, false, Vec3( 0, 220, 102) }; + Weapons[(int)LaraWeaponType::Crossbow - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 5, 20, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false, false, Vec3( 0, 240, 50) }; + Weapons[(int)LaraWeaponType::GrenadeLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 10, ScriptColor(192, 128, 0), 0, 0, true, false, false, false, false, Vec3( 0, 190, 50) }; + Weapons[(int)LaraWeaponType::RocketLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 1, ScriptColor(192, 128, 0), 0, 0, true, false, false, false, false, Vec3( 0, 90, 90) }; + Weapons[(int)LaraWeaponType::HarpoonGun - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 6, 6, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false, false, Vec3(-15, 240, 50) }; } void Settings::Register(sol::table& parent) @@ -73,35 +73,35 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(AnimSettings, ScriptReserved_AnimSettings), /// Extended crawl moveset. - // @tfield bool crawlExtended when enabled, player will be able to traverse across one-click steps in crawlspaces. + // @tfield bool crawlExtended When enabled, player will be able to traverse across one-click steps in crawlspaces. "crawlExtended", &AnimSettings::CrawlExtended, /// Crouch roll. - // @tfield bool crouchRoll when enabled, player can perform crawlspace roll by pressing sprint key. + // @tfield bool crouchRoll When enabled, player can perform crawlspace roll by pressing sprint key. "crouchRoll", &AnimSettings::CrouchRoll, /// Crawlspace dive. - // @tfield bool crawlspaceSwandive when enabled, player will be able to swandive into crawlspaces. + // @tfield bool crawlspaceSwandive When enabled, player will be able to swandive into crawlspaces. "crawlspaceSwandive", &AnimSettings::CrawlspaceDive, // Overhang climbing. - // @tfield bool overhangClimb enables overhang climbing feature. Currently does not work. + // @tfield bool overhangClimb Enables overhang climbing feature. Currently does not work. "overhangClimb", &AnimSettings::OverhangClimb, // Extended slide mechanics. - // @tfield bool slideExtended if enabled, player will be able to change slide direction with controls. Currently does not work. + // @tfield bool slideExtended If enabled, player will be able to change slide direction with controls. Currently does not work. "slideExtended", &AnimSettings::SlideExtended, /// Sprint jump. - // @tfield bool sprintJump if enabled, player will be able to perform extremely long jump when sprinting. + // @tfield bool sprintJump If enabled, player will be able to perform extremely long jump when sprinting. "sprintJump", &AnimSettings::SprintJump, /// Ledge jumps. - // @tfield bool ledgeJumps if this setting is enabled, player will be able to jump upwards while hanging on the ledge. + // @tfield bool ledgeJumps If this setting is enabled, player will be able to jump upwards while hanging on the ledge. "ledgeJumps", &AnimSettings::LedgeJumps, /// Pose timeout. - // @tfield int poseTimeout if this setting is larger than 0, idle standing pose animation will be performed after given timeout (in seconds). + // @tfield int poseTimeout If this setting is larger than 0, idle standing pose animation will be performed after given timeout (in seconds). "poseTimeout", &AnimSettings::PoseTimeout); } @@ -116,15 +116,15 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(CameraSettings, ScriptReserved_CameraSettings), /// Determines highlight color in binocular mode. - // @tfield Color binocularLightColor color of highlight, when player presses action. Zero color means there will be no highlight. + // @tfield Color binocularLightColor Color of highlight, when player presses action. Zero color means there will be no highlight. "binocularLightColor", &CameraSettings::BinocularLightColor, /// Determines highlight color in lasersight mode. - // @tfield Color lasersightLightColor lasersight highlight color. Zero color means there will be no highlight. + // @tfield Color lasersightLightColor Lasersight highlight color. Zero color means there will be no highlight. "lasersightLightColor", &CameraSettings::LasersightLightColor, /// Specify whether camera can collide with objects. - // @tfield bool objectCollision when enabled, camera will collide with moveables and statics. Disable or TR4-like camera behaviour. + // @tfield bool objectCollision When enabled, camera will collide with moveables and statics. Disable for TR4-like camera behaviour. "objectCollision", &CameraSettings::ObjectCollision); } @@ -139,39 +139,39 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(FlareSettings, ScriptReserved_FlareSettings), /// Flare color. - // @tfield Color color flare color. Used for sparks and lensflare coloring as well. + // @tfield Color color Flare color. Used for sparks and lensflare coloring as well. "color", &FlareSettings::Color, /// Muzzle offset. - // @tfield Vec3 offset a relative muzzle offset where light and particle effects originate from. + // @tfield Vec3 offset A relative muzzle offset where light and particle effects originate from. "offset", &FlareSettings::Offset, /// Light range. - // @tfield int range flare light radius or range. Represented in "clicks" equal to 256 world units. + // @tfield int range Flare light radius or range. Represented in "clicks" equal to 256 world units. "range", &FlareSettings::Range, /// Burn timeout. - // @tfield int timeout flare burn timeout. Flare will stop working after given timeout (specified in seconds). + // @tfield int timeout Flare burn timeout. Flare will stop working after given timeout (specified in seconds). "timeout", &FlareSettings::Timeout, /// Default flare pickup count. - // @tfield int pickupCount specifies amount of flares that you get when you pick up a box of flares. + // @tfield int pickupCount Specifies amount of flares that you get when you pick up a box of flares. "pickupCount", &FlareSettings::PickupCount, /// Lens flare brightness. - // @tfield float lensflareBrightness brightness multiplier. Specifies how bright lens flare is in relation to light (on a range from 0 to 1). + // @tfield float lensflareBrightness Brightness multiplier. Specifies how bright lens flare is in relation to light (on a range from 0 to 1). "lensflareBrightness", &FlareSettings::LensflareBrightness, /// Toggle spark effect. - // @tfield bool sparks spark effect. Determines whether flare generates sparks when burning. + // @tfield bool sparks Spark effect. Determines whether flare generates sparks when burning. "sparks", &FlareSettings::Sparks, /// Toggle smoke effect. - // @tfield bool smoke smoke effect. Determines whether flare generates smoke when burning. + // @tfield bool smoke Smoke effect. Determines whether flare generates smoke when burning. "smoke", &FlareSettings::Smoke, /// Toggle flicker effect. - // @tfield bool flicker light and lensflare flickering. When turned off, flare light will be constant. + // @tfield bool flicker Light and lensflare flickering. When turned off, flare light will be constant. "flicker", &FlareSettings::Flicker); } @@ -188,15 +188,15 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(HairSettings, ScriptReserved_HairSettings), /// Root mesh to which hair object will attach to. - // @tfield int mesh index of a root mesh to which hair will attach. Root mesh may be different for each hair object. + // @tfield int mesh Index of a root mesh to which hair will attach. Root mesh may be different for each hair object. "rootMesh", &HairSettings::RootMesh, /// Relative braid offset to a headmesh. - // @tfield Vec3 offset specifies how braid is positioned in relation to a headmesh. + // @tfield Vec3 offset Specifies how braid is positioned in relation to a headmesh. "offset", &HairSettings::Offset, /// Braid connection indices. - // @tfield table indices a list of headmesh's vertex connection indices. Each index corresponds to nearest braid rootmesh vertex. Amount of indices is unlimited. + // @tfield table indices A list of headmesh's vertex connection indices. Each index corresponds to nearest braid rootmesh vertex. Amount of indices is unlimited. "indices", &HairSettings::Indices); } @@ -211,19 +211,19 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(HudSettings, ScriptReserved_HudSettings), /// Toggle in-game status bars visibility. - // @tfield bool statusBars if disabled, all status bars (health, air, stamina) will be hidden. + // @tfield bool statusBars If disabled, all status bars (health, air, stamina) will be hidden. "statusBars", &HudSettings::StatusBars, /// Toggle loading bar visibility. - // @tfield bool loadingBar if disabled, loading bar will be invisible in game. + // @tfield bool loadingBar If disabled, loading bar will be invisible in game. "loadingBar", &HudSettings::LoadingBar, /// Toggle speedometer visibility. - // @tfield bool speedometer if disabled, speedometer will be invisible in game. + // @tfield bool speedometer If disabled, speedometer will be invisible in game. "speedometer", &HudSettings::Speedometer, /// Toggle pickup notifier visibility. - // @tfield bool pickupNotifier if disabled, pickup notifier will be invisible in game. + // @tfield bool pickupNotifier If disabled, pickup notifier will be invisible in game. "pickupNotifier", &HudSettings::PickupNotifier); } @@ -238,11 +238,11 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(PhysicsSettings, ScriptReserved_PhysicsSettings), /// Global world gravity. - // @tfield float gravity specifies global gravity. Mostly affects Lara and several other objects. + // @tfield float gravity Specifies global gravity. Mostly affects Lara and several other objects. "gravity", &PhysicsSettings::Gravity, /// Swim velocity. - // @tfield float swimVelocity specifies swim velocity for Lara. Affects both surface and underwater. + // @tfield float swimVelocity Specifies swim velocity for Lara. Affects both surface and underwater. "swimVelocity", &PhysicsSettings::SwimVelocity); } @@ -258,60 +258,68 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(WeaponSettings, ScriptReserved_WeaponSettings), /// Shooting accuracy. - // @tfield float accuracy determines accuracy range in angles (smaller angles mean higher accuracy). Applicable only for firearms. + // @tfield float accuracy Determines accuracy range in angles (smaller angles mean higher accuracy). Applicable only for firearms. "accuracy", &WeaponSettings::Accuracy, /// Targeting distance. - // @tfield float targetingDistance specifies maximum targeting distance in world units (1 block = 1024 world units) for a given weapon. + // @tfield float targetingDistance Specifies maximum targeting distance in world units (1 block = 1024 world units) for a given weapon. "targetingDistance", &WeaponSettings::Distance, /// Shooting interval. - // @tfield float interval specifies an interval (in frames), after which Lara is able to shoot again. Not applicable for backholster weapons. + // @tfield float interval Specifies an interval (in frames), after which Lara is able to shoot again. Not applicable for backholster weapons. "interval", &WeaponSettings::Interval, /// Damage. - // @tfield int damage amount of hit points taken for every hit. + // @tfield int damage Amount of hit points taken for every hit. "damage", &WeaponSettings::Damage, /// Alternate damage. - // @tfield int alternateDamage for Revolver and HK, specifies damage in lasersight mode. For crossbow, specifies damage for explosive ammo. + // @tfield int alternateDamage For Revolver and HK, specifies damage in lasersight mode. For crossbow, specifies damage for explosive ammo. "alternateDamage", &WeaponSettings::AlternateDamage, /// Water level. - // @tfield int waterLevel specifies water depth, at which Lara will put weapons back into holsters, indicating it's not possible to use it in water. + // @tfield int waterLevel Specifies water depth, at which Lara will put weapons back into holsters, indicating it's not possible to use it in water. "waterLevel", &WeaponSettings::WaterLevel, /// Default ammo pickup count. - // @tfield int pickupCount amount of ammo which is given with every ammo pickup for this weapon. + // @tfield int pickupCount Amount of ammo which is given with every ammo pickup for this weapon. "pickupCount", &WeaponSettings::PickupCount, /// Gunflash color. - // @tfield Color flashColor specifies the color of the gunflash. Applicable only for firearms. + // @tfield Color flashColor specifies the color of the gunflash. "flashColor", &WeaponSettings::FlashColor, /// Gunflash range. - // @tfield Color flashRange specifies the range of the gunflash. Applicable only for firearms. + // @tfield Color flashRange specifies the range of the gunflash. "flashRange", &WeaponSettings::FlashRange, /// Gunflash duration. - // @tfield int flashDuration specifies the duration of a gunflash effect. Applicable only for firearms. + // @tfield int flashDuration specifies the duration of a gunflash effect. "flashDuration", &WeaponSettings::FlashDuration, /// Gun smoke. - // @tfield bool smoke if set to true, indicates that weapon emits gun smoke. Not applicable for crossbow and harpoon gun. + // @tfield bool smoke if set to true, indicates that weapon emits gun smoke. "smoke", &WeaponSettings::Smoke, /// Gun shell. - // @tfield bool shell if set to true, indicates that weapon emits gun shell. Applicable only for firearms. + // @tfield bool shell If set to true, indicates that weapon emits gun shell. Applicable only for firearms. "shell", &WeaponSettings::Shell, /// Display muzzle flash. - // @tfield bool muzzleFlash specifies whether muzzle flash should be displayed or not. Applicable only for firearms. + // @tfield bool muzzleFlash specifies whether muzzle flash should be displayed or not. "muzzleFlash", &WeaponSettings::MuzzleFlash, + /// Display muzzle glow. + // @tfield bool muzzleGlow specifies whether muzzle glow should be displayed or not. + "muzzleGlow", &WeaponSettings::MuzzleGlow, + /// Colorize muzzle flash. - // @tfield bool colorizeMuzzleFlash specifies whether muzzle flash should be tinted with the same color as gunflash color. Applicable only for firearms. - "colorizeMuzzleFlash", &WeaponSettings::ColorizeMuzzleFlash); + // @tfield bool colorizeMuzzleFlash specifies whether muzzle flash should be tinted with the same color as gunflash color. + "colorizeMuzzleFlash", &WeaponSettings::ColorizeMuzzleFlash, + + /// Muzzle offset. + // @tfield Vec3 muzzleOffset specifies offset for spawning muzzle gunflash effects. + "muzzleOffset", &WeaponSettings::MuzzleOffset); } /// System @@ -325,20 +333,20 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(SystemSettings, ScriptReserved_SystemSettings), /// How should the application respond to script errors? - // @tfield Flow.ErrorMode errorMode error mode to use. */ + // @tfield Flow.ErrorMode errorMode Error mode to use. "errorMode", &SystemSettings::ErrorMode, /// Use multithreading in certain calculations.
                                                      // When set to `true`, some performance-critical calculations will be performed in parallel, which can give // a significant performance boost. Don't disable unless you have problems with launching or using TombEngine. - // @tfield bool multithreaded determines whether to use multithreading or not. */ + // @tfield bool multithreaded Determines whether to use multithreading or not. "multithreaded", &SystemSettings::Multithreaded, /// Can the game utilize the fast reload feature?
                                                      // When set to `true`, the game will attempt to perform fast savegame reloading if current level is the same as // the level loaded from the savegame. It will not work if the level timestamp or checksum has changed // (i.e. level was updated). If set to `false`, this functionality is turned off. - // @tfield bool fastReload toggle fast reload on or off. + // @tfield bool fastReload Toggles fast reload on or off. "fastReload", &SystemSettings::FastReload); } } diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h index 7b2d962ad..f4f110141 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h @@ -103,7 +103,9 @@ namespace TEN::Scripting bool Smoke = false; bool Shell = false; bool MuzzleFlash = true; + bool MuzzleGlow = true; bool ColorizeMuzzleFlash = false; + Vec3 MuzzleOffset = {}; static void Register(sol::table& parent); }; diff --git a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp index 027572219..7f9ca11f3 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp @@ -7,9 +7,7 @@ namespace TEN::Scripting::Types { class ScriptColor; } using namespace TEN::Scripting::Types; -/*** Describes a layer of moving clouds. -As seen in TR4's City of the Dead. - +/*** Describes a layer of moving clouds. To be used with @{Flow.Level.layer1} and @{Flow.Level.layer2} properties. @tenprimitive Flow.SkyLayer @pragma nostrip */ @@ -21,11 +19,11 @@ void SkyLayer::Register(sol::table & parent) ctors(), sol::call_constructor, ctors(), - /// (@{Color}) RGB sky color + /// (@{Color}) RGB sky color. //@mem color "color", sol::property(&SkyLayer::GetColor, &SkyLayer::SetColor), - /*** (int) cloud speed. + /*** (int) Cloud speed. Values can be between [-32768, 32767], with positive numbers resulting in a sky that scrolls from west to east, and negative numbers resulting in one that travels east to west. @@ -40,8 +38,8 @@ void SkyLayer::Register(sol::table & parent) } /*** -@tparam Color color RGB color -@tparam int speed cloud speed +@tparam Color color RGB color. +@tparam int speed Cloud speed. @treturn SkyLayer A SkyLayer object. @function SkyLayer */ diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp index 5b1b3de47..dcb1eaca5 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp @@ -6,8 +6,7 @@ using namespace TEN::Effects::Environment; -/// Represents a starfield in the sky. -// +/// Represents a star field in the sky. To be used with @{Flow.Level.starfield} property. // @tenprimitive Flow.Starfield // @pragma nostrip @@ -24,12 +23,27 @@ namespace TEN::Scripting "Starfield", ctors(), sol::call_constructor, ctors(), + /// (int) Amount of visible stars. + // @mem starCount + "starCount", sol::property(&Starfield::GetStarCount, &Starfield::SetStarCount), + + /// (int) Amount of visible meteors. + // @mem meteorCount + "meteorCount", sol::property(&Starfield::GetMeteorCount, &Starfield::SetMeteorCount), + + /// (int) Meteor spawn density. + // @mem meteorSpawnDensity + "meteorSpawnDensity", sol::property(&Starfield::GetMeteorSpawnDensity, &Starfield::SetMeteorSpawnDensity), + + /// (int) Meteor velocity. + // @mem meteorVelocity + "meteorVelocity", sol::property(&Starfield::GetMeteorVelocity, &Starfield::SetMeteorVelocity), + + // Compatibility. "GetStarCount", &Starfield::GetStarCount, "GetMeteorCount", &Starfield::GetMeteorCount, "GetMeteorSpawnDensity", &Starfield::GetMeteorSpawnDensity, "GetMeteorVelocity", &Starfield::GetMeteorVelocity, - "GetStarsEnabled", &Starfield::GetStarsEnabledStatus, - "GetMeteorsEnabled", &Starfield::GetMeteorsEnabledStatus, "SetStarCount", &Starfield::SetStarCount, "SetMeteorCount", &Starfield::SetMeteorCount, @@ -50,6 +64,8 @@ namespace TEN::Scripting // @function Starfield // @tparam int starCount Star count. __Max: 6000__ // @tparam int meteorCount Meteor count. __Max: 100__ + // @tparam int meteorSpawnDensity Meteor spawn density. + // @tparam int meteorVel Meteor velocity. // @treturn Starfield A new Starfield object. Starfield::Starfield(int starCount, int meteorCount, int meteorSpawnDensity, float meteorVel) { @@ -65,57 +81,26 @@ namespace TEN::Scripting _meteorVelocity = meteorVel; } - /// Get this starfield's number of stars. - // @function Starfield:GetStarCount - // @treturn int Count. int Starfield::GetStarCount() const { return _starCount; } - /// Get this starfield's number of meteors. - // @function Starfield:GetMeteorCount - // @treturn int Count. int Starfield::GetMeteorCount() const { return _meteorCount; } - /// Get this starfield's meteor spawn density. - // @function Starfield:GetMeteorSpawnDensity - // @treturn int Spawn density. int Starfield::GetMeteorSpawnDensity() const { return _meteorSpawnDensity; } - /// Get this starfield's meteor velocity. - // @function Starfield:GetMeteorVelocity - // @treturn float Velocity. float Starfield::GetMeteorVelocity() const { return _meteorVelocity; } - /// Get this starfield's stars enabled status. - // @function Starfield:GetStarsEnabled - // @treturn bool Stars enabled status. __true: enabled__, __false: disabled__ - bool Starfield::GetStarsEnabledStatus() const - { - return (_starCount > 0); - } - - /// Get this starfield's meteors enabled status. - // @function Starfield:GetMeteorsEnabled - // @treturn bool Meteors enabled status. __true: enabled__, __false: disabled__ - bool Starfield::GetMeteorsEnabledStatus() const - { - return (_meteorCount > 0); - } - - /// Set this starfield's number of stars. - // @function Starfield:SetStarCount - // @tparam int New star count. void Starfield::SetStarCount(int count) { if (count < 0 || count > STAR_COUNT_MAX) @@ -124,9 +109,6 @@ namespace TEN::Scripting _starCount = std::clamp(count, 0, STAR_COUNT_MAX); } - /// Set this starfield's number of meteors. - // @function Starfield:SetMeteorCount - // @tparam int New meteor count. void Starfield::SetMeteorCount(int count) { if (count < 0 || count > METEOR_COUNT_MAX) @@ -135,17 +117,11 @@ namespace TEN::Scripting _meteorCount = std::clamp(count, 0, METEOR_COUNT_MAX); } - /// Set this starfield's meteor spawn density. - // @function Starfield:SetMeteorSpawnDensity - // @tparam int New meteor spawn density. void Starfield::SetMeteorSpawnDensity(int spawnDensity) { _meteorSpawnDensity = spawnDensity; } - /// Set this starfield's meteor velocity. - // @function Starfield:SetMeteorVelocity - // @tparam float New meteor velocity. void Starfield::SetMeteorVelocity(float vel) { _meteorVelocity = vel; diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h index 4f7045b8c..7e918e996 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h @@ -35,8 +35,6 @@ namespace TEN::Scripting int GetMeteorCount() const; int GetMeteorSpawnDensity() const; float GetMeteorVelocity() const; - bool GetStarsEnabledStatus() const; - bool GetMeteorsEnabledStatus() const; // Setters diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp index d84b3bec4..cc9bef77d 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp @@ -21,42 +21,47 @@ namespace TEN::Scripting sol::meta_function::new_index, NewIndexErrorMaker(Statistics, ScriptReserved_Statistics), /*** Ammo hits. - @tfield int ammoHits amount of successful enemy hits. + @tfield int ammoHits Amount of successful enemy hits. */ "ammoHits", &Statistics::AmmoHits, /*** Ammo used. - @tfield int ammoUsed amount of used ammo. + @tfield int ammoUsed Amount of used ammo. */ "ammoUsed", &Statistics::AmmoUsed, /*** Distance traveled. - @tfield int distanceTraveled amount of traveled distance in world units. One meter is 420 world units. + @tfield int distanceTraveled Amount of traveled distance in world units. One meter is 420 world units. */ "distanceTraveled", &Statistics::Distance, /*** Health packs used. - @tfield int healthPacksUsed amount of used medipacks. + @tfield int healthPacksUsed Amount of used medipacks. */ "healthPacksUsed", &Statistics::HealthUsed, /*** Damage taken. - @tfield int damageTaken overall amount of taken damage. + @tfield int damageTaken overall Amount of taken damage. */ "damageTaken", &Statistics::DamageTaken, /*** Kills. - @tfield int kills amount of killed enemies. + @tfield int kills Amount of killed enemies. */ "kills", &Statistics::Kills, + /*** Pickups. + @tfield int pickups Amount of picked up items. + */ + "pickups", &Statistics::Pickups, + /*** Secrets. - @tfield int secrets amount of found secrets. + @tfield int secrets Amount of found secrets. */ "secrets", &Statistics::Secrets, /*** Time taken. - @tfield Time timeTaken amount of time passed. + @tfield Time timeTaken Amount of time passed. */ "timeTaken", &Statistics::TimeTaken); } diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h index 46ce309c2..b289a2849 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h @@ -15,6 +15,7 @@ namespace TEN::Scripting unsigned int HealthUsed = 0; unsigned int DamageTaken = 0; unsigned int Kills = 0; + unsigned int Pickups = 0; unsigned int Secrets = 0; static void Register(sol::table&); diff --git a/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h b/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h index 93b5a5614..788d0a0e2 100644 --- a/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h +++ b/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h @@ -63,7 +63,7 @@ To be used with @{Input.KeyIsHit}, @{Input.KeyIsHeld}, and similar functions. @table Input.ActionID */ -static const std::unordered_map ACTION_IDS +static const std::unordered_map ACTION_IDS { { "FORWARD", In::Forward }, { "BACK", In::Back }, diff --git a/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp index 5db8c91f2..7f604d502 100644 --- a/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp @@ -19,8 +19,8 @@ namespace TEN::Scripting::Input { /// Vibrate the game controller if the function is available and the setting is on. // @function Vibrate - // @tparam float strength Vibration strength. - // @tparam float time __(default 0.3)__ Vibration time in seconds. + // @tparam float strength Vibration strength. + // @tparam[opt=0.3] float time Vibration time in seconds. static void Vibrate(float strength, sol::optional time) { Rumble(strength, time.value_or(0.3f), RumbleMode::Both); @@ -28,7 +28,7 @@ namespace TEN::Scripting::Input static bool CheckInput(int actionID) { - if (actionID > (int)ActionID::Count) + if (actionID > (int)InputActionID::Count) { ScriptAssertF(false, "Input action {} does not exist.", actionID); return false; @@ -45,7 +45,7 @@ namespace TEN::Scripting::Input if (!CheckInput(actionID)) return false; - if (IsHeld((ActionID)actionID)) + if (IsHeld((InputActionID)actionID)) return true; return false; @@ -59,7 +59,7 @@ namespace TEN::Scripting::Input if (!CheckInput(actionID)) return false; - if (IsClicked((ActionID)actionID)) + if (IsClicked((InputActionID)actionID)) return true; return false; @@ -73,7 +73,7 @@ namespace TEN::Scripting::Input if (!CheckInput(actionID)) return; - ActionQueue[actionID] = QueueState::Push; + ActionQueueMap[(InputActionID)actionID] = ActionQueueState::Update; } /// Clear an action key. @@ -84,19 +84,19 @@ namespace TEN::Scripting::Input if (!CheckInput(actionID)) return; - ActionQueue[actionID] = QueueState::Clear; + ActionQueueMap[(InputActionID)actionID] = ActionQueueState::Clear; } /// Clear all action keys. // @function KeyClearAll static void KeyClearAll() { - for (auto& queue : ActionQueue) - queue = QueueState::Clear; + for (auto& [actionID, queue] : ActionQueueMap) + queue = ActionQueueState::Clear; } /// Get the display position of the cursor in percent. - // @function GetMouseDisplayPosition() + // @function GetMouseDisplayPosition // @treturn Vec2 Cursor display position in percent. static Vec2 GetMouseDisplayPosition() { diff --git a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp index 2253f4bcc..1ec40f0f5 100644 --- a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp @@ -194,11 +194,11 @@ sol::object GetVariable(sol::table tab, sol::object key) return tab.raw_get(key); } -LogicHandler::LogicHandler(sol::state* lua, sol::table & parent) : m_handler{ lua } +LogicHandler::LogicHandler(sol::state* lua, sol::table& parent) : _handler{ lua } { - m_handler.GetState()->set_function("print", &LogicHandler::LogPrint, this); + _handler.GetState()->set_function("print", &LogicHandler::LogPrint, this); - sol::table tableLogic{ m_handler.GetState()->lua_state(), sol::create }; + auto tableLogic = sol::table(_handler.GetState()->lua_state(), sol::create); parent.set(ScriptReserved_Logic, tableLogic); @@ -208,24 +208,24 @@ LogicHandler::LogicHandler(sol::state* lua, sol::table & parent) : m_handler{ lu tableLogic.set_function(ScriptReserved_EnableEvent, &LogicHandler::EnableEvent, this); tableLogic.set_function(ScriptReserved_DisableEvent, &LogicHandler::DisableEvent, this); - m_handler.MakeReadOnlyTable(tableLogic, ScriptReserved_EndReason, LEVEL_END_REASONS); - m_handler.MakeReadOnlyTable(tableLogic, ScriptReserved_CallbackPoint, CALLBACK_POINTS); - m_handler.MakeReadOnlyTable(tableLogic, ScriptReserved_EventType, EVENT_TYPES); + _handler.MakeReadOnlyTable(tableLogic, ScriptReserved_EndReason, LEVEL_END_REASONS); + _handler.MakeReadOnlyTable(tableLogic, ScriptReserved_CallbackPoint, CALLBACK_POINTS); + _handler.MakeReadOnlyTable(tableLogic, ScriptReserved_EventType, EVENT_TYPES); - m_callbacks.insert(std::make_pair(CallbackPoint::PreStart, &m_callbacksPreStart)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostStart, &m_callbacksPostStart)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreLoad, &m_callbacksPreLoad)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostLoad, &m_callbacksPostLoad)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreLoop, &m_callbacksPreLoop)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostLoop, &m_callbacksPostLoop)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreSave, &m_callbacksPreSave)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostSave, &m_callbacksPostSave)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreEnd, &m_callbacksPreEnd)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostEnd, &m_callbacksPostEnd)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreUseItem, &m_callbacksPreUseItem)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostUseItem, &m_callbacksPostUseItem)); - m_callbacks.insert(std::make_pair(CallbackPoint::PreFreeze, &m_callbacksPreFreeze)); - m_callbacks.insert(std::make_pair(CallbackPoint::PostFreeze, &m_callbacksPostFreeze)); + _callbacks.insert(std::make_pair(CallbackPoint::PreStart, &_callbacksPreStart)); + _callbacks.insert(std::make_pair(CallbackPoint::PostStart, &_callbacksPostStart)); + _callbacks.insert(std::make_pair(CallbackPoint::PreLoad, &_callbacksPreLoad)); + _callbacks.insert(std::make_pair(CallbackPoint::PostLoad, &_callbacksPostLoad)); + _callbacks.insert(std::make_pair(CallbackPoint::PreLoop, &_callbacksPreLoop)); + _callbacks.insert(std::make_pair(CallbackPoint::PostLoop, &_callbacksPostLoop)); + _callbacks.insert(std::make_pair(CallbackPoint::PreSave, &_callbacksPreSave)); + _callbacks.insert(std::make_pair(CallbackPoint::PostSave, &_callbacksPostSave)); + _callbacks.insert(std::make_pair(CallbackPoint::PreEnd, &_callbacksPreEnd)); + _callbacks.insert(std::make_pair(CallbackPoint::PostEnd, &_callbacksPostEnd)); + _callbacks.insert(std::make_pair(CallbackPoint::PreUseItem, &_callbacksPreUseItem)); + _callbacks.insert(std::make_pair(CallbackPoint::PostUseItem, &_callbacksPostUseItem)); + _callbacks.insert(std::make_pair(CallbackPoint::PreFreeze, &_callbacksPreFreeze)); + _callbacks.insert(std::make_pair(CallbackPoint::PostFreeze, &_callbacksPostFreeze)); LevelFunc::Register(tableLogic); @@ -234,10 +234,10 @@ LogicHandler::LogicHandler(sol::state* lua, sol::table & parent) : m_handler{ lu void LogicHandler::ResetGameTables() { - auto state = m_handler.GetState(); + auto state = _handler.GetState(); MakeSpecialTable(state, ScriptReserved_GameVars, &GetVariable, &SetVariable); - (*state)[ScriptReserved_GameVars][ScriptReserved_Engine] = sol::table{ *state, sol::create }; + (*state)[ScriptReserved_GameVars][ScriptReserved_Engine] = sol::table(*state, sol::create); } /*** Register a function as a callback. @@ -286,9 +286,8 @@ Any returned value will be discarded. */ void LogicHandler::AddCallback(CallbackPoint point, const LevelFunc& levelFunc) { - auto it = m_callbacks.find(point); - - if (it == m_callbacks.end()) + auto it = _callbacks.find(point); + if (it == _callbacks.end()) { TENLog("Error: callback point not found. Attempted to access missing value.", LogLevel::Error, LogConfig::All, false); return; @@ -315,8 +314,8 @@ Will have no effect if the function was not registered as a callback */ void LogicHandler::RemoveCallback(CallbackPoint point, const LevelFunc& levelFunc) { - auto it = m_callbacks.find(point); - if (it == m_callbacks.end()) + auto it = _callbacks.find(point); + if (it == _callbacks.end()) { TENLog("Error: callback point not found. Attempted to access missing value.", LogLevel::Error, LogConfig::All, false); return; @@ -343,7 +342,7 @@ Possible event type values: @function HandleEvent @tparam string name Name of the event set to find. @tparam EventType type Event to execute. -@tparam Objects.Moveable activator Optional activator. Default is the player object. +@tparam[opt=Lara] Objects.Moveable activator Optional activator. */ void LogicHandler::HandleEvent(const std::string& name, EventType type, sol::optional activator) { @@ -374,7 +373,7 @@ void LogicHandler::DisableEvent(const std::string& name, EventType type) void LogicHandler::ResetLevelTables() { - auto state = m_handler.GetState(); + auto state = _handler.GetState(); MakeSpecialTable(state, ScriptReserved_LevelVars, &GetVariable, &SetVariable); (*state)[ScriptReserved_LevelVars][ScriptReserved_Engine] = sol::table{ *state, sol::create }; @@ -382,15 +381,15 @@ void LogicHandler::ResetLevelTables() sol::object LogicHandler::GetLevelFuncsMember(sol::table tab, const std::string& name) { - std::string partName = tab.raw_get(strKey); - auto& map = m_levelFuncs_tablesOfNames[partName]; + auto partName = tab.raw_get(strKey); + auto& map = _levelFuncs_tablesOfNames[partName]; auto fullNameIt = map.find(name); if (fullNameIt != std::cend(map)) { std::string_view key = fullNameIt->second; - if (m_levelFuncs_levelFuncObjects[key].valid()) - return m_levelFuncs_levelFuncObjects[key]; + if (_levelFuncs_levelFuncObjects[key].valid()) + return _levelFuncs_levelFuncObjects[key]; } return sol::nil; @@ -400,7 +399,7 @@ bool LogicHandler::SetLevelFuncsMember(sol::table tab, const std::string& name, { if (sol::type::lua_nil == value.get_type()) { - std::string error{ "Tried to set " + std::string{ScriptReserved_LevelFuncs} + " member " }; + auto error = std::string("Tried to set " + std::string{ScriptReserved_LevelFuncs} + " member "); error += name + " to nil; this not permitted at this time."; return ScriptAssert(false, error); } @@ -409,27 +408,27 @@ bool LogicHandler::SetLevelFuncsMember(sol::table tab, const std::string& name, // Add name to table of names. auto partName = tab.raw_get(strKey); auto fullName = partName + "." + name; - auto& parentNameTab = m_levelFuncs_tablesOfNames[partName]; + auto& parentNameTab = _levelFuncs_tablesOfNames[partName]; parentNameTab.insert_or_assign(name, fullName); // Create LevelFunc userdata and add that too. LevelFunc levelFuncObject; levelFuncObject.m_funcName = fullName; levelFuncObject.m_handler = this; - m_levelFuncs_levelFuncObjects[fullName] = levelFuncObject; + _levelFuncs_levelFuncObjects[fullName] = levelFuncObject; // Add function itself. - m_levelFuncs_luaFunctions[fullName] = value; + _levelFuncs_luaFunctions[fullName] = value; } else if (sol::type::table == value.get_type()) { // Create and add new name map. - std::unordered_map newNameMap; + auto newNameMap = std::unordered_map{}; auto fullName = tab.raw_get(strKey) + "." + name; - m_levelFuncs_tablesOfNames.insert_or_assign(fullName, newNameMap); + _levelFuncs_tablesOfNames.insert_or_assign(fullName, newNameMap); // Create new table to put in the LevelFuncs hierarchy. - auto newLevelFuncsTab = MakeSpecialTable(m_handler.GetState(), name, &LogicHandler::GetLevelFuncsMember, &LogicHandler::SetLevelFuncsMember, this); + auto newLevelFuncsTab = MakeSpecialTable(_handler.GetState(), name, &LogicHandler::GetLevelFuncsMember, &LogicHandler::SetLevelFuncsMember, this); newLevelFuncsTab.raw_set(strKey, fullName); tab.raw_set(name, newLevelFuncsTab); @@ -440,7 +439,7 @@ bool LogicHandler::SetLevelFuncsMember(sol::table tab, const std::string& name, } else { - std::string error{ "Failed to add " }; + auto error = std::string("Failed to add "); error += name + " to " + ScriptReserved_LevelFuncs + " or one of its tables; it must be a function or a table of functions."; return ScriptAssert(false, error); } @@ -450,10 +449,10 @@ bool LogicHandler::SetLevelFuncsMember(sol::table tab, const std::string& name, void LogicHandler::LogPrint(sol::variadic_args args) { - std::string str; + auto str = std::string(); for (const sol::object& o : args) { - auto strPart = (*m_handler.GetState())["tostring"](o).get(); + auto strPart = (*_handler.GetState())["tostring"](o).get(); str += strPart; str += "\t"; } @@ -465,10 +464,10 @@ void LogicHandler::ResetScripts(bool clearGameVars) { FreeLevelScripts(); - for (auto& [first, second] : m_callbacks) + for (auto& [first, second] : _callbacks) second->clear(); - auto currentPackage = m_handler.GetState()->get("package"); + auto currentPackage = _handler.GetState()->get("package"); auto currentLoaded = currentPackage.get("loaded"); for (auto& [first, second] : currentLoaded) @@ -477,35 +476,35 @@ void LogicHandler::ResetScripts(bool clearGameVars) if (clearGameVars) ResetGameTables(); - m_handler.ResetGlobals(); + _handler.ResetGlobals(); - m_shortenedCalls = false; + _shortenedCalls = false; - m_handler.GetState()->collect_garbage(); + _handler.GetState()->collect_garbage(); } void LogicHandler::FreeLevelScripts() { - m_levelFuncs = MakeSpecialTable(m_handler.GetState(), ScriptReserved_LevelFuncs, &LogicHandler::GetLevelFuncsMember, &LogicHandler::SetLevelFuncsMember, this); - m_levelFuncs.raw_set(strKey, ScriptReserved_LevelFuncs); + _levelFuncs = MakeSpecialTable(_handler.GetState(), ScriptReserved_LevelFuncs, &LogicHandler::GetLevelFuncsMember, &LogicHandler::SetLevelFuncsMember, this); + _levelFuncs.raw_set(strKey, ScriptReserved_LevelFuncs); - m_levelFuncs[ScriptReserved_Engine] = sol::table{ *m_handler.GetState(), sol::create }; + _levelFuncs[ScriptReserved_Engine] = sol::table(*_handler.GetState(), sol::create); - m_levelFuncs_tablesOfNames.clear(); - m_levelFuncs_luaFunctions.clear(); - m_levelFuncs_levelFuncObjects = sol::table{ *m_handler.GetState(), sol::create }; + _levelFuncs_tablesOfNames.clear(); + _levelFuncs_luaFunctions.clear(); + _levelFuncs_levelFuncObjects = sol::table(*_handler.GetState(), sol::create); - m_levelFuncs_tablesOfNames.emplace(std::make_pair(ScriptReserved_LevelFuncs, std::unordered_map{})); + _levelFuncs_tablesOfNames.emplace(std::make_pair(ScriptReserved_LevelFuncs, std::unordered_map{})); ResetLevelTables(); - m_onStart = sol::nil; - m_onLoad = sol::nil; - m_onLoop = sol::nil; - m_onSave = sol::nil; - m_onEnd = sol::nil; - m_onUseItem = sol::nil; - m_onBreak = sol::nil; - m_handler.GetState()->collect_garbage(); + _onStart = sol::nil; + _onLoad = sol::nil; + _onLoop = sol::nil; + _onSave = sol::nil; + _onEnd = sol::nil; + _onUseItem = sol::nil; + _onFreeze = sol::nil; + _handler.GetState()->collect_garbage(); } // Used when loading. @@ -516,13 +515,13 @@ void LogicHandler::SetVariables(const std::vector& vars, bool onlyLeve ResetLevelTables(); - std::unordered_map solTables; + auto solTables = std::unordered_map{}; for(int i = 0; i < vars.size(); ++i) { if (std::holds_alternative(vars[i])) { - solTables.try_emplace(i, *m_handler.GetState(), sol::create); + solTables.try_emplace(i, *_handler.GetState(), sol::create); auto indexTab = std::get(vars[i]); for (auto& [first, second] : indexTab) { @@ -530,7 +529,7 @@ void LogicHandler::SetVariables(const std::vector& vars, bool onlyLeve // create it if need be if (std::holds_alternative(vars[second])) { - solTables.try_emplace(second, *m_handler.GetState(), sol::create); + solTables.try_emplace(second, *_handler.GetState(), sol::create); solTables[i][vars[first]] = solTables[second]; } else if (std::holds_alternative(vars[second])) @@ -594,14 +593,14 @@ void LogicHandler::SetVariables(const std::vector& vars, bool onlyLeve sol::table levelVars = rootTable[ScriptReserved_LevelVars]; for (auto& [first, second] : levelVars) - (*m_handler.GetState())[ScriptReserved_LevelVars][first] = second; + (*_handler.GetState())[ScriptReserved_LevelVars][first] = second; if (onlyLevelVars) return; sol::table gameVars = rootTable[ScriptReserved_GameVars]; for (auto& [first, second] : gameVars) - (*m_handler.GetState())[ScriptReserved_GameVars][first] = second; + (*_handler.GetState())[ScriptReserved_GameVars][first] = second; } template @@ -621,12 +620,34 @@ int Handle(TypeFrom& var, MapType& varsMap, size_t& numVars, std::vectorsecond; } +void LogicHandler::AddConsoleInput(const std::string& input) +{ + _consoleInput = input; +} + +void LogicHandler::PerformConsoleInput() +{ + if (!_consoleInput.empty()) + { + try + { + ExecuteString(_consoleInput); + } + catch (const std::exception& ex) + { + TENLog("Error executing " + _consoleInput + ": " + ex.what(), LogLevel::Error); + } + + _consoleInput.clear(); + } +} + std::string LogicHandler::GetRequestedPath() const { - std::string path; - for (unsigned int i = 0; i < m_savedVarPath.size(); ++i) + auto path = std::string(); + for (unsigned int i = 0; i < _savedVarPath.size(); ++i) { - auto key = m_savedVarPath[i]; + auto key = _savedVarPath[i]; if (std::holds_alternative(key)) { path += "[" + std::to_string(std::get(key)) + "]"; @@ -635,9 +656,13 @@ std::string LogicHandler::GetRequestedPath() const { auto part = std::get(key); if (i > 0) + { path += "." + part; + } else + { path += part; + } } } @@ -647,15 +672,15 @@ std::string LogicHandler::GetRequestedPath() const // Used when saving. void LogicHandler::GetVariables(std::vector& vars) { - sol::table tab{ *m_handler.GetState(), sol::create }; - tab[ScriptReserved_LevelVars] = (*m_handler.GetState())[ScriptReserved_LevelVars]; - tab[ScriptReserved_GameVars] = (*m_handler.GetState())[ScriptReserved_GameVars]; + auto tab = sol::table(*_handler.GetState(), sol::create); + tab[ScriptReserved_LevelVars] = (*_handler.GetState())[ScriptReserved_LevelVars]; + tab[ScriptReserved_GameVars] = (*_handler.GetState())[ScriptReserved_GameVars]; - std::unordered_map varsMap; - std::unordered_map numMap; - std::unordered_map boolMap; + auto varsMap = std::unordered_map{}; + auto numMap = std::unordered_map{}; + auto boolMap = std::unordered_map{}; - size_t numVars = 0; + size_t varCount = 0; // The following functions will all try to put their values in a map. If it succeeds // then the value was not already in the map, so we can put it into the var vector. @@ -667,12 +692,12 @@ void LogicHandler::GetVariables(std::vector& vars) auto handleNum = [&](auto num, auto map) { - auto [first, second] = map.insert(std::make_pair(num, (int)numVars)); + auto [first, second] = map.insert(std::make_pair(num, (int)varCount)); if (second) { vars.push_back(num); - ++numVars; + ++varCount; } return first->second; @@ -681,12 +706,12 @@ void LogicHandler::GetVariables(std::vector& vars) auto handleStr = [&](const sol::object& obj) { auto str = obj.as(); - auto [first, second] = varsMap.insert(std::make_pair(str.data(), (int)numVars)); + auto [first, second] = varsMap.insert(std::make_pair(str.data(), (int)varCount)); if (second) { vars.push_back(std::string{ str.data() }); - ++numVars; + ++varCount; } return first->second; @@ -694,12 +719,12 @@ void LogicHandler::GetVariables(std::vector& vars) auto handleFuncName = [&](const LevelFunc& fnh) { - auto [first, second] = varsMap.insert(std::make_pair(&fnh, (int)numVars)); + auto [first, second] = varsMap.insert(std::make_pair(&fnh, (int)varCount)); if (second) { vars.push_back(FuncName{ std::string{ fnh.m_funcName } }); - ++numVars; + ++varCount; } return first->second; @@ -707,11 +732,11 @@ void LogicHandler::GetVariables(std::vector& vars) std::function populate = [&](const sol::table& obj) { - auto [first, second] = varsMap.insert(std::make_pair(obj.pointer(), (int)numVars)); + auto [first, second] = varsMap.insert(std::make_pair(obj.pointer(), (int)varCount)); if(second) { - ++numVars; + ++varCount; auto id = first->second; vars.push_back(IndexTable{}); @@ -729,7 +754,7 @@ void LogicHandler::GetVariables(std::vector& vars) { keyIndex = handleStr(first); key = std::string{ first.as().data() }; - m_savedVarPath.push_back(key); + _savedVarPath.push_back(key); } break; @@ -744,7 +769,7 @@ void LogicHandler::GetVariables(std::vector& vars) { keyIndex = handleNum(data, numMap); key = static_cast(data); - m_savedVarPath.push_back(key); + _savedVarPath.push_back(key); } } break; @@ -784,23 +809,23 @@ void LogicHandler::GetVariables(std::vector& vars) { if (second.is()) { - putInVars(Handle(second.as(), varsMap, numVars, vars)); + putInVars(Handle(second.as(), varsMap, varCount, vars)); } else if (second.is()) { - putInVars(Handle(second.as(), varsMap, numVars, vars)); + putInVars(Handle(second.as(), varsMap, varCount, vars)); } else if (second.is()) { - putInVars(Handle(second.as(), varsMap, numVars, vars)); + putInVars(Handle(second.as(), varsMap, varCount, vars)); } else if (second.is
                                                      CustomBarThis module provides functions for creating and managing custom progress bars.
                                                      DiaryDiaries: - The module provides functions to create and manage Diaries.This module provides functions to create and manage diaries.
                                                      EventSequence