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 7bff5eeb4..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,4 +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 -- Stranger1992 (This website, Facebook, Instagram, Youtube, Twitter, and Twitch. +- Stranger1992 (Tomb Engine website, Discord, Facebook, Instagram, Youtube, X, and Twitch) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc186b41..d0beb91c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,22 +5,32 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ## [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 splash effects remaining in the level after reloading from the savegame. * 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. -* Fixed distorted knee and elbow joint vertices. -* Fixed HK sound effects. - -### New features -* Added muzzle glow effect for firearms. +* Fixed static meshes not interpolating when dynamically changing their positional data. +* Fixed crashes when shooting, if gunflash or gunshell objects are not present in a level. +* Fixed crashes when Lara is on a vehicle unreachable by friendly NPCs. +* 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 diff --git a/Documentation/config.ld b/Documentation/config.ld index 6a3876d25..c16aa6c57 100644 --- a/Documentation/config.ld +++ b/Documentation/config.ld @@ -12,7 +12,7 @@ new_type("luautil", "5 Lua utility modules", true) not_luadoc = true -local version = "1.8.1" +local version = "1.8.2" project = " TombEngine" title = "TombEngine " .. version .. " Lua API" description = "TombEngine " .. version .. " scripting interface" diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html index b8726289c..bafc35aa1 100644 --- a/Documentation/doc/1 modules/Effects.html +++ b/Documentation/doc/1 modules/Effects.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -124,19 +124,19 @@

Functions

- + - + - + - + @@ -148,7 +148,7 @@ - + @@ -156,15 +156,15 @@ - + - + - + @@ -193,7 +193,7 @@
- EmitLightningArc(origin, target, color, life, amplitude, beamWidth, detail, smooth, endDrift) + EmitLightningArc(origin, target, [color.], [life], [amplitude], [beamWidth], [detail], [smooth], [endDrift])
Emit a lightning arc. @@ -214,33 +214,42 @@ -
  • color +
  • color. Color - (default Color(255, 255, 255)) + + + + Default: Color(255, 255, 255).
  • life float - Lifetime in seconds. Clamped to [0, 4.233] for now because of strange internal maths. default: 1 + Lifetime in seconds. Clamped to [0, 4.233] for now because of strange internal maths. + Default: 1.
  • amplitude int - "strength" of the lightning - the higher the value, the "taller" the arcs. Clamped to [1, 255]. default: 20 + Strength of the lightning - the higher the value, the "taller" the arcs. Clamped to [1, 255]. + Default: 20.
  • beamWidth int - Clamped to [1, 127]. default 2 + Beam width. Clamped to [1, 127]. + Default: 2.
  • detail int - Higher numbers equal more segments, but it's not a 1:1 correlation. Clamped to [1, 127]. default: 10 + Higher numbers equal more segments, but it's not a 1:1 correlation. Clamped to [1, 127]. + Default: 10.
  • smooth bool - If true, the arc will have large, smooth curves; if false, it will have small, jagged spikes. default: false + If true, the arc will have large, smooth curves; if false, it will have small, jagged spikes. + Default: false.
  • endDrift bool - If true, the end of the arc will be able to gradually drift away from its destination in a random direction default: false + If true, the end of the arc will be able to gradually drift away from its destination in a random direction. + Default: false.
  • @@ -251,7 +260,7 @@
    - EmitParticle(pos, vel, spriteID, gravity, rotVel, startColor, endColor, blendMode, startSize, endSize, life, damage, poison, spriteSeqID, startRot) + EmitParticle(pos, vel, spriteID, [gravity], [rotVel], [startColor], [endColor], [blendMode], [startSize], [endSize], [life], [damage], [poison], [spriteSeqID], [startRot])
    Emit a particle. @@ -274,51 +283,63 @@
  • gravity float - Effect of gravity. Positive value ascends, negative value descends. default: 0 + Effect of gravity. Positive value ascends, negative value descends. + Default: 0.
  • rotVel float - Rotational velocity in degrees. default: 0 + Rotational velocity in degrees. + Default: 0.
  • startColor Color - Color at start of life. default: Color(255, 255, 255) + Color at start of life. + Default: Color(255, 255, 255).
  • endColor Color - Color at end of life. This will finish long before the end of the particle's life due to internal math. default: Color(255, 255, 255) + Color at end of life. This will finish long before the end of the particle's life due to internal math. + Default: Color(255, 255, 255).
  • blendMode BlendID - Render blend mode. TEN.Effects.BlendID.ALPHA_BLEND + Render blend mode. + Default: TEN.Effects.BlendID.ALPHA_BLEND.
  • startSize float - Size at start of life. default: 10 + Size at start of life. + Default: 10.
  • endSize float - Size at end of life. default: 0 + Size at end of life. + Default: 0.
  • life float - Lifespan in seconds. default: 2 + Lifespan in seconds. + Default: 2.
  • damage bool - Harm the player on collision. default: false + Harm the player on collision. + Default: false.
  • poison bool - Poison the player on collision. default: false + Poison the player on collision. + Default: false.
  • spriteSeqID SpriteConstants - Sprite sequence slot ID. default: Objects.ObjID.DEFAULT_SPRITES + Sprite sequence slot ID. + Default: Objects.ObjID.DEFAULT_SPRITES.
  • startRot float - Rotation at start of life. default: random + Rotation at start of life. + Default: random.
  • @@ -348,7 +369,7 @@
    - EmitAdvancedParticle(ParticleData) + EmitAdvancedParticle(particleData)
    Emit a particle with extensive configuration options, including sprite sequence animation, lights, sounds, and damage effects. @@ -357,7 +378,7 @@

    Parameters:

    - 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. @@ -415,35 +436,42 @@ EmitAdvancedParticle(particle) @@ -470,22 +498,22 @@ EmitAdvancedParticle(particle)
  • 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) + If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). Optional.
  • @@ -517,32 +545,32 @@ EmitAdvancedParticle(particle)
  • 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) + If provided, engine will interpolate this light for high framerate mode (be careful not to use same name for different lights). Optional.
  • @@ -554,7 +582,7 @@ EmitAdvancedParticle(particle)
    - EmitBlood(pos, count) + EmitBlood(pos, [count])
    Emit blood. @@ -571,7 +599,8 @@ EmitAdvancedParticle(particle)
  • count int - Sprite count. default: 1 + Sprite count. + Default: 1.
  • @@ -597,13 +626,13 @@ EmitAdvancedParticle(particle)
  • size float - Sprite size. Default: 32 - Optional. + Sprite size. + Default: 32.
  • amp float - Oscillation amplitude. Default: 32 - Optional. + Oscillation amplitude. + Default: 32.
  • @@ -614,7 +643,7 @@ EmitAdvancedParticle(particle)
    - 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. @@ -625,13 +654,12 @@ EmitAdvancedParticle(particle) @@ -642,7 +670,7 @@ EmitAdvancedParticle(particle)
    - MakeExplosion(pos, size, shockwave) + MakeExplosion(pos, [size], [shockwave])
    Make an explosion. Does not hurt Lara @@ -659,11 +687,13 @@ EmitAdvancedParticle(particle)
  • 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.
  • @@ -674,7 +704,7 @@ EmitAdvancedParticle(particle)
    - MakeEarthquake(strength) + MakeEarthquake([strength])
    Make an earthquake @@ -685,7 +715,8 @@ EmitAdvancedParticle(particle) @@ -732,8 +763,8 @@ EmitAdvancedParticle(particle) Moveable object with which to associate the effect.
  • tag - int[opt] - Numeric tag with which to associate the effect on the moveable. Default: 0 + int + Numeric tag with which to associate the effect on the moveable.
  • pos Vec3 @@ -745,58 +776,58 @@ EmitAdvancedParticle(particle)
  • rot float - Start rotation in degrees. Default: 0 - Optional. + Start rotation in degrees. + Default: 0.
  • startColor Color - Color at the start of life. Default: Color(255, 255, 255, 255)) - Optional. + Color at the start of life. + Default: Color(255, 255, 255).
  • endColor Color - Color at the end of life. Default: Color(0, 0, 0, 0)) - Optional. + Color at the end of life. + Default: Color(0, 0, 0).
  • width float - Width in world units. Default: 0 - Optional. + Width in world units. + Default: 0.
  • life float - Lifetime in seconds. Default: 1 - Optional. + Lifetime in seconds. + Default: 1.
  • vel float - Movement velocity in world units per second. Default: 0 - Optional. + Movement velocity in world units per second. + Default: 0.
  • expRate float - Width expansion rate in world units per second. Default: 0 - Optional. + Width expansion rate in world units per second. + Default: 0.
  • rotRate float - Rotation rate in degrees per second. Default: 0 - Optional. + Rotation rate in degrees per second. + Default: 0.
  • edgeFeatherMode StreamerFeatherMode - Edge feather mode. Default: Effects.StreamerFeatherMode.NONE - Optional. + Edge feather mode. + Default: Effects.StreamerFeatherMode.NONE.
  • lengthFeatherMode StreamerFeatherMode - Length feather mode. UNIMPLEMENTED, currently will always leave a fading tail - Optional. + Length feather mode. Not yet implemented. + Default: Effects.StreamerFeatherMode.LEFT.
  • blendID BlendID - Renderer blend ID. Default: Effects.BlendID.ALPHA_BLEND - Optional. + Renderer blend ID. + Default: Effects.BlendID.ALPHA_BLEND.
  • @@ -830,128 +861,128 @@ EmitAdvancedParticle(particle)
  • spriteSeqID SpriteConstants - Sprite sequence slot ID. default: Objects.ObjID.DEFAULT_SPRITES - Optional. + Sprite sequence slot ID. + Default: Objects.ObjID.DEFAULT_SPRITES.
  • spriteID int - Sprite ID in the sprite sequence slot. default: 0 - Optional. + Sprite ID in the sprite sequence slot. + Default: 0.
  • life float - Lifespan in seconds. default: 2 - Optional. + Lifespan in seconds. + Default: 2.
  • maxYVel float - Maximum vertical velocity in world units per second. default: 0 - Optional. + 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 - Optional. + 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 - Optional. + Friction affecting velocity over time in world units per second. + Default: 0.
  • startRot float - Rotation at start of life. default: random - Optional. + Rotation at start of life. + Default: random.
  • rotVel float - Rotational velocity in degrees per second. default: 0 - Optional. + Rotational velocity in degrees per second. + Default: 0.
  • startSize float - Size at start of life. default: 10 - Optional. + Size at start of life. + Default: 10.
  • endSize float - Size at end of life. default: 0 - Optional. + Size at end of life. + Default: 0.
  • startColor Color - Color at start of life. default: Color(255, 255, 255) - Optional. + 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) - Optional. + 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 - Optional. + Render blend mode. + Default: TEN.Effects.BlendID.ALPHA_BLEND.
  • damage bool - Harm the player on collision. default: false - Optional. + Harm the player on collision. + Default: false.
  • poison bool - Poison the player on collision. default: false - Optional. + Poison the player on collision. + Default: false.
  • burn bool - Burn the player on collision. default: false - Optional. + Burn the player on collision. + Default: false.
  • wind bool - Affect position by wind in outside rooms. default: false - Optional. + Affect position by wind in outside rooms. + Default: false.
  • damageHit int - Player damage amount on collision. default: 2 - Optional. + 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 - Optional. + 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 - Optional. + Light radius in 1/4 blocks. + Default: 0.
  • lightFlicker int - Interval at which the light should flicker. default: 0 - Optional. + 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. default: none + 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 - Optional. + Play animates sprite sequence. + Default: false.
  • animType ParticleAnimationType - Animation type of the sprite sequence. default: TEN.Effects.ParticleAnimationType.LOOP - Optional. + Animation type of the sprite sequence. + Default: TEN.Effects.ParticleAnimationType.LOOP.
  • frameRate float - Sprite sequence animation framerate. default: 1 - Optional. + Sprite sequence animation framerate. + Default: 1.
  • diff --git a/Documentation/doc/1 modules/Flow.html b/Documentation/doc/1 modules/Flow.html index 4a680cba5..0f6720dc5 100644 --- a/Documentation/doc/1 modules/Flow.html +++ b/Documentation/doc/1 modules/Flow.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -132,6 +132,10 @@ scripts too.

    + + + + @@ -179,11 +183,11 @@ scripts too.

    - + - + @@ -261,11 +265,11 @@ scripts too.

    - + - + @@ -299,7 +303,7 @@ ambient tracks. @@ -313,8 +317,7 @@ ambient tracks. SetIntroImagePath(path)
    - 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. @@ -322,7 +325,29 @@ Must be a .jpg or .png image. + + + + + +
    +
    + + SetIntroVideoPath(path) +
    +
    + Video to show when loading the game. Must be a common video format, such as mp4, mkv, mov or avi. + + + +

    Parameters:

    + @@ -336,9 +361,7 @@ Must be a .jpg or .png image. SetTitleScreenImagePath(path)
    - Image to show in the background of the title screen. -Must be a .jpg or .png image. -(not yet implemented) + Image to show in the background of the title screen. Must be a .jpg or .png image. Not yet implemented. @@ -346,7 +369,7 @@ Must be a .jpg or .png image. @@ -369,7 +392,7 @@ Must be true or false @@ -392,7 +415,7 @@ Must be true or false @@ -406,7 +429,7 @@ Must be true or false EnableHomeLevel(enabled)
    - Enable or disable Home Level entry in the main menu. () + Enable or disable Home Level entry in the main menu. @@ -428,7 +451,7 @@ Must be true or false EnableLoadSave(enabled)
    - Enable or disable saving and loading of savegames. () + Enable or disable saving and loading of savegames. @@ -454,7 +477,7 @@ Must be true or false EnableFlyCheat(enabled)
    - Enable or disable the fly cheat. () + Enable or disable the fly cheat. @@ -485,7 +508,7 @@ Must be true or false @@ -508,7 +531,7 @@ Must be true or false @@ -524,7 +547,7 @@ Must be true or false
    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. @@ -532,7 +555,7 @@ have an ID of 0, the second an ID of 1, and so on. @@ -540,7 +563,7 @@ have an ID of 0, the second an ID of 1, and so on.
      Level - the level indicated by the id + The level indicated by the index.
    @@ -561,7 +584,7 @@ have an ID of 0, the second an ID of 1, and so on.
      Level - the current level + The current level.
    @@ -584,13 +607,13 @@ teleported to such object with OCB similar to provided second argument. @@ -601,7 +624,7 @@ teleported to such object with OCB similar to provided second argument.
    - GetStatistics(game) + GetStatistics([game])
    Get game or level statistics. For reference about statistics class, see Flow.Statistics. @@ -612,7 +635,8 @@ teleported to such object with OCB similar to provided second argument. @@ -620,7 +644,7 @@ teleported to such object with OCB similar to provided second argument.
      Statistics - statistics structure representing game or level statistics + Statistics structure representing game or level statistics.
    @@ -629,7 +653,7 @@ teleported to such object with OCB similar to provided second argument.
    - SetStatistics(statistics, game) + SetStatistics(statistics, [game])
    Set game or level statistics. For reference about statistics class, see Flow.Statistics. @@ -640,11 +664,12 @@ teleported to such object with OCB similar to provided second argument. @@ -667,7 +692,7 @@ teleported to such object with OCB similar to provided second argument.
      GameStatus - the current game status + The current game status.
    @@ -688,7 +713,7 @@ teleported to such object with OCB similar to provided second argument.
      FreezeMode - the current freeze mode + The current freeze mode.
    @@ -710,7 +735,7 @@ custom menu creation, photo mode or time freeze. @@ -847,7 +872,7 @@ custom menu creation, photo mode or time freeze. @@ -870,7 +895,7 @@ The index argument corresponds to the secret's unique ID, the same that would go @@ -994,7 +1019,7 @@ Must be an integer value (0 means no secrets). @@ -1017,7 +1042,7 @@ Must be an integer value (0 means no secrets).
      Settings - current settings table + Current settings table.
    @@ -1029,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.
    @@ -1045,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.
    @@ -1057,7 +1081,7 @@ You will not need to call them manually.
    - GetString(string) + GetString(key)
    Get translated string. @@ -1066,9 +1090,9 @@ You will not need to call them manually.

    Parameters:

    @@ -1079,7 +1103,7 @@ You will not need to call them manually.
    - IsStringPresent(string) + IsStringPresent(key)
    Check if translated string is present. @@ -1088,9 +1112,9 @@ You will not need to call them manually.

    Parameters:

    @@ -1112,8 +1136,8 @@ Specify which translations in the strings table correspond to which languages.

    Parameters:

    diff --git a/Documentation/doc/1 modules/Input.html b/Documentation/doc/1 modules/Input.html index 7cf9f7de0..db47196cd 100644 --- a/Documentation/doc/1 modules/Input.html +++ b/Documentation/doc/1 modules/Input.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -295,7 +295,7 @@ GetMouseDisplayPosition()
    - Get the display position of the cursor in percent. () + Get the display position of the cursor in percent. diff --git a/Documentation/doc/1 modules/Inventory.html b/Documentation/doc/1 modules/Inventory.html index 1c069126b..3d2e89db6 100644 --- a/Documentation/doc/1 modules/Inventory.html +++ b/Documentation/doc/1 modules/Inventory.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/1 modules/Logic.html b/Documentation/doc/1 modules/Logic.html index dff8277a1..a30ea0bda 100644 --- a/Documentation/doc/1 modules/Logic.html +++ b/Documentation/doc/1 modules/Logic.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -132,7 +132,7 @@
    - + @@ -148,7 +148,7 @@
    EmitLightningArc(origin, target, color, life, amplitude, beamWidth, detail, smooth, endDrift)EmitLightningArc(origin, target, [color.], [life], [amplitude], [beamWidth], [detail], [smooth], [endDrift]) Emit a lightning arc.
    EmitParticle(pos, vel, spriteID, gravity, rotVel, startColor, endColor, blendMode, startSize, endSize, life, damage, poison, spriteSeqID, startRot)EmitParticle(pos, vel, spriteID, [gravity], [rotVel], [startColor], [endColor], [blendMode], [startSize], [endSize], [life], [damage], [poison], [spriteSeqID], [startRot]) Emit a particle.
    EmitAdvancedParticle(ParticleData)EmitAdvancedParticle(particleData) Emit a particle with extensive configuration options, including sprite sequence animation, lights, sounds, and damage effects.
    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.
    Emit dynamic directional spotlight that lasts for a single frame.
    EmitBlood(pos, count)EmitBlood(pos, [count]) Emit blood.
    Emit an air bubble in a water room.
    EmitFire(pos, size)EmitFire(pos, [size]) Emit fire for one frame.
    MakeExplosion(pos, size, shockwave)MakeExplosion(pos, [size], [shockwave]) Make an explosion.
    MakeEarthquake(strength)MakeEarthquake([strength]) Make an earthquake
    Image to show when loading the game.
    SetIntroVideoPath(path)Video to show when loading the game.
    SetTitleScreenImagePath(path) Image to show in the background of the title screen.
    Finishes the current level, with optional level index and start position index provided.
    GetStatistics(game)GetStatistics([game]) Get game or level statistics.
    SetStatistics(statistics, game)SetStatistics(statistics, [game]) Set game or level statistics.
    Set string variable keys and their translations.
    GetString(string)GetString(key) Get translated string.
    IsStringPresent(string)IsStringPresent(key) Check if translated string is present.
    Deregister a function as a callback.
    HandleEvent(name, type, activator)HandleEvent(name, type, [activator]) Attempt to find an event set and execute a particular event from it.
    - +
    LaraA Objects.Moveable representing Lara herself.An Objects.Moveable entry representing Lara herself.

    Special tables

    @@ -272,7 +272,7 @@ Will have no effect if the function was not registered as a callback
    - HandleEvent(name, type, activator) + HandleEvent(name, type, [activator])
    Attempt to find an event set and execute a particular event from it. @@ -302,7 +302,8 @@ MENU
  • activator Moveable - Optional activator. Default is the player object. + Optional activator. + Default: Lara.
  • @@ -372,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 06d84e7c1..eee82fbf8 100644 --- a/Documentation/doc/1 modules/Objects.html +++ b/Documentation/doc/1 modules/Objects.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -189,14 +189,14 @@

    Returns:

      - Moveable + Moveable a non-owning Moveable referencing the item.
    @@ -217,15 +217,15 @@

    Returns:

      - Static - a non-owning Static referencing the mesh. + Static + a non-owning Static referencing the static mesh.
    @@ -245,7 +245,7 @@ @@ -253,7 +253,7 @@
      table - table of Moveables referencing the given slot. + Table of moveables referencing the given slot.
    @@ -273,7 +273,7 @@ @@ -281,7 +281,7 @@
      table - table of Statics referencing the given slot ID. + Table of static meshes referencing the given slot.
    @@ -301,7 +301,7 @@ @@ -309,7 +309,7 @@
      table - table of Rooms containing the given tag. + Table of rooms containing the given tag.
    @@ -329,15 +329,15 @@

    Returns:

      - Camera - a non-owning Camera referencing the camera. + Camera + A non-owning Camera referencing the camera.
    @@ -357,15 +357,15 @@

    Returns:

      - Sink - a non-owning Sink referencing the sink. + Sink + A non-owning Sink referencing the sink.
    @@ -385,15 +385,15 @@

    Returns:

      - SoundSource - a non-owning SoundSource referencing the sound source. + SoundSource + A non-owning SoundSource referencing the sound source.
    @@ -413,15 +413,15 @@

    Returns:

      - AIObject - a non-owning SoundSource referencing the AI moveable. + AIObject + A non-owning AIObject referencing the AI object.
    @@ -441,15 +441,15 @@

    Returns:

      - Volume - a non-owning Volume referencing the room. + Volume + A non-owning Volume referencing the volume.
    @@ -469,15 +469,15 @@

    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 be07997d5..74b9aa3da 100644 --- a/Documentation/doc/1 modules/Sound.html +++ b/Documentation/doc/1 modules/Sound.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -156,7 +156,7 @@ Check if the sound effect is playing. - IsAudioTrackPlaying(Track) + IsAudioTrackPlaying(track) Check if the audio track is playing. @@ -177,7 +177,7 @@ PlayAudioTrack(filename, type)
    - Play an audio track. Supported formats are wav, mp3 and ogg. + Play an audio track. Should be placed in the Audio folder. Supported formats are wav, mp3 and ogg. @@ -362,7 +362,7 @@
    - IsAudioTrackPlaying(Track) + IsAudioTrackPlaying(track)
    Check if the audio track is playing. @@ -371,7 +371,7 @@

    Parameters:

    @@ -386,7 +385,7 @@ To be used with - PickStaticByDisplayPosition(Display) + PickStaticByDisplayPosition(position)
    Pick a static mesh by the given display position. @@ -395,9 +394,9 @@ To be used with Display +
  • position Vec2 - space position in percent. + Display space position in percent.
  • @@ -414,7 +413,7 @@ To be used with - PrintLog(message, logLevel, [allowSpam]) + PrintLog(Message, logLevel, [allowSpam])
    Write messages within the Log file @@ -428,17 +427,17 @@ 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 + 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 51c5b824e..f30980297 100644 --- a/Documentation/doc/1 modules/View.html +++ b/Documentation/doc/1 modules/View.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -124,15 +124,15 @@

    Functions

    - + - + - + @@ -164,7 +164,7 @@ - + @@ -172,6 +172,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -188,7 +212,7 @@ - + @@ -206,7 +230,7 @@
    - FadeIn(speed) + FadeIn([speed])
    Do a full-screen fade-in from black. @@ -217,7 +241,8 @@
    • speed float - (default 1.0). Speed in units 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.
    @@ -228,7 +253,7 @@
    - FadeOut(speed) + FadeOut([speed])
    Do a full-screen fade-to-black. The screen will remain black until a call to FadeIn. @@ -239,7 +264,8 @@
    • speed float - (default 1.0). Speed in units 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.
    @@ -250,7 +276,7 @@
    - SetCineBars(height, speed) + SetCineBars([height], [speed])
    Move black cinematic bars in from the top and bottom of the game window. @@ -261,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.
    @@ -287,7 +315,7 @@
    • angle float - in degrees (clamped to [10, 170]) + Angle in degrees (clamped to [10, 170]).
    @@ -310,7 +338,7 @@
      float - current FOV angle in degrees + Current FOV angle in degrees.
    @@ -331,7 +359,7 @@
      CameraType - value used by the Main Camera. + Value used by the game camera.
    @@ -360,7 +388,7 @@
      Vec3 - current camera position + Current camera position.
    @@ -381,7 +409,7 @@
      Vec3 - current camera target + Current camera target.
    @@ -402,7 +430,7 @@
      Room - current room of the camera + Current room of the camera.
    @@ -422,7 +450,7 @@ @@ -433,7 +461,7 @@
    - SetPostProcessStrength(strength) + SetPostProcessStrength([strength])
    Sets the post-process effect strength. @@ -444,7 +472,8 @@
    • strength float - (default 1.0). How strong the effect is. + How strong the effect is. + Default: 1.
    @@ -474,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. +
    + + + +
    @@ -588,7 +763,7 @@
    - FlashScreen(color, speed) + FlashScreen([color], [speed])
    Flash screen. @@ -599,11 +774,13 @@
    • color Color - (default Color(255, 255, 255)) + Color. + Default: Color(255, 255, 255).
    • speed float - (default 1.0). Speed in units 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 f10d87d34..662726038 100644 --- a/Documentation/doc/2 classes/Collision.Probe.html +++ b/Documentation/doc/2 classes/Collision.Probe.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/2 classes/Flow.Level.html b/Documentation/doc/2 classes/Flow.Level.html index c7c23ab6b..f37dc3fb6 100644 --- a/Documentation/doc/2 classes/Flow.Level.html +++ b/Documentation/doc/2 classes/Flow.Level.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -123,7 +123,7 @@
    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.
    Reset object camera back to Lara and deactivate object camera.
    FlashScreen(color, speed)FlashScreen([color], [speed]) Flash screen.
    - + @@ -139,7 +139,7 @@ - + @@ -151,11 +151,11 @@ - + - + @@ -183,7 +183,7 @@ - + @@ -226,8 +226,7 @@ nameKey
    - (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. @@ -243,7 +242,7 @@
    (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. @@ -275,7 +274,7 @@
    (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. @@ -290,7 +289,7 @@ ambientTrack
    - (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. @@ -336,7 +335,7 @@ horizon1
    - (Flow.Horizon) First horizon layer. + (Flow.Horizon) Primary horizon object. @@ -351,7 +350,7 @@ horizon2
    - (Flow.Horizon) Second horizon layer. + (Flow.Horizon) Secondary horizon object. @@ -413,7 +412,7 @@
    (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. @@ -460,20 +459,9 @@ laraType
    - (LaraType) Must be one of the LaraType values. -These are:

    - -
    Normal
    -Young
    -Bunhead
    -Catsuit
    -Divesuit
    -Invisible
    -
    - -

    e.g. myLevel.laraType = LaraType.Divesuit

    - -

    Not yet fully implemented. Only types Normal and Young are guaranteed to work. + (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. diff --git a/Documentation/doc/2 classes/Flow.Settings.html b/Documentation/doc/2 classes/Flow.Settings.html index c59098a2a..58217bcd9 100644 --- a/Documentation/doc/2 classes/Flow.Settings.html +++ b/Documentation/doc/2 classes/Flow.Settings.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -350,7 +350,7 @@

    @@ -371,7 +371,7 @@ @@ -392,7 +392,7 @@ @@ -413,7 +413,7 @@ @@ -434,7 +434,7 @@ @@ -455,7 +455,7 @@ @@ -483,7 +483,7 @@ @@ -504,7 +504,7 @@ @@ -525,7 +525,7 @@ @@ -553,7 +553,7 @@ @@ -574,7 +574,7 @@ @@ -595,7 +595,7 @@ @@ -616,7 +616,7 @@ @@ -637,7 +637,7 @@ @@ -658,7 +658,7 @@ @@ -679,7 +679,7 @@ @@ -700,7 +700,7 @@ @@ -721,7 +721,7 @@ @@ -751,7 +751,7 @@ @@ -772,7 +772,7 @@ @@ -793,7 +793,7 @@ @@ -821,7 +821,7 @@ @@ -842,7 +842,7 @@ @@ -863,7 +863,7 @@ @@ -884,7 +884,7 @@ @@ -912,7 +912,7 @@ @@ -933,7 +933,7 @@ @@ -962,7 +962,7 @@ @@ -983,7 +983,7 @@ @@ -1004,7 +1004,7 @@ @@ -1025,7 +1025,7 @@ @@ -1046,7 +1046,7 @@ @@ -1067,7 +1067,7 @@ @@ -1088,7 +1088,7 @@ @@ -1109,7 +1109,7 @@ @@ -1130,7 +1130,7 @@ @@ -1151,7 +1151,7 @@ @@ -1172,7 +1172,7 @@ @@ -1193,7 +1193,7 @@ @@ -1214,7 +1214,7 @@ @@ -1235,7 +1235,7 @@ @@ -1256,7 +1256,7 @@ @@ -1277,7 +1277,7 @@ @@ -1305,7 +1305,7 @@ @@ -1328,7 +1328,7 @@ @@ -1352,7 +1352,7 @@ diff --git a/Documentation/doc/2 classes/Flow.Statistics.html b/Documentation/doc/2 classes/Flow.Statistics.html index 9cc173115..1af7cd652 100644 --- a/Documentation/doc/2 classes/Flow.Statistics.html +++ b/Documentation/doc/2 classes/Flow.Statistics.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -178,7 +178,7 @@ @@ -199,7 +199,7 @@ @@ -220,7 +220,7 @@ @@ -241,7 +241,7 @@ @@ -262,7 +262,7 @@ @@ -283,7 +283,7 @@ @@ -304,7 +304,7 @@ @@ -325,7 +325,7 @@ @@ -346,7 +346,7 @@ diff --git a/Documentation/doc/2 classes/Objects.AIObject.html b/Documentation/doc/2 classes/Objects.AIObject.html index 0122971a9..bc58896f4 100644 --- a/Documentation/doc/2 classes/Objects.AIObject.html +++ b/Documentation/doc/2 classes/Objects.AIObject.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -125,11 +125,11 @@
    nameKey(string) string key for the level's (localised) name.(string) String key for the level's name.
    scriptFile
    ambientTrack(string) initial ambient sound track to play.(string) Initial ambient sound track to play.
    layer1
    horizon1(Flow.Horizon) First horizon layer.(Flow.Horizon) Primary horizon object.
    horizon2(Flow.Horizon) Second horizon layer.(Flow.Horizon) Secondary horizon object.
    starfield
    laraType(LaraType) Must be one of the LaraType values.(LaraType) Appearance of Lara.
    rumble
    - + - + @@ -141,32 +141,31 @@ - + - + - + - + - + - + - +
    AIObject:GetPosition()Get the object's positionGet the object's position.
    AIObject:SetPosition(position)Set the object's positionSet the object's position.
    AIObject:GetRotationY()
    AIObject:GetName()Get the object's unique string identifierGet the object's unique string identifier.
    AIObject:SetName(name)Set the object's name (its unique string identifier)Set the object's unique string identifier.
    AIObject:GetRoom()Get the current room of the objectGet the current room of the object.
    AIObject:GetRoomNumber()Get the current room number of the objectGet the current room number of the object.
    AIObject:SetRoomNumber(ID)Set room number of the object - This is used in conjunction with SetPosition to teleport the object to a new room.Set room number of the object.
    AIObject:GetObjectID()Retrieve the object IDRetrieve the object ID.
    AIObject:SetObjectID(ID)Change the object's ID.Change the object ID.
    @@ -182,7 +181,7 @@ AIObject:GetPosition()
    - Get the object's position + Get the object's position. @@ -191,7 +190,7 @@
      Vec3 - a copy of the object's position + A copy of the object's position.
    @@ -203,7 +202,7 @@ AIObject:SetPosition(position)
    - Set the object's position + Set the object's position. @@ -211,7 +210,7 @@ @@ -226,7 +225,6 @@
    Get the object's Y-axis rotation. - To the best of my knowledge, the rotation of an AIObject has no effect. @@ -234,8 +232,8 @@

    Returns:

      - number - the object's Y-axis rotation + int + The object's Y-axis rotation.
    @@ -248,15 +246,14 @@
    Set the object's Y-axis rotation. - To the best of my knowledge, the rotation of an AIObject has no effect.

    Parameters:

    @@ -270,7 +267,7 @@ AIObject:GetName()
    - Get the object's unique string identifier + Get the object's unique string identifier. @@ -279,7 +276,7 @@
      string - the object's name + The object's name.
    @@ -291,7 +288,7 @@ AIObject:SetName(name)
    - Set the object's name (its unique string identifier) + Set the object's unique string identifier. @@ -299,7 +296,7 @@ @@ -313,7 +310,7 @@ AIObject:GetRoom()
    - Get the current room of the object + Get the current room of the object. @@ -321,8 +318,8 @@

    Returns:

      - Room - current room of the object + Room + current room of the object.
    @@ -334,7 +331,7 @@ AIObject:GetRoomNumber()
    - Get the current room number of the object + Get the current room number of the object. @@ -343,7 +340,7 @@
      int - number representing the current room of the object + Number representing the current room of the object.
    @@ -355,7 +352,7 @@ AIObject:SetRoomNumber(ID)
    - Set room number of the object + Set room number of the object. This is used in conjunction with SetPosition to teleport the object to a new room. @@ -364,7 +361,7 @@ @@ -378,7 +375,7 @@ AIObject:GetObjectID()
    - Retrieve the object ID + Retrieve the object ID. @@ -387,7 +384,7 @@
      int - a number representing the ID of the object + A number representing the ID of the object.
    @@ -399,7 +396,7 @@ AIObject:SetObjectID(ID)
    - Change the object's ID. This will change the type of AI object it is. + Change the object ID. This will change the type of AI object it is. Note that a baddy will gain the behaviour of the tile it's on before said baddy is triggered. This means that changing the type of an AI object beneath a moveable will have no effect. Instead, this function can be used to change an object that the baddy isn't standing on. @@ -412,7 +409,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Camera.html b/Documentation/doc/2 classes/Objects.Camera.html index 3ca2f2939..117c69637 100644 --- a/Documentation/doc/2 classes/Objects.Camera.html +++ b/Documentation/doc/2 classes/Objects.Camera.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -125,11 +125,11 @@ - + - + @@ -137,24 +137,23 @@ - + - + - + - + - - + +
    Camera:GetPosition()Get the camera's positionGet the camera's position.
    Camera:SetPosition(position)Set the camera's positionSet the camera's position.
    Camera:GetName()
    Camera:SetName(name)Set the camera's name (its unique string identifier)Set the camera's name (its unique string identifier).
    Camera:GetRoom()Get the current room of the cameraGet the current room of the camera.
    Camera:GetRoomNumber()Get the current room number of the cameraGet the current room number of the camera.
    Camera:SetRoomNumber(ID)Set room of camera - This is used in conjunction with SetPosition to teleport the camera to a new room.Set room of camera.
    Camera:PlayCamera([Target])Active the camera during that frame.Camera:PlayCamera([target])Activate the camera for the current game frame.
    @@ -170,7 +169,7 @@ Camera:GetPosition()
    - Get the camera's position + Get the camera's position. @@ -179,7 +178,7 @@
      Vec3 - a copy of the camera's position + Camera's position.
    @@ -191,7 +190,7 @@ Camera:SetPosition(position)
    - Set the camera's position + Set the camera's position. @@ -199,7 +198,7 @@ @@ -222,7 +221,7 @@
      string - the camera's name + the camera's name.
    @@ -234,7 +233,7 @@ Camera:SetName(name)
    - Set the camera's name (its unique string identifier) + Set the camera's name (its unique string identifier). @@ -242,7 +241,7 @@ @@ -256,7 +255,7 @@ Camera:GetRoom()
    - Get the current room of the camera + Get the current room of the camera. @@ -264,8 +263,8 @@

    Returns:

      - Room - current room of the camera + Room + Current room of the camera.
    @@ -277,7 +276,7 @@ Camera:GetRoomNumber()
    - Get the current room number of the camera + Get the current room number of the camera. @@ -286,7 +285,7 @@
      int - number representing the current room of the camera + Number representing the current room of the camera.
    @@ -298,7 +297,7 @@ Camera:SetRoomNumber(ID)
    - Set room of camera + Set room of camera. This is used in conjunction with SetPosition to teleport the camera to a new room. @@ -307,7 +306,7 @@ @@ -318,17 +317,17 @@
    - Camera:PlayCamera([Target]) + Camera:PlayCamera([target])
    - Active the camera during that frame. + Activate the camera for the current game frame.

    Parameters:

    @@ -1056,7 +1032,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:SetCustomEffect(color1, color2, [timeout])
    - Set custom colored burn effect to moveable + Set custom colored burn effect to moveable. @@ -1087,7 +1063,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:GetEffect()
    - Get current moveable effect + Get current moveable effect. @@ -1108,7 +1084,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:GetItemFlags(index)
    - Get the value stored in ItemFlags[index] + Get the value stored in ItemFlags[index]. @@ -1124,7 +1100,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
      int - the value contained in the ItemFlags[index] + The value contained in the ItemFlags[index].
    @@ -1136,7 +1112,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:SetItemFlags(value, index)
    - Stores a value in ItemFlags[index] + Stores a value in ItemFlags[index]. @@ -1162,7 +1138,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:GetLocationAI()
    - Get the location value stored in the Enemy AI + Get the location value stored in the Enemy AI. @@ -1171,7 +1147,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
      short - the value contained in the LocationAI of the creature. + The value contained in the LocationAI of the creature.
    @@ -1205,7 +1181,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:GetColor()
    - Get the moveable's color + Get the moveable's color. @@ -1214,7 +1190,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
      Color - a copy of the moveable's color + Moveable's color.
    @@ -1226,7 +1202,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:SetColor(color)
    - Set the moveable's color + Set the moveable's color. @@ -1234,7 +1210,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) @@ -1249,9 +1225,9 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
    -

    Get AIBits of object +

    Get AIBits of object. This will return a table with six values, each corresponding to - an active behaviour. If the object is in a certain AI mode, the table will + an active behaviour. If the object is in a certain AI mode, the table will have a 1 in the corresponding cell. Otherwise, the cell will hold a 0.

    @@ -1272,7 +1248,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
      table - a table of AI bits + A table of AI bits.
    @@ -1284,7 +1260,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) Moveable:SetAIBits(bits)
    - Set AIBits of object + Set AIBits of object. Use this to force a moveable into a certain AI mode or modes, as if a certain nullmesh (or more than one) had suddenly spawned beneath their feet. @@ -1294,7 +1270,7 @@ baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided) @@ -1323,7 +1299,7 @@ sas:SetAIBits({1, 0, int - the index of the active state + The index of the active state. @@ -1345,7 +1321,7 @@ sas:SetAIBits({1, 0, int - the index of the target state + The index of the target state. @@ -1367,7 +1343,7 @@ sas:SetAIBits({1, 0,
  • index int - the index of the desired state + The index of the desired state.
  • @@ -1392,7 +1368,7 @@ sas:SetAIBits({1, 0, int - animation slot ID + Animation slot ID. @@ -1414,7 +1390,7 @@ sas:SetAIBits({1, 0, int - the index of the active animation + The index of the active animation. @@ -1436,11 +1412,11 @@ sas:SetAIBits({1, 0,
  • index int - the index of the desired anim + The index of the desired animation.
  • slot int - slot ID of the desired anim (if omitted, moveable's own slot ID is used) + Slot ID of the desired anim (if omitted, moveable's own slot ID is used). Optional.
  • @@ -1465,7 +1441,7 @@ sas:SetAIBits({1, 0, int - the current frame of the active animation + The current frame of the active animation. @@ -1488,7 +1464,7 @@ sas:SetAIBits({1, 0, Vec3 - current object velocity + Current object velocity. @@ -1510,7 +1486,7 @@ sas:SetAIBits({1, 0,
  • velocity Vec3 - velocity represented as vector + Velocity represented as vector.
  • @@ -1536,7 +1512,7 @@ sas:SetAIBits({1, 0,
  • frame int - the new frame number + The new frame number.
  • @@ -1572,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. @@ -1581,7 +1557,7 @@ sas:SetAIBits({1, 0, bool - true if the moveable is active + True if the moveable is active. @@ -1602,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. @@ -1614,7 +1590,7 @@ sas:SetAIBits({1, 0, Moveable:GetRoom()
    - Get the current room of the object + Get the current room of the moveable. @@ -1623,7 +1599,7 @@ sas:SetAIBits({1, 0, Room - current room of the object + Current room of the moveable. @@ -1635,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. @@ -1644,7 +1620,7 @@ sas:SetAIBits({1, 0, int - number representing the current room of the object + Number representing the current room of the moveable. @@ -1728,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 @@ -1738,7 +1714,7 @@ sas:SetPosition(newPos, false)
      int - number of meshes + Number of meshes.
    @@ -1750,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. @@ -1760,7 +1736,7 @@ sas:SetPosition(newPos, false) @@ -1768,7 +1744,7 @@ sas:SetPosition(newPos, false)
      bool - visibility status + Visibility status.
    @@ -1780,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. @@ -1789,11 +1765,11 @@ sas:SetPosition(newPos, false) @@ -1807,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(). @@ -1816,7 +1792,7 @@ sas:SetPosition(newPos, false) @@ -1830,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. @@ -1840,7 +1815,7 @@ sas:SetPosition(newPos, false) @@ -1848,7 +1823,7 @@ sas:SetPosition(newPos, false)
      bool - mesh swap status + Mesh swap status.
    @@ -1860,7 +1835,7 @@ sas:SetPosition(newPos, false) 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. @@ -1869,15 +1844,15 @@ sas:SetPosition(newPos, false) @@ -1892,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 @@ -1901,7 +1876,7 @@ sas:SetPosition(newPos, false) @@ -1912,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. @@ -1923,7 +1898,8 @@ sas:SetPosition(newPos, false) @@ -1937,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. @@ -1992,7 +1968,7 @@ sas:SetPosition(newPos, false)
      bool - item's collision state + Item's collision state.
    @@ -2020,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. @@ -2049,7 +2010,7 @@ sas:SetPosition(newPos, false) @@ -2063,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. @@ -2072,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.
    @@ -2110,7 +2071,7 @@ sas:SetPosition(newPos, false) Mesh of a target moveable to use as a camera target.
  • target - Moveable + Moveable Target moveable to attach camera to.
  • mesh @@ -2129,7 +2090,7 @@ sas:SetPosition(newPos, false) Moveable:AnimFromObject(objectID, animNumber, stateID)
    - Borrow animation from an object + Borrow animation from an object. @@ -2137,7 +2098,7 @@ sas:SetPosition(newPos, false)
    • objectID ObjID - Object ID to take animation and stateID from. + Object ID to take animation and state ID from.
    • animNumber int @@ -2145,7 +2106,7 @@ sas:SetPosition(newPos, false)
    • stateID int - state 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 acc0de38b..d99e4cbf6 100644 --- a/Documentation/doc/2 classes/Objects.Room.html +++ b/Documentation/doc/2 classes/Objects.Room.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/2 classes/Objects.Sink.html b/Documentation/doc/2 classes/Objects.Sink.html index 54ee6f9de..67e467d19 100644 --- a/Documentation/doc/2 classes/Objects.Sink.html +++ b/Documentation/doc/2 classes/Objects.Sink.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/2 classes/Objects.SoundSource.html b/Documentation/doc/2 classes/Objects.SoundSource.html index 6daf287f2..1ff54349a 100644 --- a/Documentation/doc/2 classes/Objects.SoundSource.html +++ b/Documentation/doc/2 classes/Objects.SoundSource.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -125,27 +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 IDSet the sound source's ID.
    @@ -161,7 +161,7 @@ SoundSource:GetPosition()
    - Get the sound source's position + Get the sound source's position. @@ -170,7 +170,7 @@
      Vec3 - a copy of the sound source's position + Sound source's position.
    @@ -182,7 +182,7 @@ SoundSource:SetPosition(position)
    - Set the sound source's position + Set the sound source's position. @@ -190,7 +190,7 @@
    • position Vec3 - the new position of the sound source + The new position of the sound source.
    @@ -204,7 +204,7 @@ SoundSource:GetName()
    - Get the sound source's unique string identifier + Get the sound source's unique string identifier. @@ -213,7 +213,7 @@
      string - the sound source's name + The sound source's name.
    @@ -225,7 +225,7 @@ SoundSource:SetName(name)
    - Set the sound source's name (its unique string identifier) + Set the sound source's unique string identifier. @@ -233,7 +233,7 @@
    • name string - The sound source's new name + The sound source's new name.
    @@ -247,7 +247,7 @@ SoundSource:GetSoundID()
    - Get the sound source's unique int identifier + Get the sound source's sound ID. @@ -256,7 +256,7 @@
      int - the ID of the sound + The ID of the sound.
    @@ -268,7 +268,7 @@ SoundSource:SetSoundID(name)
    - Set the sound source's ID + Set the sound source's ID. @@ -276,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 faa84c20f..0ad8251f4 100644 --- a/Documentation/doc/2 classes/Objects.Static.html +++ b/Documentation/doc/2 classes/Objects.Static.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -381,7 +381,7 @@
      bool - Status. true: visible, false: invisible + Status. true means visible, false otherwise.
    @@ -402,7 +402,7 @@
      bool - Collision status. true: can be collided with, false: no collision + Collision status. true if can be collided with, false otherwise.
    @@ -423,7 +423,7 @@
      bool - Solid Status. true: solid, false: soft + Solid Status. true if solid, false if soft.
    @@ -597,7 +597,7 @@
    • status bool - New status. true: solid, false: soft + New status, true is solid, false is soft.
    @@ -619,7 +619,7 @@
    • collidable bool - New collision status. true: can be collided with, false: no collision + 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 77e6b626a..0a3c41b06 100644 --- a/Documentation/doc/2 classes/Objects.Volume.html +++ b/Documentation/doc/2 classes/Objects.Volume.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -160,7 +160,7 @@ Determine if this volume is active. - Volume:IsMoveableInside(Moveable) + Volume:IsMoveableInside(moveable) Determine if a moveable is inside this volume. @@ -189,7 +189,7 @@ Volume:GetName()
    - Get the unique string identifier of this volume. () + Get the unique string identifier of this volume. @@ -210,7 +210,7 @@ Volume:GetPosition()
    - Get the position of this volume. () + Get the position of this volume. @@ -231,7 +231,7 @@ Volume:GetRotation()
    - Get the rotation of this volume. () + Get the rotation of this volume. @@ -252,7 +252,7 @@ Volume:GetScale()
    - Get this scale of this volume. () + Get this scale of this volume. @@ -273,7 +273,7 @@ Volume:SetName(name)
    - Set the unique string identifier of this volume. () + Set the unique string identifier of this volume. @@ -295,7 +295,7 @@ Volume:SetPosition(pos)
    - Set the position of this volume. () + Set the position of this volume. @@ -317,7 +317,7 @@ Volume:SetRotation(rot)
    - Set the rotation of this volume. () + Set the rotation of this volume. @@ -339,7 +339,7 @@ Volume:SetScale(scale)
    - Set the scale of the volume. () + Set the scale of the volume. @@ -361,7 +361,7 @@ Volume:GetActive()
    - Determine if this volume is active. () + Determine if this volume is active. @@ -379,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.
    @@ -410,7 +410,7 @@ Volume:Enable()
    - Enable this volume. () + Enable this volume. @@ -425,7 +425,7 @@ Volume:Disable()
    - Disable this volume. () + Disable this volume. @@ -440,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 4f1088fad..958d506a8 100644 --- a/Documentation/doc/2 classes/Strings.DisplayString.html +++ b/Documentation/doc/2 classes/Strings.DisplayString.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -129,23 +129,23 @@ when you need to use screen-space coordinates.

    Functions

    - + - + - + - + - + @@ -166,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.
    @@ -183,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. @@ -197,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.
  • @@ -239,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. @@ -248,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.
    @@ -260,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. @@ -268,7 +265,7 @@ If true, the string argument will be the key of a translated string specified in @@ -282,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. @@ -293,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.
    @@ -302,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:

    @@ -329,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. @@ -351,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. @@ -373,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. @@ -396,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. @@ -417,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. @@ -425,7 +418,7 @@ If true, the string argument will be the key of a translated string specified in @@ -444,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:

    - - - - - -
    diff --git a/Documentation/doc/2 classes/View.DisplaySprite.html b/Documentation/doc/2 classes/View.DisplaySprite.html index 2b097a9bb..9347dded9 100644 --- a/Documentation/doc/2 classes/View.DisplaySprite.html +++ b/Documentation/doc/2 classes/View.DisplaySprite.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -124,10 +124,14 @@

    Functions

    - + + + + + @@ -152,27 +156,27 @@ - + - + - + - + - + - + @@ -190,23 +194,65 @@
    - DisplaySprite(ID, int, pos, rot, scale, [color]) + DisplaySprite(objectID, index, pos, rot, scale, [color])
    - Create a DisplaySprite object. () + Create a DisplaySprite object.

    Parameters:

    + +

    Returns:

    +
      + + DisplaySprite + A new DisplaySprite object. +
    + + + + +
    +
    + + DisplaySprite(pos, rot, scale, [color]) +
    +
    + Create a DisplaySprite object with a video image. + Video should be played using View.PlayVideo function in a background mode. If no video is played, sprite will not show. + + + +

    Parameters:

    + diff --git a/Documentation/doc/3 primitive classes/Flow.Horizon.html b/Documentation/doc/3 primitive classes/Flow.Horizon.html index 891539543..f0eebb4e5 100644 --- a/Documentation/doc/3 primitive classes/Flow.Horizon.html +++ b/Documentation/doc/3 primitive classes/Flow.Horizon.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/3 primitive classes/Flow.InventoryItem.html b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html index ac66af1ac..ba857b892 100644 --- a/Documentation/doc/3 primitive classes/Flow.InventoryItem.html +++ b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -147,8 +147,7 @@
    DisplaySprite(ID, int, pos, rot, scale, [color])DisplaySprite(objectID, index, pos, rot, scale, [color]) Create a DisplaySprite object.
    DisplaySprite(pos, rot, scale, [color])Create a DisplaySprite object with a video image.
    DisplaySprite:GetObjectID() Get the object ID of the sprite sequence object used by the display sprite.
    Get the color of the display sprite.
    DisplaySprite:SetObjectID(New)DisplaySprite:SetObjectID(objectID) Set the sprite sequence object ID used by the display sprite.
    DisplaySprite:SetSpriteID(New)DisplaySprite:SetSpriteID(spriteID) Set the sprite ID in the sprite sequence object used by the display sprite.
    DisplaySprite:SetPosition(New)DisplaySprite:SetPosition(position) Set the display position of the display sprite in percent.
    DisplaySprite:SetRotation(New)DisplaySprite:SetRotation(rotation) Set the rotation of the display sprite in degrees.
    DisplaySprite:SetScale(New)DisplaySprite:SetScale(scale) Set the horizontal and vertical scale of the display sprite in percent.
    DisplaySprite:SetColor(New)DisplaySprite:SetColor(color) Set the color of the display sprite.
    - + - +
    color(Color) RGB sky color(Color) RGB sky color.
    speed(int) cloud speed.(int) Cloud speed.

    Functions

    @@ -152,7 +152,7 @@ color
    - (Color) RGB sky color + (Color) RGB sky color. @@ -167,7 +167,7 @@ speed
    - (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.
    @@ -205,11 +205,11 @@
         
    • color Color - RGB color + RGB color.
    • speed int - cloud speed + Cloud speed.
    diff --git a/Documentation/doc/3 primitive classes/Flow.Starfield.html b/Documentation/doc/3 primitive classes/Flow.Starfield.html index 9182b0b89..feab0e343 100644 --- a/Documentation/doc/3 primitive classes/Flow.Starfield.html +++ b/Documentation/doc/3 primitive classes/Flow.Starfield.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -281,7 +281,7 @@

    Returns:

      - StarField + Starfield A new Starfield object.
    diff --git a/Documentation/doc/3 primitive classes/Rotation.html b/Documentation/doc/3 primitive classes/Rotation.html index 08d1dedf6..1c39be191 100644 --- a/Documentation/doc/3 primitive classes/Rotation.html +++ b/Documentation/doc/3 primitive classes/Rotation.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/3 primitive classes/Time.html b/Documentation/doc/3 primitive classes/Time.html index 1edf989a5..9a671f125 100644 --- a/Documentation/doc/3 primitive classes/Time.html +++ b/Documentation/doc/3 primitive classes/Time.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/3 primitive classes/Vec2.html b/Documentation/doc/3 primitive classes/Vec2.html index 4bedd88bf..7a9e44453 100644 --- a/Documentation/doc/3 primitive classes/Vec2.html +++ b/Documentation/doc/3 primitive classes/Vec2.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/3 primitive classes/Vec3.html b/Documentation/doc/3 primitive classes/Vec3.html index 5ff74ce81..f8e233fbc 100644 --- a/Documentation/doc/3 primitive classes/Vec3.html +++ b/Documentation/doc/3 primitive classes/Vec3.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Collision.MaterialType.html b/Documentation/doc/4 enums/Collision.MaterialType.html index 564b8ca1f..8ed328b63 100644 --- a/Documentation/doc/4 enums/Collision.MaterialType.html +++ b/Documentation/doc/4 enums/Collision.MaterialType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -142,7 +142,10 @@
    -

    Table of MaterialType constants. To be used with Collision.Probe.GetFloorMaterialType and Collision.Probe.GetCeilingMaterialType.

    +

    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 bd2f1aca9..5c3fc42f4 100644 --- a/Documentation/doc/4 enums/Effects.BlendID.html +++ b/Documentation/doc/4 enums/Effects.BlendID.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -142,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 32b783f43..504db707c 100644 --- a/Documentation/doc/4 enums/Effects.EffectID.html +++ b/Documentation/doc/4 enums/Effects.EffectID.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Effects.ParticleAnimationType.html b/Documentation/doc/4 enums/Effects.ParticleAnimationType.html index f1351b9af..d9acddbe4 100644 --- a/Documentation/doc/4 enums/Effects.ParticleAnimationType.html +++ b/Documentation/doc/4 enums/Effects.ParticleAnimationType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html b/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html index 47692e9c5..c345a047e 100644 --- a/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html +++ b/Documentation/doc/4 enums/Effects.StreamerFeatherMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Flow.ErrorMode.html b/Documentation/doc/4 enums/Flow.ErrorMode.html index 4bf7d6fab..de10d20bd 100644 --- a/Documentation/doc/4 enums/Flow.ErrorMode.html +++ b/Documentation/doc/4 enums/Flow.ErrorMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -146,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 d01a30a1a..9b9032383 100644 --- a/Documentation/doc/4 enums/Flow.FreezeMode.html +++ b/Documentation/doc/4 enums/Flow.FreezeMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Flow.GameStatus.html b/Documentation/doc/4 enums/Flow.GameStatus.html index 0e9262274..1c85193ae 100644 --- a/Documentation/doc/4 enums/Flow.GameStatus.html +++ b/Documentation/doc/4 enums/Flow.GameStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Input.ActionID.html b/Documentation/doc/4 enums/Input.ActionID.html index b0c16ee50..6e112df91 100644 --- a/Documentation/doc/4 enums/Input.ActionID.html +++ b/Documentation/doc/4 enums/Input.ActionID.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Objects.AmmoType.html b/Documentation/doc/4 enums/Objects.AmmoType.html index cf02b25c1..114163de2 100644 --- a/Documentation/doc/4 enums/Objects.AmmoType.html +++ b/Documentation/doc/4 enums/Objects.AmmoType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Objects.HandStatus.html b/Documentation/doc/4 enums/Objects.HandStatus.html index 5e6f31be9..b0582d69f 100644 --- a/Documentation/doc/4 enums/Objects.HandStatus.html +++ b/Documentation/doc/4 enums/Objects.HandStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Objects.MoveableStatus.html b/Documentation/doc/4 enums/Objects.MoveableStatus.html index 21ceb56ef..87325f180 100644 --- a/Documentation/doc/4 enums/Objects.MoveableStatus.html +++ b/Documentation/doc/4 enums/Objects.MoveableStatus.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -147,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 87fb56147..889c4b9a3 100644 --- a/Documentation/doc/4 enums/Objects.ObjID.html +++ b/Documentation/doc/4 enums/Objects.ObjID.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -883,7 +883,7 @@ INVENTORY_PASSPORT INVENTORY_SUNGLASSES INVENTORY_KEYS INVENTORY_HEADPHONES -INVENTORY_POLAROID +INVENTORY_PHOTO SMOKE_EMITTER_WHITE SMOKE_EMITTER_BLACK SMOKE_EMITTER diff --git a/Documentation/doc/4 enums/Objects.RoomFlagID.html b/Documentation/doc/4 enums/Objects.RoomFlagID.html index 3edc7b5ce..cdd7e43ea 100644 --- a/Documentation/doc/4 enums/Objects.RoomFlagID.html +++ b/Documentation/doc/4 enums/Objects.RoomFlagID.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -143,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 420e1731c..555358c9c 100644 --- a/Documentation/doc/4 enums/Objects.RoomReverb.html +++ b/Documentation/doc/4 enums/Objects.RoomReverb.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -143,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 c45efc459..6b6a87ea2 100644 --- a/Documentation/doc/4 enums/Objects.WeaponType.html +++ b/Documentation/doc/4 enums/Objects.WeaponType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/Sound.SoundTrackType.html b/Documentation/doc/4 enums/Sound.SoundTrackType.html index ad9eb5e39..1b80f2b82 100644 --- a/Documentation/doc/4 enums/Sound.SoundTrackType.html +++ b/Documentation/doc/4 enums/Sound.SoundTrackType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -147,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 e43f3200b..32a0f566d 100644 --- a/Documentation/doc/4 enums/Strings.DisplayStringOption.html +++ b/Documentation/doc/4 enums/Strings.DisplayStringOption.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -145,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 3e463cf45..db5b3d0c1 100644 --- a/Documentation/doc/4 enums/Util.LogLevel.html +++ b/Documentation/doc/4 enums/Util.LogLevel.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/View.AlignMode.html b/Documentation/doc/4 enums/View.AlignMode.html index 479a64e04..90ce2b553 100644 --- a/Documentation/doc/4 enums/View.AlignMode.html +++ b/Documentation/doc/4 enums/View.AlignMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/View.CameraType.html b/Documentation/doc/4 enums/View.CameraType.html index 8059b3c65..cd0848ceb 100644 --- a/Documentation/doc/4 enums/View.CameraType.html +++ b/Documentation/doc/4 enums/View.CameraType.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -145,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 03b0419d6..0036ba5c3 100644 --- a/Documentation/doc/4 enums/View.PostProcessMode.html +++ b/Documentation/doc/4 enums/View.PostProcessMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/4 enums/View.ScaleMode.html b/Documentation/doc/4 enums/View.ScaleMode.html index d00970ef0..445c35879 100644 --- a/Documentation/doc/4 enums/View.ScaleMode.html +++ b/Documentation/doc/4 enums/View.ScaleMode.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -145,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 index 2940474c8..b0f3fe3be 100644 --- a/Documentation/doc/5 lua utility modules/CustomBar.html +++ b/Documentation/doc/5 lua utility modules/CustomBar.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/5 lua utility modules/Diary.html b/Documentation/doc/5 lua utility modules/Diary.html index 58d81a722..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.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -294,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 @@ -302,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 e0557249c..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.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/5 lua utility modules/Timer.html b/Documentation/doc/5 lua utility modules/Timer.html index 2bdecfa5e..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.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/5 lua utility modules/Type.html b/Documentation/doc/5 lua utility modules/Type.html index dad15e9ec..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.8.1 Lua API + TombEngine 1.8.2 Lua API diff --git a/Documentation/doc/index.html b/Documentation/doc/index.html index 780a8b9e5..0d8c40599 100644 --- a/Documentation/doc/index.html +++ b/Documentation/doc/index.html @@ -3,7 +3,7 @@ - TombEngine 1.8.1 Lua API + TombEngine 1.8.2 Lua API @@ -115,7 +115,7 @@
      -

      TombEngine 1.8.1 scripting interface

      +

      TombEngine 1.8.2 scripting interface

      Welcome to the TombEngine scripting API.

      Note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. @@ -208,7 +208,7 @@ local door = GetMoveableByName("door_type4_14") Objects.LaraObject - Class for extra player-only functions. + Class for player-only functions. Objects.Moveable 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 557b222d6..cbc224c3e 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ - Support for high framerate, antialiasing, mipmapping, and SSAO. - Full diagonal geometry support. - Uncapped map size. -- A streamlined player control scheme.. - -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). +- A streamlined player control scheme. *Tomb Engine* is used in conjunction with *Tomb Editor*. The repository can be found [here](https://github.com/MontyTRC89/Tomb-Editor). @@ -36,6 +34,9 @@ Steps: Once done, you should be able to build a level with *Tomb Editor* and run it in *TEN*. -# Disclaimer -This community project is unaffiliated with Core Design, Eidos Interactive, or Embracer Group AB. *Tomb Raider* is a registered trademark of Embracer Group AB. *Tomb Engine* is not for sale. The code is open-source to encourage contributions and 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. +# 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 +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/CustomDiary.lua b/Scripts/Engine/CustomDiary.lua index e62e2424d..20b029c37 100644 --- a/Scripts/Engine/CustomDiary.lua +++ b/Scripts/Engine/CustomDiary.lua @@ -531,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/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_one_gun.cpp b/TombEngine/Game/Lara/lara_one_gun.cpp index 3dcefb301..ede45b080 100644 --- a/TombEngine/Game/Lara/lara_one_gun.cpp +++ b/TombEngine/Game/Lara/lara_one_gun.cpp @@ -94,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: @@ -168,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()) @@ -183,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: @@ -203,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; @@ -264,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()) @@ -276,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; @@ -322,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; @@ -348,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, @@ -393,8 +407,6 @@ void FireShotgun(ItemInfo& laraItem) auto pos = GetJointPosition(&laraItem, LM_RHAND, offset + Vector3::UnitY * CLICK(2)); auto pos2 = GetJointPosition(&laraItem, LM_RHAND, offset); - player.LeftArm.GunSmoke = 32; - if (laraItem.MeshBits != 0) { for (int i = 0; i < 7; i++) @@ -406,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) @@ -552,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; @@ -608,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; } @@ -652,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]; @@ -743,8 +744,7 @@ void FireGrenade(ItemInfo& laraItem) break; } - SaveGame::Statistics.Level.AmmoUsed++; - SaveGame::Statistics.Game.AmmoUsed++; + return true; } void GrenadeControl(short itemNumber) @@ -835,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; @@ -905,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) @@ -974,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; @@ -1059,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) @@ -1092,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]; @@ -1134,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) @@ -1195,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) @@ -1283,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)); + } + } } 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 075b2f78e..b0d6bb61d 100644 --- a/TombEngine/Game/Lara/lara_struct.h +++ b/TombEngine/Game/Lara/lara_struct.h @@ -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/control/box.cpp b/TombEngine/Game/control/box.cpp index 763dfec8b..a6ea4b676 100644 --- a/TombEngine/Game/control/box.cpp +++ b/TombEngine/Game/control/box.cpp @@ -971,7 +971,8 @@ void TargetBox(LOTInfo* LOT, int boxNumber) { if (boxNumber == NO_VALUE) return; - auto* box = &g_Level.PathfindingBoxes[boxNumber]; + + const auto* box = &g_Level.PathfindingBoxes[boxNumber]; // Maximize target precision. DO NOT change bracket precedence! LOT->Target.x = (int)((box->top * BLOCK(1)) + (float)GetRandomControl() * (((float)(box->bottom - box->top) - 1.0f) / 32.0f) + CLICK(2.0f)); @@ -1637,9 +1638,9 @@ void CreatureMood(ItemInfo* item, AI_INFO* AI, bool isViolent) auto* enemy = creature->Enemy; - // HACK: Fallback to bored mood from attack mood if enemy was cleared. + // HACK: Fallback to bored mood from attack or escape 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) + if (enemy == nullptr && (creature->Mood == MoodType::Attack || creature->Mood == MoodType::Escape)) creature->Mood = MoodType::Bored; int boxNumber; diff --git a/TombEngine/Game/control/control.cpp b/TombEngine/Game/control/control.cpp index b543b9ee5..677b39f95 100644 --- a/TombEngine/Game/control/control.cpp +++ b/TombEngine/Game/control/control.cpp @@ -39,6 +39,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" @@ -59,7 +60,7 @@ #include "Specific/Input/Input.h" #include "Specific/level.h" #include "Specific/winmain.h" -#include "Objects/Effects/Fireflies.h" +#include "Specific/Video/Video.h" using namespace std::chrono; using namespace TEN::Effects; @@ -91,6 +92,7 @@ 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; @@ -356,18 +358,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. @@ -490,6 +495,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. @@ -519,6 +543,7 @@ void CleanUp() ClearFootprints(); ClearDrips(); ClearRipples(); + ClearSplashes(); ClearLaserBarrierEffects(); ClearLaserBeamEffects(); DisableSmokeParticles(); @@ -586,7 +611,8 @@ void InitializeScripting(int levelIndex, bool loadGame) void DeInitializeScripting(int levelIndex, GameStatus reason) { // Reload gameflow script to clear level script variables. - g_GameFlow->LoadFlowScript(); + if (reason != GameStatus::ExitGame) + g_GameFlow->LoadFlowScript(); g_GameScript->FreeLevelScripts(); g_GameScriptEntities->FreeEntities(); @@ -658,6 +684,9 @@ GameStatus DoGameLoop(int levelIndex) { g_Synchronizer.Sync(); + if (g_VideoPlayer.Update()) + continue; + while (g_Synchronizer.Synced()) { status = ControlPhase(false); @@ -686,7 +715,7 @@ GameStatus DoGameLoop(int levelIndex) } } - EndGameLoop(levelIndex, status); + EndGameLoop(levelIndex, DoTheGame ? status : GameStatus::ExitGame); return status; } @@ -696,9 +725,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(); @@ -721,7 +753,7 @@ 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/los.cpp b/TombEngine/Game/control/los.cpp index 3f1c0b2ab..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) 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/Splash.cpp b/TombEngine/Game/effects/Splash.cpp index 713964652..88b919608 100644 --- a/TombEngine/Game/effects/Splash.cpp +++ b/TombEngine/Game/effects/Splash.cpp @@ -129,6 +129,14 @@ namespace TEN::Effects::Splash } } + void ClearSplashes() + { + SplashCount = 0; + + for (auto& splash : SplashEffects) + splash = {}; + } + void Splash(ItemInfo* item) { int probedRoomNumber = GetPointCollision(*item).GetRoomNumber(); diff --git a/TombEngine/Game/effects/Splash.h b/TombEngine/Game/effects/Splash.h index f2509cb44..522cffba0 100644 --- a/TombEngine/Game/effects/Splash.h +++ b/TombEngine/Game/effects/Splash.h @@ -60,5 +60,6 @@ namespace TEN::Effects::Splash void SetupSplash(const SplashEffectSetup* const setup, int room); void UpdateSplashes(); + void ClearSplashes(); void Splash(ItemInfo* item); } diff --git a/TombEngine/Game/effects/debris.cpp b/TombEngine/Game/effects/debris.cpp index 4139bb33b..df0b63e2b 100644 --- a/TombEngine/Game/effects/debris.cpp +++ b/TombEngine/Game/effects/debris.cpp @@ -61,7 +61,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe { int meshIndex = 0; short yRot = 0; - float scale; + Vector3 scale; Vector3 pos; bool isStatic; @@ -74,7 +74,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe meshIndex = Statics[mesh->staticNumber].meshNumber; yRot = mesh->pos.Orientation.y; pos = Vector3(mesh->pos.Position.x, mesh->pos.Position.y, mesh->pos.Position.z); - scale = mesh->scale; + scale = mesh->pos.Scale; if (mesh->HitPoints <= 0) mesh->flags &= ~StaticMeshFlags::SM_VISIBLE; @@ -89,7 +89,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe meshIndex = item->meshIndex; yRot = item->yRot; pos = item->sphere.Center; - scale = 1.0f; + scale = Vector3::One; } auto fragmentsMesh = &g_Level.Meshes[meshIndex]; diff --git a/TombEngine/Game/gui.cpp b/TombEngine/Game/gui.cpp index 46558185d..9d0377ab5 100644 --- a/TombEngine/Game/gui.cpp +++ b/TombEngine/Game/gui.cpp @@ -27,12 +27,14 @@ #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 { @@ -716,7 +718,7 @@ namespace TEN::Gui else { g_Renderer.PrepareScene(); // Just for updating blink time. - UpdateInputActions(item); + UpdateInputActions(); } if (CurrentSettings.IgnoreInput) @@ -1157,7 +1159,7 @@ namespace TEN::Gui static const int numOptionsOptions = 2; TimeInMenu++; - UpdateInputActions(item); + UpdateInputActions(); switch (MenuToDisplay) { @@ -3185,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); @@ -3249,6 +3252,7 @@ namespace TEN::Gui } else { + g_VideoPlayer.Resume(); ResumeAllSounds(SoundPauseMode::Pause); } @@ -3266,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); @@ -3296,7 +3301,7 @@ namespace TEN::Gui SaveGame::Statistics.Game.TimeTaken++; SaveGame::Statistics.Level.TimeTaken++; - UpdateInputActions(item); + UpdateInputActions(); if (GuiIsDeselected() || IsClicked(In::Inventory)) { @@ -3387,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/pickup/pickup.cpp b/TombEngine/Game/pickup/pickup.cpp index 3059baac0..260cca2a2 100644 --- a/TombEngine/Game/pickup/pickup.cpp +++ b/TombEngine/Game/pickup/pickup.cpp @@ -1239,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.cpp b/TombEngine/Game/room.cpp index f2ce9fa21..018a48ff0 100644 --- a/TombEngine/Game/room.cpp +++ b/TombEngine/Game/room.cpp @@ -255,11 +255,11 @@ GameBoundingBox& GetBoundsAccurate(const MESH_INFO& mesh, bool getVisibilityBox) if (getVisibilityBox) { - bounds = Statics[mesh.staticNumber].visibilityBox * mesh.scale; + bounds = Statics[mesh.staticNumber].visibilityBox * mesh.pos.Scale; } else { - bounds = Statics[mesh.staticNumber].collisionBox * mesh.scale; + bounds = Statics[mesh.staticNumber].collisionBox * mesh.pos.Scale; } return bounds; diff --git a/TombEngine/Game/room.h b/TombEngine/Game/room.h index a43e2c428..763b245e1 100644 --- a/TombEngine/Game/room.h +++ b/TombEngine/Game/room.h @@ -77,7 +77,6 @@ struct MESH_INFO { Pose pos; int roomNumber; - float scale; short staticNumber; short flags; Vector4 color; diff --git a/TombEngine/Game/savegame.cpp b/TombEngine/Game/savegame.cpp index 26b41d8ad..bff1931c0 100644 --- a/TombEngine/Game/savegame.cpp +++ b/TombEngine/Game/savegame.cpp @@ -40,6 +40,7 @@ #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; @@ -53,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; @@ -293,6 +295,15 @@ const std::vector SaveGame::Build() 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++) @@ -472,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); @@ -951,7 +961,7 @@ const std::vector SaveGame::Build() fireflySave.add_b(firefly.b); fireflySave.add_on(firefly.on); fireflySave.add_size(firefly.size); - fireflySave.add_rot_Ang(firefly.rotAng); + fireflySave.add_rot_ang(firefly.rotAng); auto fireflySaveOffset = fireflySave.Finish(); fireflySwarm.push_back(fireflySaveOffset); @@ -1071,7 +1081,6 @@ const std::vector SaveGame::Build() Save::StaticMeshInfoBuilder staticMesh{ fbb }; staticMesh.add_pose(&FromPose(room->mesh[j].pos)); - staticMesh.add_scale(room->mesh[j].scale); staticMesh.add_color(&FromVector4(room->mesh[j].color)); staticMesh.add_flags(room->mesh[j].flags); @@ -1588,8 +1597,8 @@ const std::vector SaveGame::Build() sgb.add_postprocess_strength(g_Renderer.GetPostProcessStrength()); 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); @@ -2122,7 +2131,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(); @@ -2304,6 +2312,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++) { @@ -2353,7 +2369,7 @@ static void ParseEffects(const Save::SaveGame* s) firefly.b = fireflySave->b(); firefly.on = fireflySave->on(); firefly.size = fireflySave->size(); - firefly.rotAng = fireflySave->rot_Ang(); + firefly.rotAng = fireflySave->rot_ang(); FireflySwarm.push_back(firefly); } @@ -2499,7 +2515,6 @@ static void ParseLevel(const Save::SaveGame* s, bool hubMode) room->mesh[number].pos = ToPose(*staticMesh->pose()); room->mesh[number].roomNumber = staticMesh->room_number(); - room->mesh[number].scale = staticMesh->scale(); room->mesh[number].color = ToVector4(staticMesh->color()); room->mesh[number].flags = staticMesh->flags(); diff --git a/TombEngine/Math/Objects/GameBoundingBox.cpp b/TombEngine/Math/Objects/GameBoundingBox.cpp index 60177a6da..5ce31a140 100644 --- a/TombEngine/Math/Objects/GameBoundingBox.cpp +++ b/TombEngine/Math/Objects/GameBoundingBox.cpp @@ -167,6 +167,14 @@ Z1 * scalar, Z2 * scalar); } + GameBoundingBox GameBoundingBox::operator *(Vector3 scalar) const + { + return GameBoundingBox( + X1 * scalar.x, X2 * scalar.x, + Y1 * scalar.y, Y2 * scalar.y, + Z1 * scalar.z, Z2 * scalar.z); + } + GameBoundingBox GameBoundingBox::operator /(float scalar) const { return GameBoundingBox( @@ -174,4 +182,12 @@ Y1 / scalar, Y2 / scalar, Z1 / scalar, Z2 / scalar); } + + GameBoundingBox GameBoundingBox::operator /(Vector3 scalar) const + { + return GameBoundingBox( + X1 / scalar.x, X2 / scalar.x, + Y1 / scalar.y, Y2 / scalar.y, + Z1 / scalar.z, Z2 / scalar.z); + } //} diff --git a/TombEngine/Math/Objects/GameBoundingBox.h b/TombEngine/Math/Objects/GameBoundingBox.h index ff819239d..90cda2dbc 100644 --- a/TombEngine/Math/Objects/GameBoundingBox.h +++ b/TombEngine/Math/Objects/GameBoundingBox.h @@ -57,6 +57,8 @@ struct ObjectInfo; GameBoundingBox operator -(const GameBoundingBox& bounds) const; GameBoundingBox operator -(const Pose& pose) const; GameBoundingBox operator *(float scalar) const; + GameBoundingBox operator *(Vector3 scalar) const; GameBoundingBox operator /(float scalar) const; + GameBoundingBox operator /(Vector3 scalar) const; }; //} diff --git a/TombEngine/Objects/game_object_ids.h b/TombEngine/Objects/game_object_ids.h index 18c64a25b..a70404f76 100644 --- a/TombEngine/Objects/game_object_ids.h +++ b/TombEngine/Objects/game_object_ids.h @@ -746,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, 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/Renderer.cpp b/TombEngine/Renderer/Renderer.cpp index b4c83e8d9..c3f5da770 100644 --- a/TombEngine/Renderer/Renderer.cpp +++ b/TombEngine/Renderer/Renderer.cpp @@ -6,11 +6,11 @@ #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 { @@ -62,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 16c6325c2..c359341ba 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; @@ -451,7 +452,7 @@ namespace TEN::Renderer void PrepareShockwaves(RenderView& view); void PrepareRipples(RenderView& view); void PrepareUnderwaterBloodParticles(RenderView& view); - void DrawFullScreenQuad(ID3D11ShaderResourceView* texture, Vector3 color, bool fit = true); + void DrawFullScreenQuad(ID3D11ShaderResourceView* texture, Vector3 color, bool fit = true, float customAspect = 0.0f); void DrawFullScreenSprite(RendererSprite* sprite, DirectX::SimpleMath::Vector3 color, bool fit = true); void PrepareSmokeParticles(RenderView& view); void PrepareSparkParticles(RenderView& view); @@ -609,7 +610,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); @@ -633,6 +634,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 bc31f8308..c7f4fdce7 100644 --- a/TombEngine/Renderer/RendererCompatibility.cpp +++ b/TombEngine/Renderer/RendererCompatibility.cpp @@ -68,11 +68,18 @@ namespace TEN::Renderer _animatedTextures[i] = tex; } - 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; @@ -81,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; }); @@ -273,12 +292,11 @@ namespace TEN::Renderer staticInfo->RoomNumber = oldMesh->roomNumber; staticInfo->Color = oldMesh->color; staticInfo->AmbientLight = r->AmbientLight; - staticInfo->Pose = oldMesh->pos; - staticInfo->Scale = oldMesh->scale; + staticInfo->Pose = staticInfo->PrevPose = oldMesh->pos; staticInfo->OriginalSphere = Statics[staticInfo->ObjectNumber].visibilityBox.ToLocalBoundingSphere(); staticInfo->IndexInRoom = l; - staticInfo->Update(); + staticInfo->Update(GetInterpolationFactor()); } } @@ -747,7 +765,7 @@ namespace TEN::Renderer for (int v1 = 0; v1 < currentBucket.NumVertices; v1++) { auto* currentVertex = &_moveablesVertices[currentBucket.StartVertex + v1]; - currentVertex->BoneIndex[0] = currentVertex->BoneIndex[1] = j + 1; + currentVertex->BoneIndex[0] = j + 1; // Link mesh 0 to root mesh. if (j == 0) diff --git a/TombEngine/Renderer/RendererDraw.cpp b/TombEngine/Renderer/RendererDraw.cpp index d2d39acbf..34a34f41f 100644 --- a/TombEngine/Renderer/RendererDraw.cpp +++ b/TombEngine/Renderer/RendererDraw.cpp @@ -2184,6 +2184,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); @@ -2798,30 +2825,48 @@ 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 diff --git a/TombEngine/Renderer/RendererDraw2D.cpp b/TombEngine/Renderer/RendererDraw2D.cpp index cf5648e3f..5f5751d82 100644 --- a/TombEngine/Renderer/RendererDraw2D.cpp +++ b/TombEngine/Renderer/RendererDraw2D.cpp @@ -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 ce6ed8034..05502ba10 100644 --- a/TombEngine/Renderer/RendererDrawEffect.cpp +++ b/TombEngine/Renderer/RendererDrawEffect.cpp @@ -555,13 +555,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, @@ -1081,92 +1087,90 @@ 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; - if (Lara.Control.Weapon.GunType != LaraWeaponType::Flare && - Lara.Control.Weapon.GunType != LaraWeaponType::Crossbow) + // 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); + unsigned int offset = 0; + + _context->IASetVertexBuffers(0, 1, _moveablesVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); + _context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + _context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); + + const auto& room = _rooms[LaraItem->RoomNumber]; + auto* itemPtr = &_items[LaraItem->Index]; + + // Divide gunflash tint by 2 because tinting uses multiplication and additive color which doesn't look good with overbright color values. + _stStatic.Color = settings.ColorizeMuzzleFlash ? ((Vector4)settings.FlashColor / 2) : Vector4::One; + _stStatic.AmbientLight = room.AmbientLight; + _stStatic.LightMode = (int)LightMode::Static; + BindStaticLights(itemPtr->LightsToDraw); + + SetAlphaTest(AlphaTestMode::GreatherThan, ALPHA_TEST_THRESHOLD); + SetBlendMode(BlendMode::Additive); + + for (const auto& flashBucket : flashMesh.Buckets) { - // 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 (flashBucket.BlendMode == BlendMode::Opaque) + continue; - if (!_moveableObjects[gunflash].has_value()) - return false; + if (flashBucket.Polygons.size() == 0) + continue; - const auto& flashMoveable = *_moveableObjects[gunflash]; - const auto& flashMesh = *flashMoveable.ObjectMeshes[0]; + BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[flashBucket.Texture]), SamplerStateRegister::AnisotropicClamp); - _shaders.Bind(Shader::Statics); + 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. - unsigned int stride = sizeof(Vertex); - unsigned int offset = 0; + auto tMatrix = Matrix::CreateTranslation(offset); + auto rotMatrix = Matrix::CreateRotationX(TO_RAD(Lara.Control.Weapon.GunType == LaraWeaponType::Pistol ? -16830 : -14560)); // HACK - _context->IASetVertexBuffers(0, 1, _moveablesVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); - _context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - _context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); - - const auto& room = _rooms[LaraItem->RoomNumber]; - auto* itemPtr = &_items[LaraItem->Index]; - - // Divide gunflash tint by 2 because tinting uses multiplication and additive color which doesn't look good with overbright color values. - _stStatic.Color = settings.ColorizeMuzzleFlash ? ((Vector4)settings.FlashColor / 2) : Vector4::One; - _stStatic.AmbientLight = room.AmbientLight; - _stStatic.LightMode = (int)LightMode::Static; - BindStaticLights(itemPtr->LightsToDraw); - - SetAlphaTest(AlphaTestMode::GreatherThan, ALPHA_TEST_THRESHOLD); - SetBlendMode(BlendMode::Additive); - - for (const auto& flashBucket : flashMesh.Buckets) + auto worldMatrix = Matrix::Identity; + if (Lara.LeftArm.GunFlash) { - if (flashBucket.BlendMode == BlendMode::Opaque) - continue; + worldMatrix = itemPtr->AnimTransforms[LM_LHAND] * itemPtr->World; + worldMatrix = tMatrix * worldMatrix; + worldMatrix = rotMatrix * worldMatrix; + ReflectMatrixOptionally(worldMatrix); - if (flashBucket.Polygons.size() == 0) - continue; + _stStatic.World = worldMatrix; + _cbStatic.UpdateData(_stStatic, _context.Get()); - BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[flashBucket.Texture]), SamplerStateRegister::AnisotropicClamp); + DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); + _numMoveablesDrawCalls++; + } - 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. + if (Lara.RightArm.GunFlash) + { + worldMatrix = itemPtr->AnimTransforms[LM_RHAND] * itemPtr->World; + worldMatrix = tMatrix * worldMatrix; + worldMatrix = rotMatrix * worldMatrix; + ReflectMatrixOptionally(worldMatrix); - auto tMatrix = Matrix::CreateTranslation(offset); - auto rotMatrix = Matrix::CreateRotationX(TO_RAD(Lara.Control.Weapon.GunType == LaraWeaponType::Pistol ? -16830 : -14560)); // HACK + _stStatic.World = worldMatrix; + _cbStatic.UpdateData(_stStatic, _context.Get()); - auto worldMatrix = Matrix::Identity; - if (Lara.LeftArm.GunFlash) - { - worldMatrix = itemPtr->AnimTransforms[LM_LHAND] * itemPtr->World; - worldMatrix = tMatrix * worldMatrix; - worldMatrix = rotMatrix * worldMatrix; - ReflectMatrixOptionally(worldMatrix); + DrawIndexedTriangles(flashBucket.NumIndices, flashBucket.StartIndex, 0); - _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 e38f1e440..403501f30 100644 --- a/TombEngine/Renderer/RendererDrawMenu.cpp +++ b/TombEngine/Renderer/RendererDrawMenu.cpp @@ -903,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) diff --git a/TombEngine/Renderer/RendererFrame.cpp b/TombEngine/Renderer/RendererFrame.cpp index d8d0fcdb0..c8ce913c9 100644 --- a/TombEngine/Renderer/RendererFrame.cpp +++ b/TombEngine/Renderer/RendererFrame.cpp @@ -527,10 +527,9 @@ namespace TEN::Renderer mesh->Color = nativeMesh->color; mesh->OriginalSphere = Statics[mesh->ObjectNumber].visibilityBox.ToLocalBoundingSphere(); mesh->Pose = nativeMesh->pos; - mesh->Scale = nativeMesh->scale; - mesh->Update(); + mesh->Update(GetInterpolationFactor()); - nativeMesh->Dirty = false; + nativeMesh->Dirty = (mesh->PrevPose != mesh->Pose); } if (!(nativeMesh->flags & StaticMeshFlags::SM_VISIBLE)) @@ -931,5 +930,11 @@ namespace TEN::Renderer effect.PrevRotation = effect.Rotation; effect.PrevScale = effect.Scale; } + + for (auto& room : _rooms) + { + for (auto& stat : room.Statics) + stat.PrevPose = stat.Pose; + } } } diff --git a/TombEngine/Renderer/RendererInit.cpp b/TombEngine/Renderer/RendererInit.cpp index 54a05a98d..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(); @@ -237,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/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/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/RendererStatic.h b/TombEngine/Renderer/Structures/RendererStatic.h index 03ae26f0f..9a3f4ea39 100644 --- a/TombEngine/Renderer/Structures/RendererStatic.h +++ b/TombEngine/Renderer/Structures/RendererStatic.h @@ -15,6 +15,7 @@ namespace TEN::Renderer::Structures int ObjectNumber; int RoomNumber; int IndexInRoom; + Pose PrevPose; Pose Pose; Matrix World; Vector4 Color; @@ -24,14 +25,15 @@ namespace TEN::Renderer::Structures bool CacheLights; BoundingSphere OriginalSphere; BoundingSphere Sphere; - float Scale; - void Update() + void Update(float interpolationFactor) { - World = (Pose.Orientation.ToRotationMatrix() * - Matrix::CreateScale(Scale) * - Matrix::CreateTranslation(Pose.Position.x, Pose.Position.y, Pose.Position.z)); - Sphere = BoundingSphere(Vector3::Transform(OriginalSphere.Center, World), OriginalSphere.Radius * Scale); + auto pos = Vector3::Lerp(PrevPose.Position.ToVector3(), Pose.Position.ToVector3(), interpolationFactor); + auto scale = Vector3::Lerp(PrevPose.Scale, Pose.Scale, interpolationFactor); + auto orient = Matrix::Lerp(PrevPose.Orientation.ToRotationMatrix(), Pose.Orientation.ToRotationMatrix(), interpolationFactor); + + World = (orient * Matrix::CreateScale(scale) * Matrix::CreateTranslation(pos)); + Sphere = BoundingSphere(Vector3::Transform(OriginalSphere.Center, World), OriginalSphere.Radius * std::max(std::max(Pose.Scale.x, Pose.Scale.y), Pose.Scale.z)); CacheLights = true; } }; 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/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h index c21c3f3e3..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"; @@ -352,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"; @@ -361,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"; diff --git a/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h b/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h index 5d9f078f9..a23f2d348 100644 --- a/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h +++ b/TombEngine/Scripting/Internal/TEN/Collision/MaterialTypes.h @@ -6,7 +6,10 @@ // @enum Collision.MaterialType // @pragma nostrip -/// Table of MaterialType constants. To be used with @{Collision.Probe.GetFloorMaterialType} and @{Collision.Probe.GetCeilingMaterialType}. +/// 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/Effects/BlendIDs.h b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h index a68d656b9..744efb496 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h +++ b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h @@ -9,16 +9,18 @@ namespace TEN::Scripting::Effects // @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` - // - `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. // // @table Effects.BlendID diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp index ba5dc17e9..6463e6e3f 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp +++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp @@ -46,19 +46,19 @@ 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. + /// Emit a lightning arc. // @function EmitLightningArc // @tparam Vec3 origin // @tparam Vec3 target - // @tparam Color color (default Color(255, 255, 255)) - // @tparam float life Lifetime in seconds. Clamped to [0, 4.233] for now because of strange internal maths. __default: 1__ - // @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__ + // @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) { @@ -113,18 +113,18 @@ namespace TEN::Scripting::Effects // @tparam Vec3 pos World position. // @tparam Vec3 vel Directional velocity. // @tparam int spriteID Sprite ID in the sprite sequence slot. - // @tparam float gravity Effect of gravity. Positive value ascends, negative value descends. __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 at end of life. 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.ALPHA_BLEND__ - // @tparam float startSize Size at start of life. __default: 10__ - // @tparam float endSize Size at end of life. __default: 0__ - // @tparam float life Lifespan in seconds. __default: 2__ - // @tparam bool damage Harm the player on collision. __default: false__ - // @tparam bool poison Poison the player on collision. __default: false__ - // @tparam Objects.ObjID.SpriteConstants spriteSeqID Sprite sequence slot ID. __default: Objects.ObjID.DEFAULT_SPRITES__ - // @tparam float startRot Rotation at start of life. __default: random__ + // @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, @@ -223,7 +223,7 @@ namespace TEN::Scripting::Effects /// 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. + // @tparam ParticleData particleData Table containing particle data. // @usage // local particle = // { @@ -261,31 +261,31 @@ namespace TEN::Scripting::Effects // @table ParticleData // @tfield Vec3 pos World position. // @tfield Vec3 vel Directional velocity in world units per second. - // @tfield[opt] Objects.ObjID.SpriteConstants spriteSeqID Sprite sequence slot ID. __default: Objects.ObjID.DEFAULT_SPRITES__ - // @tfield[opt] int spriteID Sprite ID in the sprite sequence slot. __default: 0__ - // @tfield[opt] float life Lifespan in seconds. __default: 2__ - // @tfield[opt] float maxYVel Maximum vertical velocity in world units per second. __default: 0__ - // @tfield[opt] float gravity Effect of gravity in world units per second. Positive value ascend, negative value descend. __default: 0__ - // @tfield[opt] float friction Friction affecting velocity over time in world units per second. __default: 0__ - // @tfield[opt] float startRot Rotation at start of life. __default: random__ - // @tfield[opt] float rotVel Rotational velocity in degrees per second. __default: 0__ - // @tfield[opt] float startSize Size at start of life. __default: 10__ - // @tfield[opt] float endSize Size at end of life. __default: 0__ - // @tfield[opt] Color startColor Color at start of life. __default: Color(255, 255, 255)__ - // @tfield[opt] Color endColor 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)__ - // @tfield[opt] Effects.BlendID blendMode Render blend mode. __default: TEN.Effects.BlendID.ALPHA_BLEND__ - // @tfield[opt] bool damage Harm the player on collision. __default: false__ - // @tfield[opt] bool poison Poison the player on collision. __default: false__ - // @tfield[opt] bool burn Burn the player on collision. __default: false__ - // @tfield[opt] bool wind Affect position by wind in outside rooms. __default: false__ - // @tfield[opt] int damageHit Player damage amount on collision. __default: 2__ - // @tfield[opt] bool light Emit a colored light. CAUTION: Recommended only for a single particle. Too many particles with lights can overwhelm the lighting system. __default: false__ - // @tfield[opt] int lightRadius Light radius in 1/4 blocks. __default: 0__ - // @tfield[opt] int lightFlicker Interval at which the light should flicker. __default: 0__ - // @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. __default: none__ - // @tfield[opt] bool animated Play animates sprite sequence. __default: false__ - // @tfield[opt] Effects.ParticleAnimationType animType Animation type of the sprite sequence. __default: TEN.Effects.ParticleAnimationType.LOOP__ - // @tfield[opt] float frameRate Sprite sequence animation framerate. __default: 1__ + // @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; @@ -402,14 +402,14 @@ namespace TEN::Scripting::Effects /// 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 + // @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) { @@ -444,10 +444,10 @@ namespace TEN::Scripting::Effects // 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) + // @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)); @@ -460,12 +460,12 @@ namespace TEN::Scripting::Effects // @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) + // @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)); @@ -478,7 +478,7 @@ namespace TEN::Scripting::Effects /// Emit blood. // @function EmitBlood // @tparam Vec3 pos - // @tparam int count Sprite count. __default: 1__ + // @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)); @@ -487,8 +487,8 @@ namespace TEN::Scripting::Effects /// 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; @@ -502,8 +502,8 @@ namespace TEN::Scripting::Effects /// 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 Fire size. __default: 1__ + // @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(pos.ToVector3i()), ValueOr(size, 1)); @@ -512,8 +512,8 @@ namespace TEN::Scripting::Effects /// Make an explosion. Does not hurt Lara // @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 hurt Lara + // @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))); @@ -521,7 +521,7 @@ namespace TEN::Scripting::Effects /// 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. + // @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); @@ -540,20 +540,20 @@ namespace TEN::Scripting::Effects /// Emit an extending streamer effect. // @function EmitStreamer // @tparam Moveable mov Moveable object with which to associate the effect. - // @tparam int[opt] tag Numeric tag with which to associate the effect on the moveable. __Default: 0__ + // @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] float rot Start rotation in degrees. __Default: 0__ - // @tparam[opt] Color startColor Color at the start of life. __Default: Color(255, 255, 255, 255))__ - // @tparam[opt] Color endColor Color at the end of life. __Default: Color(0, 0, 0, 0))__ - // @tparam[opt] float width Width in world units. __Default: 0__ - // @tparam[opt] float life Lifetime in seconds. __Default: 1__ - // @tparam[opt] float vel Movement velocity in world units per second. __Default: 0__ - // @tparam[opt] float expRate Width expansion rate in world units per second. __Default: 0__ - // @tparam[opt] float rotRate Rotation rate in degrees per second. __Default: 0__ - // @tparam[opt] Effects.StreamerFeatherMode edgeFeatherMode Edge feather mode. __Default: Effects.StreamerFeatherMode.NONE__ - // @tparam[opt] Effects.StreamerFeatherMode lengthFeatherMode Length feather mode. __UNIMPLEMENTED, currently will always leave a fading tail__ - // @tparam[opt] Effects.BlendID blendID Renderer blend ID. __Default: Effects.BlendID.ALPHA_BLEND__ + // @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) 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 705143056..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,7 +239,7 @@ 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); @@ -270,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); @@ -407,11 +411,17 @@ 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; diff --git a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h index 976397ca9..6d826f769 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h +++ b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h @@ -69,6 +69,7 @@ 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); diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp index b269ff2cb..932db5bd2 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp @@ -37,8 +37,8 @@ void Fog::Register(sol::table& parent) /*** @tparam Color color RGB color -@tparam int min Distance at which fog starts (in sectors) -@tparam int max Distance at which fog reaches the maximum strength (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 */ diff --git a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp index 9d229fb41..91b4dcd09 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp @@ -11,15 +11,14 @@ /*** 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: @@ -27,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 @@ -35,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/Level/FlowLevel.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp index 2b5c0aea8..a9a7bb7cf 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp @@ -24,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, @@ -40,11 +39,11 @@ 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, @@ -57,12 +56,12 @@ void Level::Register(sol::table& parent) //@mem layer2 "layer2", &Level::Layer2, -/// (@{Flow.Horizon}) First horizon layer. +/// (@{Flow.Horizon}) Primary horizon object. //@mem horizon1 "horizon1", &Level::Horizon1, "horizon", sol::property(&Level::GetHorizon1Enabled, &Level::SetHorizon1Enabled), // Compatibility. -/// (@{Flow.Horizon}) Second horizon layer. +/// (@{Flow.Horizon}) Secondary horizon object. //@mem horizon2 "horizon2", &Level::Horizon2, @@ -80,7 +79,7 @@ void Level::Register(sol::table& parent) "fog", &Level::Fog, /// (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, @@ -94,19 +93,10 @@ void Level::Register(sol::table& parent) //@mem weatherStrength "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.__ Only types `Normal` and `Young` are guaranteed to work. @mem laraType*/ "laraType", &Level::Type, diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp index cb65ca8d7..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, true, 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, true, false, Vec3(-10, 130, 45) }; - 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, true, 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, 42) }; - 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, true, 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() }; - 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() }; - 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() }; - 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() }; + 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 for 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,67 +258,67 @@ 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. Applicable only for firearms. + // @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. + // @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. Applicable only for firearms. + // @tfield Vec3 muzzleOffset specifies offset for spawning muzzle gunflash effects. "muzzleOffset", &WeaponSettings::MuzzleOffset); } @@ -333,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/SkyLayer/SkyLayer.cpp b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp index 33bf45fa1..7f9ca11f3 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp @@ -19,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. @@ -38,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 09176ce75..dcb1eaca5 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp @@ -66,7 +66,7 @@ namespace TEN::Scripting // @tparam int meteorCount Meteor count. __Max: 100__ // @tparam int meteorSpawnDensity Meteor spawn density. // @tparam int meteorVel Meteor velocity. - // @treturn StarField A new Starfield object. + // @treturn Starfield A new Starfield object. Starfield::Starfield(int starCount, int meteorCount, int meteorSpawnDensity, float meteorVel) { if (starCount < 0 || starCount > STAR_COUNT_MAX) diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp index 1dc5cbf69..cc9bef77d 100644 --- a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp +++ b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp @@ -21,47 +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. + @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/Input/InputHandler.cpp b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp index f68607d88..7f604d502 100644 --- a/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp @@ -96,7 +96,7 @@ namespace TEN::Scripting::Input } /// 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 e1cf4ed6b..1ec40f0f5 100644 --- a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp @@ -342,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) { @@ -951,7 +951,7 @@ std::unique_ptr GetByName(const std::string& type, const std::string& name, c @section specialobjects */ -/*** A @{Objects.Moveable} representing Lara herself. +/*** An @{Objects.Moveable} entry representing Lara herself. @table Lara */ void LogicHandler::ResetVariables() diff --git a/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp index cbcb5548b..a76cffdb0 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp @@ -27,67 +27,65 @@ void AIObject::Register(sol::table& parent) sol::meta_function::index, IndexError, sol::meta_function::new_index, NewIndexError, - /// Get the object's position + /// Get the object's position. // @function AIObject:GetPosition - // @treturn Vec3 a copy of the object's position + // @treturn Vec3 A copy of the object's position. ScriptReserved_GetPosition, &AIObject::GetPos, - /// Set the object's position + /// Set the object's position. // @function AIObject:SetPosition - // @tparam Vec3 position the new position of the object + // @tparam Vec3 position The new position of the object. ScriptReserved_SetPosition, &AIObject::SetPos, /// Get the object's Y-axis rotation. - // To the best of my knowledge, the rotation of an AIObject has no effect. // @function AIObject:GetRotationY - // @treturn number the object's Y-axis rotation + // @treturn int The object's Y-axis rotation. ScriptReserved_GetRotationY, &AIObject::GetYRot, /// Set the object's Y-axis rotation. - // To the best of my knowledge, the rotation of an AIObject has no effect. // @function AIObject:SetRotationY - // @tparam number rotation The object's new Y-axis rotation + // @tparam int rotation The object's new Y-axis rotation. ScriptReserved_SetRotationY, &AIObject::SetYRot, - /// Get the object's unique string identifier + /// Get the object's unique string identifier. // @function AIObject:GetName - // @treturn string the object's name + // @treturn string The object's name. ScriptReserved_GetName, &AIObject::GetName, - /// Set the object's name (its unique string identifier) + /// Set the object's unique string identifier. // @function AIObject:SetName - // @tparam string name The object's new name + // @tparam string name The object's new name. ScriptReserved_SetName, &AIObject::SetName, - /// Get the current room of the object + /// Get the current room of the object. // @function AIObject:GetRoom - // @treturn Room current room of the object + // @treturn Objects.Room current room of the object. ScriptReserved_GetRoom, &AIObject::GetRoom, - /// Get the current room number of the object + /// Get the current room number of the object. // @function AIObject:GetRoomNumber - // @treturn int number representing the current room of the object + // @treturn int Number representing the current room of the object. ScriptReserved_GetRoomNumber, &AIObject::GetRoomNumber, - /// Set room number of the object + /// Set room number of the object. // This is used in conjunction with SetPosition to teleport the object to a new room. // @function AIObject:SetRoomNumber - // @tparam int ID the ID of the new room + // @tparam int ID The ID of the new room. ScriptReserved_SetRoomNumber, &AIObject::SetRoomNumber, - /// Retrieve the object ID + /// Retrieve the object ID. // @function AIObject:GetObjectID - // @treturn int a number representing the ID of the object + // @treturn int A number representing the ID of the object. ScriptReserved_GetObjectID, &AIObject::GetObjectID, - /// Change the object's ID. This will change the type of AI object it is. + /// Change the object ID. This will change the type of AI object it is. // Note that a baddy will gain the behaviour of the tile it's on _before_ said baddy is triggered. // This means that changing the type of an AI object beneath a moveable will have no effect. // Instead, this function can be used to change an object that the baddy isn't standing on. // For example, you could have a pair of AI_GUARD objects, and change one or the other two // AI_PATROL_1 based on whether the player has a certain item or not. // @function AIObject:SetObjectID - // @tparam Objects.ObjID ID the new ID + // @tparam Objects.ObjID ID the new ID. // @usage // aiObj = TEN.Objects.GetMoveableByName("ai_guard_sphinx_room") // aiObj:SetObjectID(TEN.Objects.ObjID.AI_PATROL1) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp index 1420b3058..e82b9faa3 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp @@ -29,45 +29,45 @@ void CameraObject::Register(sol::table& parent) sol::meta_function::index, IndexError, sol::meta_function::new_index, NewIndexError, - /// Get the camera's position + /// Get the camera's position. // @function Camera:GetPosition - // @treturn Vec3 a copy of the camera's position + // @treturn Vec3 Camera's position. ScriptReserved_GetPosition, &CameraObject::GetPos, - /// Set the camera's position + /// Set the camera's position. // @function Camera:SetPosition - // @tparam Vec3 position the new position of the camera + // @tparam Vec3 position The new position of the camera. ScriptReserved_SetPosition, &CameraObject::SetPos, /// Get the camera's unique string identifier // @function Camera:GetName - // @treturn string the camera's name + // @treturn string the camera's name. ScriptReserved_GetName, &CameraObject::GetName, - /// Set the camera's name (its unique string identifier) + /// Set the camera's name (its unique string identifier). // @function Camera:SetName - // @tparam string name The camera's new name + // @tparam string name The camera's new name. ScriptReserved_SetName, &CameraObject::SetName, - /// Get the current room of the camera + /// Get the current room of the camera. // @function Camera:GetRoom - // @treturn Room current room of the camera + // @treturn Objects.Room Current room of the camera. ScriptReserved_GetRoom, &CameraObject::GetRoom, - /// Get the current room number of the camera + /// Get the current room number of the camera. // @function Camera:GetRoomNumber - // @treturn int number representing the current room of the camera + // @treturn int Number representing the current room of the camera. ScriptReserved_GetRoomNumber, &CameraObject::GetRoomNumber, - /// Set room of camera + /// Set room of camera. // This is used in conjunction with SetPosition to teleport the camera to a new room. // @function Camera:SetRoomNumber - // @tparam int ID the ID of the new room + // @tparam int ID The ID of the new room. ScriptReserved_SetRoomNumber, &CameraObject::SetRoomNumber, - /// Active the camera during that frame. + /// Activate the camera for the current game frame. // @function Camera:PlayCamera - // @tparam[opt] Moveable Target If you put a moveable, the camera will look at it. Otherwise, it will look at Lara. + // @tparam[opt] Objects.Moveable target If you put a moveable, the camera will look at it. Otherwise, it will look at Lara. ScriptReserved_PlayCamera, &CameraObject::PlayCamera); } diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp index 01516a829..04e7dd90b 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp @@ -2,6 +2,7 @@ #include "LaraObject.h" #include "Game/camera.h" +#include "Game/collision/collide_item.h" #include "Game/effects/item_fx.h" #include "Game/Lara/lara.h" #include "Game/Lara/lara_fire.h" @@ -9,10 +10,18 @@ #include "Game/Lara/lara_struct.h" #include "Objects/Generic/Object/burning_torch.h" #include "Scripting/Internal/ReservedScriptNames.h" +#include "Scripting/Internal/TEN/Input/ActionIDs.h" #include "Scripting/Internal/TEN/Objects/Lara/AmmoTypes.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 "Specific/Input/Input.h" +#include "Specific/Input/InputAction.h" #include "Specific/level.h" -/// Class for extra player-only functions. +using namespace TEN::Input; + +/// Class for player-only functions. // Do not try to create an object of this type. Use the built-in *Lara* variable instead. // LaraObject inherits all the functions of @{Objects.Moveable|Moveable}. // @@ -22,9 +31,9 @@ constexpr auto LUA_CLASS_NAME{ ScriptReserved_LaraObject }; using namespace TEN::Entities::Generic; -/// Set player poison. +/// Set the player's poison value. // @function LaraObject:SetPoison -// @tparam[opt] int poison Poison strength. Maximum value is 128 (default 0) +// @tparam[opt] int poison New poison value. __default: 0, max: 128__ // @usage // Lara:SetPoison(10) void LaraObject::SetPoison(sol::optional potency) @@ -41,9 +50,9 @@ void LaraObject::SetPoison(sol::optional potency) } } -/// Get poison potency of Lara. +/// Get the player's poison value. // @function LaraObject:GetPoison -// @treturn int Current poison potency. +// @treturn int Poison value. // @usage // local poisonPotency = Lara:GetPoison() int LaraObject::GetPoison() const @@ -52,9 +61,9 @@ int LaraObject::GetPoison() const return lara->Status.Poison; } -/// Set air value of Lara. +/// Set the player's air value. // @function LaraObject:SetAir -// @tparam int air Air value to give Lara. Maximum value is 1800. +// @tparam int air New air value. __max: 1800__ // @usage // Lara:SetAir(100) void LaraObject::SetAir(sol::optional air) @@ -67,9 +76,9 @@ void LaraObject::SetAir(sol::optional air) lara->Status.Air = LARA_AIR_MAX; } -/// Get air value of Lara. +/// Get the player's air value. // @function LaraObject:GetAir -// @treturn int Current air value. +// @treturn int Air value. // @usage // local currentAir = Lara:GetAir() int LaraObject::GetAir() const @@ -78,9 +87,9 @@ int LaraObject::GetAir() const return lara->Status.Air; } -/// Set wetness value of Lara (causes dripping). +/// Set the player's wetness value, causing drips. // @function LaraObject:SetWet -// @tparam int wetness Wetness value. Maximum value is 255. +// @tparam int wetness New wetness value. __max: 255__ // @usage // Lara:SetWet(100) void LaraObject::SetWet(sol::optional wetness) @@ -92,9 +101,9 @@ void LaraObject::SetWet(sol::optional wetness) i = value; } -/// Get wetness value of Lara. +/// Get the player's wetness value. // @function LaraObject:GetWet -// @treturn int Current wetness value. +// @treturn int Wetness value. // @usage // local dripAmount = Lara:GetWet() int LaraObject::GetWet() const @@ -103,9 +112,9 @@ int LaraObject::GetWet() const return lara->Effect.DripNodes[0]; } -/// Set sprint energy value of Lara. +/// Set the player's stamina value. // @function LaraObject:SetStamina -// @tparam int stamina Stamina to give to Lara. Maximum value is 120. +// @tparam int New stamina value. __max: 120__ // @usage // Lara:SetStamina(120) void LaraObject::SetStamina(sol::optional value) @@ -113,14 +122,18 @@ void LaraObject::SetStamina(sol::optional value) auto* lara = GetLaraInfo(_moveable); if (value.has_value()) + { lara->Status.Stamina = std::clamp(value.value(), 0, (int)LARA_STAMINA_MAX); + } else + { lara->Status.Stamina = LARA_STAMINA_MAX; + } } -/// Get stamina value of Lara. +/// Get the player's stamina value. // @function LaraObject:GetStamina -// @treturn int Current sprint value. +// @treturn int Stamina value. // @usage // local sprintEnergy = Lara:GetStamina() int LaraObject::GetStamina() const @@ -129,23 +142,23 @@ int LaraObject::GetStamina() const return lara->Status.Stamina; } -/// Get the moveable's airborne status. +/// Get the player's airborne status (set when jumping and falling). // @function Moveable:GetAirborne -// @treturn bool True if Lara state must react to aerial forces. +// @treturn bool True if airborne, otherwise false. bool LaraObject::GetAirborne() const { return _moveable->Animation.IsAirborne; } -/// Set the moveable's airborne status. +/// Set the player's airborne status. // @function Moveable:SetAirborne -// @tparam bool airborne New airborne status for Lara. +// @tparam bool airborne New airborne status. void LaraObject::SetAirborne(bool newAirborne) { _moveable->Animation.IsAirborne = newAirborne; } -/// Lara will undraw her weapon if it is drawn and throw away a flare if she is currently holding one. +/// Undraw a weapon if it is drawn and throw away a flare if currently holding one. // @function LaraObject:UndrawWeapon // @usage // Lara:UndrawWeapon() @@ -160,32 +173,30 @@ void LaraObject::UndrawWeapon() } } -/// Lara will throw away the torch if she currently holds one in her hand. -// @function LaraObject:ThrowAwayTorch +/// Discard a held torch. +// @function LaraObject:DiscardTorch // @usage -// Lara:ThrowAwayTorch() -void LaraObject::ThrowAwayTorch() +// Lara:DiscardTorch() +void LaraObject::DiscardTorch() { - auto* lara = GetLaraInfo(_moveable); + auto& player = GetLaraInfo(*_moveable); - if (lara->Control.Weapon.GunType == LaraWeaponType::Torch) - { - Lara.Torch.State = TorchState::Dropping; - } + if (player.Control.Weapon.GunType == LaraWeaponType::Torch) + player.Torch.State = TorchState::Dropping; } -/// Get actual hand status of Lara. +/// Get the player's hand status. // @function LaraObject:GetHandStatus // @usage // local handStatus = Lara:GetHandStatus() -// @treturn Objects.HandStatus Current hand status. +// @treturn Objects.HandStatus Hand status. HandStatus LaraObject::GetHandStatus() const { auto* lara = GetLaraInfo(_moveable); return HandStatus{ lara->Control.HandStatus }; } -/// Get actual weapon type of Lara. +/// Get the player's weapon type. // @function LaraObject:GetWeaponType // @usage // local weaponType = Lara:GetWeaponType() @@ -196,7 +207,7 @@ LaraWeaponType LaraObject::GetWeaponType() const return LaraWeaponType{ lara->Control.Weapon.GunType }; } -/// Set Lara weapon type. +/// Set the player's weapon type. // @function LaraObject:SetWeaponType // @usage // Lara:SetWeaponType(WeaponType.PISTOLS, false) @@ -334,7 +345,7 @@ int LaraObject::GetAmmoCount() const /// Get current vehicle, if it exists. // @function LaraObject:GetVehicle -// @treturn Objects.Moveable current vehicle (nil if no vehicle present). +// @treturn Objects.Moveable Current vehicle (nil if no vehicle present). // @usage // local vehicle = Lara:GetVehicle() std::unique_ptr LaraObject::GetVehicle() const @@ -377,41 +388,148 @@ std::unique_ptr LaraObject::GetPlayerInteractedMoveable() const return std::make_unique(player.Context.InteractedItem); } -/// Get current light state of the torch, if it exists -// @function LaraObject:TorchIsLit -// @treturn bool is torch currently lit or not? (false if no torch exists) +/// Check if a held torch is lit. +// @function LaraObject:IsTorchLit +// @treturn bool True if lit, otherwise false (also false if there is no torch in hand). // @usage -// local torchIsLit = Lara:TorchIsLit() -bool LaraObject::TorchIsLit() const +// local isTorchLit = Lara:IsTorchLit() +bool LaraObject::IsTorchLit() const { - auto* lara = GetLaraInfo(_moveable); - return lara->Torch.IsLit; + const auto& player = GetLaraInfo(*_moveable); + return player.Torch.IsLit; +} + +/// Align the player with a moveable object for interaction. +// @function LaraObject:Interact +// @tparam Objects.Moveable mov Moveable object to align the player with. +// @tparam[opt=197 (BUTTON_PUSH)] int animNumber The animation to play after alignment is complete. +// @tparam[opt=Vec3(0, 0, 312)] Vec3 offset Relative position offset from the moveable. +// @tparam[opt=Vec3(-256, -512, 0)] Vec3 minOffsetConstraint Minimum relative offset constraint. +// @tparam[opt=Vec3(256, 0, 512)] Vec3 maxOffsetConstraint Maximum relative offset constraint. +// @tparam[opt=Rotation(-10, -40, -10)] Rotation minRotConstraint Minimum relative rotation constraint. +// @tparam[opt=Rotation(10, 40, 10)] Rotation maxRotConstraint Maximum relative rotation constraint. +// @tparam[opt=Input.ActionID.ACTION] Input.ActionID actionID Input action ID to trigger the alignment. +// @usage +// local Lara:Interact( +// moveable, 197, +// Vec3(0, 0, 312), Vec3(-256, -512, -256), Vec3(256, 0, 512), +// Rotation(-10, -30, -10), Rotation(10, 30, 10), TEN.Input.ActionID.ACTION) +void LaraObject::Interact(const Moveable& mov, TypeOrNil animNumber, + const TypeOrNil& offset, const TypeOrNil& offsetConstraintMin, const TypeOrNil& offsetConstraintMax, + const TypeOrNil& rotConstraintMin, const TypeOrNil& rotConstraintMax, TypeOrNil actionID) const +{ + auto convertedOffset = ValueOr(offset, Vec3(0.0f, 0.0f, BLOCK(0.305f))).ToVector3i(); + auto convertedOffsetConstraintMin = ValueOr(offsetConstraintMin, Vec3(-BLOCK(0.25f), -BLOCK(0.5f), 0.0f)); + auto convertedOffsetConstraintMax = ValueOr(offsetConstraintMax, Vec3(BLOCK(0.25f), 0.0f, BLOCK(0.5f))); + auto convertedRotConstraintMin = ValueOr(rotConstraintMin, Rotation(-10.0f, -40.0f, -10.0f)).ToEulerAngles(); + auto convertedRotConstraintMax = ValueOr(rotConstraintMax, Rotation(10.0f, 40.0f, 10.0f)).ToEulerAngles(); + int convertedAnimNumber = ValueOr(animNumber, LA_BUTTON_SMALL_PUSH); + auto convertedActionID = ValueOr(actionID, In::Action); + + auto interactionBasis = ObjectCollisionBounds + { + GameBoundingBox( + convertedOffsetConstraintMin.x, convertedOffsetConstraintMax.x, + convertedOffsetConstraintMin.y, convertedOffsetConstraintMax.y, + convertedOffsetConstraintMin.z, convertedOffsetConstraintMax.z), + std::pair( + convertedRotConstraintMin, + convertedRotConstraintMax) + }; + + auto& player = GetLaraInfo(*_moveable); + auto& interactedItem = g_Level.Items[mov.GetIndex()]; + + bool isUnderwater = (player.Control.WaterStatus == WaterStatus::Underwater); + bool isPlayerIdle = ((!isUnderwater && _moveable->Animation.ActiveState == LS_IDLE && _moveable->Animation.AnimNumber == LA_STAND_IDLE) || + (isUnderwater && _moveable->Animation.ActiveState == LS_UNDERWATER_IDLE && _moveable->Animation.AnimNumber == LA_UNDERWATER_IDLE)); + + if ((player.Control.IsMoving && player.Context.InteractedItem == interactedItem.Index) || + (IsHeld(convertedActionID) && player.Control.HandStatus == HandStatus::Free && isPlayerIdle)) + { + if (TestLaraPosition(interactionBasis, &interactedItem, _moveable)) + { + if (MoveLaraPosition(convertedOffset, &interactedItem, _moveable)) + { + ResetPlayerFlex(_moveable); + SetAnimation(_moveable, convertedAnimNumber); + + _moveable->Animation.FrameNumber = GetAnimData(_moveable).frameBase; + player.Control.IsMoving = false; + player.Control.HandStatus = HandStatus::Busy; + } + else + { + player.Context.InteractedItem = interactedItem.Index; + } + } + } +} + +/// Test the player against a moveable object for interaction. +// @function LaraObject:TestInteraction +// @tparam Objects.Moveable mov Moveable object to align the player with. +// @tparam[opt=Vec3(-256, -512, 0)] Vec3 minOffsetConstraint Minimum relative offset constraint. +// @tparam[opt=Vec3(256, 0, 512)] Vec3 maxOffsetConstraint Maximum relative offset constraint. +// @tparam[opt=Rotation(-10, -40, -10)] Rotation minRotConstraint Minimum relative rotation constraint. +// @tparam[opt=Rotation(10, 40, 10)] Rotation maxRotConstraint Maximum relative rotation constraint. +bool LaraObject::TestInteraction(const Moveable& mov, + const TypeOrNil& offsetConstraintMin, const TypeOrNil& offsetConstraintMax, + const TypeOrNil& rotConstraintMin, const TypeOrNil& rotConstraintMax) const +{ + auto convertedOffsetConstraintMin = ValueOr(offsetConstraintMin, Vec3(-BLOCK(0.25f), -BLOCK(0.5f), 0)); + auto convertedOffsetConstraintMax = ValueOr(offsetConstraintMax, Vec3(BLOCK(0.25f), 0, BLOCK(0.5f))); + auto convertedRotConstraintMin = ValueOr(rotConstraintMin, Rotation(-10.0f, -40.0f, -10.0f)).ToEulerAngles(); + auto convertedRotConstraintMax = ValueOr(rotConstraintMax, Rotation(10.0f, 40.0f, 10.0f)).ToEulerAngles(); + + auto interactionBasis = ObjectCollisionBounds + { + GameBoundingBox( + convertedOffsetConstraintMin.x, convertedOffsetConstraintMax.x, + convertedOffsetConstraintMin.y, convertedOffsetConstraintMax.y, + convertedOffsetConstraintMin.z, convertedOffsetConstraintMax.z), + std::pair( + convertedRotConstraintMin, + convertedRotConstraintMax) + }; + + auto& item = g_Level.Items[mov.GetIndex()]; + return (TestLaraPosition(interactionBasis, &item, _moveable)); } void LaraObject::Register(sol::table& parent) { - parent.new_usertype(LUA_CLASS_NAME, - ScriptReserved_SetPoison, &LaraObject::SetPoison, - ScriptReserved_GetPoison, &LaraObject::GetPoison, - ScriptReserved_SetAir, &LaraObject::SetAir, - ScriptReserved_GetAir, &LaraObject::GetAir, - ScriptReserved_SetWet, &LaraObject::SetWet, - ScriptReserved_GetWet, &LaraObject::GetWet, - ScriptReserved_SetStamina, &LaraObject::SetStamina, - ScriptReserved_GetStamina, &LaraObject::GetStamina, - ScriptReserved_GetAirborne, &LaraObject::GetAirborne, - ScriptReserved_SetAirborne, &LaraObject::SetAirborne, - ScriptReserved_UndrawWeapon, &LaraObject::UndrawWeapon, - ScriptReserved_ThrowAwayTorch, &LaraObject::ThrowAwayTorch, - ScriptReserved_GetHandStatus, &LaraObject::GetHandStatus, - ScriptReserved_GetWeaponType, &LaraObject::GetWeaponType, - ScriptReserved_SetWeaponType, &LaraObject::SetWeaponType, - ScriptReserved_GetAmmoType, &LaraObject::GetAmmoType, - ScriptReserved_GetAmmoCount, &LaraObject::GetAmmoCount, - ScriptReserved_GetVehicle, &LaraObject::GetVehicle, - ScriptReserved_GetTarget, &LaraObject::GetTarget, - ScriptReserved_GetPlayerInteractedMoveable, &LaraObject::GetPlayerInteractedMoveable, - ScriptReserved_TorchIsLit, &LaraObject::TorchIsLit, - sol::base_classes, sol::bases() - ); + parent.new_usertype( + LUA_CLASS_NAME, + + ScriptReserved_SetPoison, &LaraObject::SetPoison, + ScriptReserved_GetPoison, &LaraObject::GetPoison, + ScriptReserved_SetAir, &LaraObject::SetAir, + ScriptReserved_GetAir, &LaraObject::GetAir, + ScriptReserved_SetWet, &LaraObject::SetWet, + ScriptReserved_GetWet, &LaraObject::GetWet, + ScriptReserved_SetStamina, &LaraObject::SetStamina, + ScriptReserved_GetStamina, &LaraObject::GetStamina, + ScriptReserved_GetAirborne, &LaraObject::GetAirborne, + ScriptReserved_SetAirborne, &LaraObject::SetAirborne, + ScriptReserved_UndrawWeapon, &LaraObject::UndrawWeapon, + ScriptReserved_PlayerDiscardTorch, &LaraObject::DiscardTorch, + ScriptReserved_GetHandStatus, &LaraObject::GetHandStatus, + ScriptReserved_GetWeaponType, &LaraObject::GetWeaponType, + ScriptReserved_SetWeaponType, &LaraObject::SetWeaponType, + ScriptReserved_GetAmmoType, &LaraObject::GetAmmoType, + ScriptReserved_GetAmmoCount, &LaraObject::GetAmmoCount, + ScriptReserved_GetVehicle, &LaraObject::GetVehicle, + ScriptReserved_GetTarget, &LaraObject::GetTarget, + ScriptReserved_GetPlayerInteractedMoveable, &LaraObject::GetPlayerInteractedMoveable, + ScriptReserved_PlayerIsTorchLit, &LaraObject::IsTorchLit, + + ScriptReserved_PlayerInteract, &LaraObject::Interact, + ScriptReserved_PlayerTestInteraction, &LaraObject::TestInteraction, + + // COMPATIBILITY + "TorchIsLit", &LaraObject::IsTorchLit, + "ThrowAwayTorch", &LaraObject::DiscardTorch, + + sol::base_classes, sol::bases()); } diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h index 4b519bece..4ab00914e 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h @@ -1,6 +1,7 @@ #pragma once #include "Game/Lara/lara_struct.h" +#include "Scripting/Internal/TEN/Input/ActionIDs.h" #include "Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h" // TODO: Organise. @@ -19,6 +20,7 @@ public: int GetWet() const; bool GetAirborne() const; void SetAirborne(bool newAirborne); + std::unique_ptr GetVehicle() const; std::unique_ptr GetTarget() const; std::unique_ptr GetPlayerInteractedMoveable() const; @@ -27,8 +29,17 @@ public: void SetWeaponType(LaraWeaponType weaponType, bool activate); int GetAmmoType() const; int GetAmmoCount() const; + void UndrawWeapon(); - void ThrowAwayTorch(); - bool TorchIsLit() const; + void DiscardTorch(); + bool IsTorchLit() const; + + void Interact(const Moveable& mov, TypeOrNil animNumber, + const TypeOrNil& offset, const TypeOrNil& offsetConstraintMin, const TypeOrNil& offsetConstraintMax, + const TypeOrNil& rotConstraintMin, const TypeOrNil& rotConstraintMax, TypeOrNil actionID) const; + bool TestInteraction(const Moveable& mov, + const TypeOrNil& offsetConstraintMin, const TypeOrNil& offsetConstraintMax, + const TypeOrNil& rotConstraintMin, const TypeOrNil& rotConstraintMax) const; + using Moveable::Moveable; }; diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp index 04e4e000b..6bd11a4e0 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp @@ -41,17 +41,17 @@ associated getters and setters. If you do not know what to set for these, most can just be ignored (see usage). @function Moveable - @tparam Objects.ObjID object ID + @tparam Objects.ObjID objectID Object ID. @tparam string name Lua name. - @tparam Vec3 position position in level - @tparam Rotation rotation rotation rotation about x, y, and z axes (default Rotation(0, 0, 0)) - @tparam int roomNumber the room number the moveable is in (default: calculated automatically). - @tparam int animNumber animation number - @tparam int frameNumber frame number - @tparam int hp Hit points. - @tparam int OCB Object code bits. - @tparam table AIBits table with AI bits (default { 0, 0, 0, 0, 0, 0 }) - @treturn Moveable A new Moveable object (a wrapper around the new object) + @tparam Vec3 position Position in level. + @tparam[opt] Rotation rotation Rotation about x, y, and z axes. + @tparam[opt] int roomNumber The room number the moveable is in. Needed if you are dealing with overlapping rooms and need to force certain room number. + @tparam[opt] int animNumber Animation number. + @tparam[opt] int frameNumber Frame number. + @tparam[opt] int hp Hit points. + @tparam[opt] int OCB Object code bits. + @tparam[opt] table AIBits Table with six AI bits. + @treturn Objects.Moveable A new Moveable object. @usage local item = Moveable( @@ -94,6 +94,10 @@ static std::unique_ptr Create(GAME_OBJECT_ID objID, const std::string& { scriptMov->SetHP(std::get(hp)); } + else + { + scriptMov->SetHP(Objects[objID].HitPoints); + } scriptMov->SetOcb(ValueOr(ocb, 0)); scriptMov->SetAIBits(ValueOr(aiBits, aiBitsType{})); @@ -242,9 +246,9 @@ void Moveable::Initialize() _initialized = true; } -/// Retrieve the object ID +/// Retrieve the object ID. // @function Moveable:GetObjectID -// @treturn Objects.ObjID a number representing the ID of the object. +// @treturn Objects.ObjID A number representing the ID of the object. GAME_OBJECT_ID Moveable::GetObjectID() const { return _moveable->ObjectNumber; @@ -252,7 +256,7 @@ GAME_OBJECT_ID Moveable::GetObjectID() const /// Change the object's ID. This will literally change the object. // @function Moveable:SetObjectID -// @tparam Objects.ObjID objectID the new ID +// @tparam Objects.ObjID objectID The new ID. // @usage // shiva = TEN.Objects.GetMoveableByName("shiva_60") // shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM) @@ -291,17 +295,17 @@ int Moveable::GetIndex() const /// Set the name of the function to be called when the moveable is shot by Lara. // Note that this will be triggered twice when shot with both pistols at once. // @function Moveable:SetOnHit -// @tparam function callback function in LevelFuncs hierarchy to call when moveable is shot +// @tparam function function Callback function in LevelFuncs hierarchy to call when moveable is shot. void Moveable::SetOnHit(const TypeOrNil& cb) { SetLevelFuncCallback(cb, ScriptReserved_SetOnHit, *this, _moveable->Callbacks.OnHit); } -/// Set the name of the function to be called when the moveable is destroyed/killed +/// Set the name of the function to be called when the moveable is destroyed/killed. // Note that enemy death often occurs at the end of an animation, and not at the exact moment // the enemy's HP becomes zero. // @function Moveable:SetOnKilled -// @tparam function callback function in LevelFuncs hierarchy to call when enemy is killed +// @tparam function function Callback function in LevelFuncs hierarchy to call when moveable is killed. // @usage // LevelFuncs.baddyKilled = function(theBaddy) print("You killed a baddy!") end // baddy:SetOnKilled(LevelFuncs.baddyKilled) @@ -310,9 +314,9 @@ void Moveable::SetOnKilled(const TypeOrNil& cb) SetLevelFuncCallback(cb, ScriptReserved_SetOnKilled, *this, _moveable->Callbacks.OnKilled); } -/// Set the function to be called when this moveable collides with another moveable +/// Set the function to be called when this moveable collides with another moveable. // @function Moveable:SetOnCollidedWithObject -// @tparam function func callback function to be called (must be in LevelFuncs hierarchy). This function can take two arguments; these will store the two @{Moveable}s taking part in the collision. +// @tparam function function Callback function to be called (must be in LevelFuncs hierarchy). This function can take two arguments; these will store the two @{Moveable}s taking part in the collision. // @usage // -- obj1 is the collision moveable // -- obj2 is the collider moveable @@ -328,7 +332,7 @@ void Moveable::SetOnCollidedWithObject(const TypeOrNil& cb) /// Set the function called when this moveable collides with room geometry (e.g. a wall or floor). This function can take an argument that holds the @{Moveable} that collided with geometry. // @function Moveable:SetOnCollidedWithRoom -// @tparam function func callback function to be called (must be in LevelFuncs hierarchy) +// @tparam function function Callback function to be called (must be in LevelFuncs hierarchy). // @usage // LevelFuncs.roomCollided = function(obj) // print(obj:GetName() .. " collided with room geometry") @@ -339,22 +343,18 @@ void Moveable::SetOnCollidedWithRoom(const TypeOrNil& cb) SetLevelFuncCallback(cb, ScriptReserved_SetOnCollidedWithRoom, *this, _moveable->Callbacks.OnRoomCollided); } -/// Get the moveable's name (its unique string identifier) -// e.g. "door\_back\_room" or "cracked\_greek\_statue" -// This corresponds with the "Lua Name" field in an object's properties in Tomb Editor. +/// Get the moveable's name (its unique string identifier). This corresponds with the "Lua Name" field in an object's properties in Tomb Editor. // @function Moveable:GetName -// @treturn string the moveable's name +// @treturn string The moveable's name. std::string Moveable::GetName() const { return _moveable->Name; } -/// Set the moveable's name (its unique string identifier) -// e.g. "door\_back\_room" or "cracked\_greek\_statue" -// It cannot be blank and cannot share a name with any existing object. +/// Set the moveable's name (its unique string identifier). It cannot be blank and cannot share a name with any existing object. // @function Moveable:SetName -// @tparam string name the new moveable's name -// @treturn bool true if we successfully set the name, false otherwise (e.g. if another object has the name already) +// @tparam string name The new moveable's name. +// @treturn bool true if name was successfully set, false otherwise (e.g. if another moveable has the name already). bool Moveable::SetName(const std::string& id) { if (!ScriptAssert(!id.empty(), "Name cannot be blank. Not setting name.")) @@ -382,21 +382,18 @@ bool Moveable::SetName(const std::string& id) return true; } -/// Get the moveable's position +/// Get the moveable's position. // @function Moveable:GetPosition -// @treturn Vec3 a copy of the moveable's position +// @treturn Vec3 Moveable's position. Vec3 Moveable::GetPosition() const { return Vec3(_moveable->Pose.Position); } -/// Set the moveable's position -// If you are moving a moveable whose behaviour involves knowledge of room geometry, -// (e.g. a BADDY1, which uses it for pathfinding), then the second argument should -// be true (or omitted, as true is the default). Otherwise, said moveable will not behave correctly. +/// Set the moveable's position. // @function Moveable:SetPosition -// @tparam Vec3 position the new position of the moveable -// @bool[opt] updateRoom Will room changes be automatically detected? Set to false if you are using overlapping rooms (default: true) +// @tparam Vec3 position The new position of the moveable. +// @bool[opt=true] updateRoom Will room changes be automatically detected? Set to false if you are using overlapping rooms. void Moveable::SetPosition(const Vec3& pos, sol::optional updateRoom) { constexpr auto BIG_DISTANCE_THRESHOLD = BLOCK(1); @@ -439,10 +436,10 @@ Vec3 Moveable::GetJointPos(int jointIndex, sol::optional offset) const return Vec3(GetJointPosition(_moveable, jointIndex, convertedOffset)); } -/// Get the object's joint rotation +/// Get the object's joint rotation. // @function Moveable:GetJointRotation // @tparam int index Index of a joint to get rotation. -// @treturn Rotation a calculated copy of the moveable's joint rotation +// @treturn Rotation Moveable's joint rotation. Rotation Moveable::GetJointRot(int jointIndex) const { auto point1 = GetJointPosition(_moveable, jointIndex); @@ -468,7 +465,7 @@ Rotation Moveable::GetJointRot(int jointIndex) const /// Get the moveable's rotation. // @function Moveable:GetRotation -// @treturn Rotation A copy of the moveable's rotation. +// @treturn Rotation Moveable's rotation. Rotation Moveable::GetRotation() const { return @@ -481,7 +478,7 @@ Rotation Moveable::GetRotation() const /// Get the moveable's visual scale. // @function Moveable:GetScale -// @treturn Vec3 A copy of the moveable's visual scale. +// @treturn Vec3 Moveable's visual scale. Vec3 Moveable::GetScale() const { return Vec3(_moveable->Pose.Scale); @@ -489,7 +486,7 @@ Vec3 Moveable::GetScale() const /// Set the moveable's rotation. // @function Moveable:SetRotation -// @tparam Rotation rotation The moveable's new rotation +// @tparam Rotation rotation The moveable's new rotation. void Moveable::SetRotation(const Rotation& rot) { constexpr auto BIG_ANGLE_THRESHOLD = ANGLE(30.0f); @@ -514,18 +511,18 @@ void Moveable::SetScale(const Vec3& scale) _moveable->Pose.Scale = scale.ToVector3(); } -/// Get current HP (hit points/health points) +/// Get current HP (hit points / health points). // @function Moveable:GetHP -// @treturn int the amount of HP the moveable currently has +// @treturn int The amount of HP the moveable currently has. short Moveable::GetHP() const { return _moveable->HitPoints; } -/// Set current HP (hit points/health points) +/// Set current HP (hit points / health points). // Clamped to [0, 32767] for "intelligent" entities (i.e. anything with AI); clamped to [-32767, 32767] otherwise. // @function Moveable:SetHP -// @tparam int HP the amount of HP to give the moveable +// @tparam int HP The amount of HP to give the moveable. void Moveable::SetHP(short hp) { if (Objects[_moveable->ObjectNumber].intelligent && hp < 0) @@ -541,25 +538,25 @@ void Moveable::SetHP(short hp) _moveable->HitPoints = hp; } -/// Get HP definded for that object type (hit points/health points) (Read Only). +/// Get HP definded for that object type (hit points / health points). // @function Moveable:GetSlotHP -// @treturn int the moveable's slot default hit points +// @treturn int The moveable's slot default hit points. short Moveable::GetSlotHP() const { return Objects[_moveable->ObjectNumber].HitPoints; } -/// Get OCB (object code bit) of the moveable +/// Get OCB (object code bit) of the moveable. // @function Moveable:GetOCB -// @treturn int the moveable's current OCB value +// @treturn int The moveable's current OCB value. short Moveable::GetOcb() const { return _moveable->TriggerFlags; } -/// Set OCB (object code bit) of the moveable +/// Set OCB (object code bit) of the moveable. // @function Moveable:SetOCB -// @tparam int OCB the new value for the moveable's OCB +// @tparam int OCB The new value for the moveable's OCB. void Moveable::SetOcb(short ocb) { _moveable->TriggerFlags = ocb; @@ -568,7 +565,7 @@ void Moveable::SetOcb(short ocb) /// Set the effect for this moveable. // @function Moveable:SetEffect // @tparam Effects.EffectID effect Type of effect to assign. -// @tparam[opt] float timeout time (in seconds) after which effect turns off. +// @tparam[opt] float timeout Time (in seconds) after which effect turns off. void Moveable::SetEffect(EffectType effectType, sol::optional timeout) { int realTimeout = timeout.has_value() ? int(timeout.value() * FPS) : -1; @@ -604,7 +601,7 @@ void Moveable::SetEffect(EffectType effectType, sol::optional timeout) } } -/// Set custom colored burn effect to moveable +/// Set custom colored burn effect to moveable. // @function Moveable:SetCustomEffect // @tparam Color color1 The primary color of the effect (also used for lighting). // @tparam Color color2 The secondary color of the effect. @@ -617,7 +614,7 @@ void Moveable::SetCustomEffect(const ScriptColor& col1, const ScriptColor& col2, ItemCustomBurn(_moveable, color1, color2, realTimeout); } -/// Get current moveable effect +/// Get current moveable effect. // @function Moveable:GetEffect // @treturn Effects.EffectID Effect type currently assigned. EffectType Moveable::GetEffect() const @@ -625,16 +622,16 @@ EffectType Moveable::GetEffect() const return _moveable->Effect.Type; } -/// Get the value stored in ItemFlags[index] +/// Get the value stored in ItemFlags[index]. // @function Moveable:GetItemFlags // @tparam int index Index of the ItemFlag, can be between 0 and 7. -// @treturn int the value contained in the ItemFlags[index] +// @treturn int The value contained in the ItemFlags[index]. short Moveable::GetItemFlags(int index) const { return _moveable->ItemFlags[index]; } -/// Stores a value in ItemFlags[index] +/// Stores a value in ItemFlags[index]. // @function Moveable:SetItemFlags // @tparam short value Value to store in the moveable's ItemFlags[index]. // @tparam int index Index of the ItemFlag where to store the value. @@ -643,9 +640,9 @@ void Moveable::SetItemFlags(short value, int index) _moveable->ItemFlags[index] = value; } -/// Get the location value stored in the Enemy AI +/// Get the location value stored in the Enemy AI. // @function Moveable:GetLocationAI -// @treturn short the value contained in the LocationAI of the creature. +// @treturn short The value contained in the LocationAI of the creature. short Moveable::GetLocationAI() const { if (_moveable->IsCreature()) @@ -674,23 +671,23 @@ void Moveable::SetLocationAI(short value) } } -/// Get the moveable's color +/// Get the moveable's color. // @function Moveable:GetColor -// @treturn Color a copy of the moveable's color +// @treturn Color Moveable's color. ScriptColor Moveable::GetColor() const { return ScriptColor{ _moveable->Model.Color }; } -/// Set the moveable's color +/// Set the moveable's color. // @function Moveable:SetColor -// @tparam Color color the new color of the moveable +// @tparam Color color The new color of the moveable. void Moveable::SetColor(const ScriptColor& color) { _moveable->Model.Color = color; } -/// Get AIBits of object +/// Get AIBits of object. // This will return a table with six values, each corresponding to // an active behaviour. If the object is in a certain AI mode, the table will // have a *1* in the corresponding cell. Otherwise, the cell will hold @@ -704,7 +701,7 @@ void Moveable::SetColor(const ScriptColor& color) // 6 - Patrol 2 // // @function Moveable:GetAIBits -// @treturn table a table of AI bits +// @treturn table A table of AI bits. aiBitsType Moveable::GetAIBits() const { static_assert(63 == ALL_AIOBJ); @@ -719,11 +716,11 @@ aiBitsType Moveable::GetAIBits() const return ret; } -/// Set AIBits of object +/// Set AIBits of object. // Use this to force a moveable into a certain AI mode or modes, as if a certain nullmesh // (or more than one) had suddenly spawned beneath their feet. // @function Moveable:SetAIBits -// @tparam table bits the table of AI bits +// @tparam table bits A table of AI bits. // @usage // local sas = TEN.Objects.GetMoveableByName("sas_enemy") // sas:SetAIBits({1, 0, 0, 0, 0, 0}) @@ -740,7 +737,7 @@ void Moveable::SetAIBits(aiBitsType const & bits) /// Retrieve the index of the current state. // This corresponds to the number shown in the item's state ID field in WadTool. // @function Moveable:GetState -// @treturn int the index of the active state +// @treturn int The index of the active state. int Moveable::GetStateNumber() const { return _moveable->Animation.ActiveState; @@ -749,7 +746,7 @@ int Moveable::GetStateNumber() const /// Retrieve the index of the target state. // This corresponds to the state the object is trying to get into, which is sometimes different from the active state. // @function Moveable:GetTargetState -// @treturn int the index of the target state +// @treturn int The index of the target state. int Moveable::GetTargetStateNumber() const { return _moveable->Animation.TargetState; @@ -759,7 +756,7 @@ int Moveable::GetTargetStateNumber() const // Performs no bounds checking. *Ensure the number given is correct, else // object may end up in corrupted animation state.* // @function Moveable:SetState -// @tparam int index the index of the desired state +// @tparam int index The index of the desired state. void Moveable::SetStateNumber(int stateNumber) { _moveable->Animation.TargetState = stateNumber; @@ -769,7 +766,7 @@ void Moveable::SetStateNumber(int stateNumber) // In certain cases, moveable may play animations from another object slot. Use this // function when you need to identify such cases. // @function Moveable:GetAnimSlot -// @treturn int animation slot ID +// @treturn int Animation slot ID. int Moveable::GetAnimSlot() const { return _moveable->Animation.AnimObjectID; @@ -778,7 +775,7 @@ int Moveable::GetAnimSlot() const /// Retrieve the index of the current animation. // This corresponds to the number shown in the item's animation list in WadTool. // @function Moveable:GetAnim -// @treturn int the index of the active animation +// @treturn int The index of the active animation. int Moveable::GetAnimNumber() const { return _moveable->Animation.AnimNumber - Objects[_moveable->Animation.AnimObjectID].animIndex; @@ -788,8 +785,8 @@ int Moveable::GetAnimNumber() const // Performs no bounds checking. *Ensure the number given is correct, else // object may end up in corrupted animation state.* // @function Moveable:SetAnim -// @tparam int index the index of the desired anim -// @tparam[opt] int slot slot ID of the desired anim (if omitted, moveable's own slot ID is used) +// @tparam int index The index of the desired animation. +// @tparam[opt] int slot Slot ID of the desired anim (if omitted, moveable's own slot ID is used). void Moveable::SetAnimNumber(int animNumber, sol::optional slotIndex) { SetAnimation(*_moveable, (GAME_OBJECT_ID)slotIndex.value_or(_moveable->ObjectNumber), animNumber); @@ -798,7 +795,7 @@ void Moveable::SetAnimNumber(int animNumber, sol::optional slotIndex) /// Retrieve frame number. // This is the current frame of the object's active animation. // @function Moveable:GetFrame -// @treturn int the current frame of the active animation +// @treturn int The current frame of the active animation. int Moveable::GetFrameNumber() const { return (_moveable->Animation.FrameNumber - GetAnimData(*_moveable).frameBase); @@ -808,7 +805,7 @@ int Moveable::GetFrameNumber() const // In most cases, only Z and Y components are used as forward and vertical velocity. // In some cases, primarily NPCs, X component is used as side velocity. // @function Moveable:GetVelocity -// @treturn Vec3 current object velocity +// @treturn Vec3 Current object velocity. Vec3 Moveable::GetVelocity() const { return Vec3( @@ -821,7 +818,7 @@ Vec3 Moveable::GetVelocity() const // In most cases, only Z and Y components are used as forward and vertical velocity. // In some cases, primarily NPCs, X component is used as side velocity. // @function Moveable:SetVelocity -// @tparam Vec3 velocity velocity represented as vector +// @tparam Vec3 velocity Velocity represented as vector. void Moveable::SetVelocity(Vec3 velocity) { if (_moveable->IsCreature()) @@ -836,7 +833,7 @@ void Moveable::SetVelocity(Vec3 velocity) // the WadTool animation editor. If the animation has no frames, the only valid argument // is -1. // @function Moveable:SetFrame -// @tparam int frame the new frame number +// @tparam int frame The new frame number. void Moveable::SetFrameNumber(int frameNumber) { const auto& anim = GetAnimData(*_moveable); @@ -865,9 +862,9 @@ int Moveable::GetEndFrame() const return (anim.frameEnd - anim.frameBase); } -/// Determine whether the moveable is active or not +/// Determine whether the moveable is active or not. // @function Moveable:GetActive -// @treturn bool true if the moveable is active +// @treturn bool True if the moveable is active. bool Moveable::GetActive() const { return _moveable->Active; @@ -880,23 +877,23 @@ void Moveable::SetActive(bool isActive) /// Get the hit status of the moveable. // @function Moveable:GetHitStatus -// @treturn bool true if the moveable was hit by something in the last gameplay frame, false otherwise +// @treturn bool true if the moveable was hit by something in the last gameplay frame, false otherwise. bool Moveable::GetHitStatus() const { return _moveable->HitStatus; } -/// Get the current room of the object +/// Get the current room of the moveable. // @function Moveable:GetRoom -// @treturn Objects.Room current room of the object +// @treturn Objects.Room Current room of the moveable. std::unique_ptr Moveable::GetRoom() const { return std::make_unique(g_Level.Rooms[_moveable->RoomNumber]); } -/// Get the current room number of the object +/// Get the current room number of the moveable. // @function Moveable:GetRoomNumber -// @treturn int number representing the current room of the object +// @treturn int Number representing the current room of the moveable. int Moveable::GetRoomNumber() const { return _moveable->RoomNumber; @@ -950,21 +947,21 @@ void Moveable::SetStatus(ItemStatus status) _moveable->Status = status; } -/// Get number of meshes for a particular object +/// Get number of meshes for a particular object. // Returns number of meshes in an object // @function Moveable:GetMeshCount -// @treturn int number of meshes +// @treturn int Number of meshes. short Moveable::GetMeshCount() const { return Objects[_moveable->ObjectNumber].nmeshes; } -/// 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. // @function Moveable:GetMeshVisible -// @int index index of a mesh -// @treturn bool visibility status +// @tparam int index Index of a mesh. +// @treturn bool Visibility status. bool Moveable::GetMeshVisible(int meshId) const { if (!MeshExists(meshId)) @@ -973,11 +970,11 @@ bool Moveable::GetMeshVisible(int meshId) const return _moveable->MeshBits.Test(meshId); } -/// Makes specified mesh visible or invisible +/// Makes specified mesh visible or invisible. // Use this to show or hide a specified mesh of an object. // @function Moveable:SetMeshVisible -// @int index index of a mesh -// @bool isVisible true if you want the mesh to be visible, false otherwise +// @tparam int index Index of a mesh. +// @tparam bool isVisible true if you want the mesh to be visible, false otherwise. void Moveable::SetMeshVisible(int meshId, bool isVisible) { if (!MeshExists(meshId)) @@ -993,10 +990,10 @@ void Moveable::SetMeshVisible(int meshId, bool isVisible) } } -/// 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(). // @function Moveable:ShatterMesh -// @int index index of a mesh +// @tparam int index Index of a mesh to shatter. void Moveable::ShatterMesh(int meshId) { if (!MeshExists(meshId)) @@ -1005,12 +1002,11 @@ void Moveable::ShatterMesh(int meshId) ExplodeItemNode(_moveable, meshId, 0, 128); } -/// 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. // @function Moveable:GetMeshSwapped -// @int index index of a mesh -// @treturn bool mesh swap status +// @tparam int index Index of a mesh. +// @treturn bool Mesh swap status. bool Moveable::GetMeshSwapped(int meshId) const { if (!MeshExists(meshId)) @@ -1019,12 +1015,12 @@ bool Moveable::GetMeshSwapped(int meshId) const return _moveable->Model.MeshIndex[meshId] == _moveable->Model.BaseMesh + meshId; } -/// 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. // @function Moveable:SwapMesh -// @int index index of a mesh -// @int slotIndex index of a slot to get meshswap from -// @int[opt] swapIndex index of a mesh from meshswap slot to use +// @tparam int index Index of a mesh. +// @tparam int slotIndex Index of a slot to get meshswap from. +// @tparam[opt] int swapIndex Index of a mesh from meshswap slot to use. void Moveable::SwapMesh(int meshId, int swapSlotId, sol::optional swapMeshIndex) { if (!MeshExists(meshId)) @@ -1054,10 +1050,10 @@ void Moveable::SwapMesh(int meshId, int swapSlotId, sol::optional swapMeshI _moveable->Model.MeshIndex[meshId] = Objects[swapSlotId].meshIndex + swapMeshIndex.value(); } -/// Set state of specified mesh swap of object +/// Set state of specified mesh swap of object. // Use this to bring back original unswapped mesh // @function Moveable:UnswapMesh -// @int index index of a mesh to unswap +// @tparam int index Index of a mesh to unswap. void Moveable::UnswapMesh(int meshId) { if (!MeshExists(meshId)) @@ -1068,7 +1064,7 @@ void Moveable::UnswapMesh(int meshId) /// Enable the item, as if a trigger for it had been stepped on. // @function Moveable:Enable -// @tparam float timeout time (in seconds) after which moveable automatically disables (optional). +// @tparam[opt] float timeout Time (in seconds) after which moveable automatically disables. void Moveable::EnableItem(sol::optional timer) { if (_moveableID == NO_VALUE) @@ -1087,8 +1083,8 @@ void Moveable::EnableItem(sol::optional timer) dynamic_cast(g_GameScriptEntities)->TryAddColliding(_moveableID); } -/// 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. // @function Moveable:Disable void Moveable::DisableItem() { @@ -1127,29 +1123,29 @@ void Moveable::Shatter() } /// Get the item's collision state. -// @treturn bool item's collision state // @function Moveable:GetCollidable +// @treturn bool Item's collision state. bool Moveable::GetCollidable() { return _moveable->Collidable; } /// Set the item's collision. -// @bool collidable true if the caller should be collidable, false if no collision should occur. // @function Moveable:SetCollidable +// @bool collidable true if the caller should be collidable, false if no collision should occur. void Moveable::SetCollidable(bool isCollidable) { _moveable->Collidable = isCollidable; } -/// Make the item invisible. Alias for `Moveable:SetVisible(false)`. +// Make the item invisible. Alias for `Moveable:SetVisible(false)`. // @function Moveable:MakeInvisible void Moveable::MakeInvisible() { SetVisible(false); } -/// Set the item's visibility. __An invisible item will have collision turned off, as if it no longer exists in the game world__. -// @bool visible true if the caller should become visible, false if it should become invisible +/// Set the item's visibility. An invisible item will have collision turned off, as if it no longer exists in the game world. +// @bool visible true if the caller should become visible, false if it should become invisible. // @function Moveable:SetVisible void Moveable::SetVisible(bool isVisible) { @@ -1200,9 +1196,9 @@ void Moveable::Invalidate() _initialized = false; } -/// 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. // @function Moveable:GetValid -// @treturn bool valid true if the object is still not destroyed +// @treturn bool true if the object is still not destroyed. bool Moveable::GetValid() const { return _moveableID > NO_VALUE; @@ -1236,18 +1232,18 @@ bool Moveable::MeshExists(int index) const /// Attach camera to an object. // @function Moveable:AttachObjCamera // @tparam int mesh Mesh of a moveable to use as a camera position. -// @tparam Moveable target Target moveable to attach camera to. +// @tparam Objects.Moveable target Target moveable to attach camera to. // @tparam int mesh Mesh of a target moveable to use as a camera target. void Moveable::AttachObjCamera(short camMeshId, Moveable& mov, short targetMeshId) { ObjCamera(_moveable, camMeshId, mov._moveable, targetMeshId, true); } -/// Borrow animation from an object +/// Borrow animation from an object. // @function Moveable:AnimFromObject -// @tparam Objects.ObjID objectID Object ID to take animation and stateID from. +// @tparam Objects.ObjID objectID Object ID to take animation and state ID from. // @tparam int animNumber Animation from object. -// @tparam int stateID state State from object. +// @tparam int stateID State from object. void Moveable::AnimFromObject(GAME_OBJECT_ID objectID, int animNumber, int stateID) { _moveable->Animation.AnimObjectID = objectID; diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h index e038d00bf..05b2e17e8 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h @@ -10,10 +10,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. // // @table Objects.MoveableStatus diff --git a/TombEngine/Scripting/Internal/TEN/Objects/ObjectIDs.h b/TombEngine/Scripting/Internal/TEN/Objects/ObjectIDs.h index 04e5732a8..f7dbb1a31 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/ObjectIDs.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/ObjectIDs.h @@ -1,7 +1,7 @@ #pragma once // This file is generated automatically, do not edit it. -// Last generated on 17/03/2025. +// Last generated on 18/04/2025. #include #include @@ -746,7 +746,7 @@ The following constants are inside ObjID. INVENTORY_SUNGLASSES INVENTORY_KEYS INVENTORY_HEADPHONES - INVENTORY_POLAROID + INVENTORY_PHOTO SMOKE_EMITTER_WHITE SMOKE_EMITTER_BLACK SMOKE_EMITTER @@ -1986,7 +1986,7 @@ static const std::unordered_map GAME_OBJECT_IDS { { "INVENTORY_SUNGLASSES", ID_INVENTORY_SUNGLASSES }, { "INVENTORY_KEYS", ID_INVENTORY_KEYS }, { "INVENTORY_HEADPHONES", ID_INVENTORY_HEADPHONES }, - { "INVENTORY_POLAROID", ID_INVENTORY_POLAROID }, + { "INVENTORY_PHOTO", ID_INVENTORY_PHOTO }, { "SMOKE_EMITTER_WHITE", ID_SMOKE_EMITTER_WHITE }, { "SMOKE_EMITTER_BLACK", ID_SMOKE_EMITTER_BLACK }, { "SMOKE_EMITTER", ID_SMOKE_EMITTER }, diff --git a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp index 89eb52ee2..af24a0c2a 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp @@ -35,88 +35,88 @@ ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table& parent) : /*** Get a moveable by its name. @function GetMoveableByName - @tparam string name the unique name of the Moveable as set in, or generated by, Tomb Editor - @treturn Moveable a non-owning Moveable referencing the item. + @tparam string name The unique name of the moveable as set in, or generated by, Tomb Editor. + @treturn Objects.Moveable a non-owning Moveable referencing the item. */ _table_objects.set_function(ScriptReserved_GetMoveableByName, &ObjectsHandler::GetByName, this); /*** Get a Static by its name. @function GetStaticByName - @tparam string name the unique name of the mesh as set in, or generated by, Tomb Editor - @treturn Static a non-owning Static referencing the mesh. + @tparam string name The unique name of the static mesh as set in, or generated by, Tomb Editor. + @treturn Objects.Static a non-owning Static referencing the static mesh. */ _table_objects.set_function(ScriptReserved_GetStaticByName, &ObjectsHandler::GetByName, this); /*** Get moveables by its slot. @function GetMoveablesBySlot - @tparam Objects.ObjID slot the unique slot of the Moveable, e.g. `Objects.ObjID.ANIMATING1` - @treturn table table of Moveables referencing the given slot. + @tparam Objects.ObjID slot The unique slot of the moveable, e.g. `Objects.ObjID.ANIMATING1`. + @treturn table Table of moveables referencing the given slot. */ _table_objects.set_function(ScriptReserved_GetMoveablesBySlot, &ObjectsHandler::GetMoveablesBySlot, this); /*** Get statics by its slot. @function GetStaticsBySlot - @tparam int slot the unique slot of the mesh like 10 - @treturn table table of Statics referencing the given slot ID. + @tparam int slot The unique numerical slot of the static mesh. + @treturn table Table of static meshes referencing the given slot. */ _table_objects.set_function(ScriptReserved_GetStaticsBySlot, &ObjectsHandler::GetStaticsBySlot, this); /*** Get rooms by tag. @function GetRoomsByTag - @tparam string tag to select rooms by - @treturn table table of Rooms containing the given tag. + @tparam string tag Tag to select rooms by. + @treturn table Table of rooms containing the given tag. */ _table_objects.set_function(ScriptReserved_GetRoomsByTag, &ObjectsHandler::GetRoomsByTag, this); /*** Get a Camera by its name. @function GetCameraByName - @tparam string name the unique name of the camera as set in, or generated by, Tomb Editor - @treturn Camera a non-owning Camera referencing the camera. + @tparam string name The unique name of the camera as set in, or generated by, Tomb Editor. + @treturn Objects.Camera A non-owning Camera referencing the camera. */ _table_objects.set_function(ScriptReserved_GetCameraByName, &ObjectsHandler::GetByName, this); /*** Get a Sink by its name. @function GetSinkByName - @tparam string name the unique name of the sink as set in, or generated by, Tomb Editor - @treturn Sink a non-owning Sink referencing the sink. + @tparam string name The unique name of the sink as set in, or generated by, Tomb Editor. + @treturn Objects.Sink A non-owning Sink referencing the sink. */ _table_objects.set_function(ScriptReserved_GetSinkByName, &ObjectsHandler::GetByName, this); /*** Get a SoundSource by its name. @function GetSoundSourceByName - @tparam string name the unique name of the sound source as set in, or generated by, Tomb Editor - @treturn SoundSource a non-owning SoundSource referencing the sound source. + @tparam string name The unique name of the sound source as set in, or generated by, Tomb Editor. + @treturn Objects.SoundSource A non-owning SoundSource referencing the sound source. */ _table_objects.set_function(ScriptReserved_GetSoundSourceByName, &ObjectsHandler::GetByName, this); /*** Get an AIObject by its name. @function GetAIObjectByName - @tparam string name the unique name of the AIObject as set in, or generated by, Tomb Editor - @treturn AIObject a non-owning SoundSource referencing the AI moveable. + @tparam string name The unique name of the AIObject as set in, or generated by, Tomb Editor. + @treturn Objects.AIObject A non-owning AIObject referencing the AI object. */ _table_objects.set_function(ScriptReserved_GetAIObjectByName, &ObjectsHandler::GetByName, this); /*** Get a Volume by its name. @function GetVolumeByName - @tparam string name the unique name of the volume as set in, or generated by, Tomb Editor - @treturn Volume a non-owning Volume referencing the room. + @tparam string name The unique name of the volume as set in, or generated by, Tomb Editor. + @treturn Objects.Volume A non-owning Volume referencing the volume. */ _table_objects.set_function(ScriptReserved_GetVolumeByName, &ObjectsHandler::GetByName, this); /*** Get a Room by its name. @function GetRoomByName - @tparam string name the unique name of the room as set in Tomb Editor - @treturn Room a non-owning Room referencing the room. + @tparam string name The unique name of the room as set in Tomb Editor. + @treturn Objects.Room A non-owning Room referencing the room. */ _table_objects.set_function(ScriptReserved_GetRoomByName, &ObjectsHandler::GetByName, this); diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h index 71da196e3..9e3caed40 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h @@ -11,7 +11,8 @@ Constants for room flag IDs. */ /*** 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/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h index 6f27ccff5..d776a520e 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h @@ -11,15 +11,15 @@ Constants for room reverb types. */ /*** Table of Objects.RoomReverb constants. -To be used with @{Objects.Room.GetReverbType} and @{Objects.Room.SetReverbType} functions. - +
      +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` @table Objects.RoomReverb */ diff --git a/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp index 54e1b0b27..7b83b8b07 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp @@ -27,34 +27,34 @@ void SoundSource::Register(sol::table& parent) sol::meta_function::index, IndexError, sol::meta_function::new_index, NewIndexError, - /// Get the sound source's position + /// Get the sound source's position. // @function SoundSource:GetPosition - // @treturn Vec3 a copy of the sound source's position + // @treturn Vec3 Sound source's position. ScriptReserved_GetPosition, &SoundSource::GetPos, - /// Set the sound source's position + /// Set the sound source's position. // @function SoundSource:SetPosition - // @tparam Vec3 position the new position of the sound source + // @tparam Vec3 position The new position of the sound source. ScriptReserved_SetPosition, &SoundSource::SetPos, - /// Get the sound source's unique string identifier + /// Get the sound source's unique string identifier. // @function SoundSource:GetName - // @treturn string the sound source's name + // @treturn string The sound source's name. ScriptReserved_GetName, &SoundSource::GetName, - /// Set the sound source's name (its unique string identifier) + /// Set the sound source's unique string identifier. // @function SoundSource:SetName - // @tparam string name The sound source's new name + // @tparam string name The sound source's new name. ScriptReserved_SetName, &SoundSource::SetName, - /// Get the sound source's unique int identifier + /// Get the sound source's sound ID. // @function SoundSource:GetSoundID - // @treturn int the ID of the sound + // @treturn int The ID of the sound. ScriptReserved_GetSoundID, &SoundSource::GetSoundID, - /// Set the sound source's ID + /// Set the sound source's ID. // @function SoundSource:SetSoundID - // @tparam int name The sound source's new name + // @tparam int name The sound source's new sound ID. ScriptReserved_SetSoundID, &SoundSource::SetSoundID ); } diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp index c2fd4ddbb..f91e981c7 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp @@ -98,7 +98,8 @@ namespace TEN::Scripting // @treturn float World scale. float Static::GetScale() const { - return _static.scale; + // TODO: Decide what to return when Vector3 scale is also exposed. + return _static.pos.Scale.x; } /// Get this static's color. @@ -119,7 +120,7 @@ namespace TEN::Scripting /// Get this static's visibility status. // @function Static:GetActive - // @treturn bool Status. __true: visible__, __false: invisible__ + // @treturn bool Status. true means visible, false otherwise. bool Static::GetActiveStatus() const { return ((_static.flags & StaticMeshFlags::SM_VISIBLE) != 0); @@ -127,7 +128,7 @@ namespace TEN::Scripting /// Get this static's collision status. // @function Static:GetCollidable - // @treturn bool Collision status. __true: can be collided with__, __false: no collision__ + // @treturn bool Collision status. true if can be collided with, false otherwise. bool Static::GetCollidable() const { return ((_static.flags & StaticMeshFlags::SM_COLLISION) != 0); @@ -135,7 +136,7 @@ namespace TEN::Scripting /// Get this static's solid collision status. // @function Static:GetSolid - // @treturn bool Solid Status. __true: solid__, __false: soft__ + // @treturn bool Solid Status. true if solid, false if soft. bool Static::GetSolidStatus() const { return ((_static.flags & StaticMeshFlags::SM_SOLID) != 0); @@ -193,7 +194,7 @@ namespace TEN::Scripting // @tparam float scale New world scale. void Static::SetScale(float scale) { - _static.scale = scale; + _static.pos.Scale = Vector3(scale); _static.Dirty = true; } @@ -216,7 +217,7 @@ namespace TEN::Scripting /// Set this static's solid collision status. // @function Static:SetSolid - // @tparam bool status New status. __true: solid__, __false: soft__ + // @tparam bool status New status, true is solid, false is soft. void Static::SetSolidStatus(bool status) { if (status) @@ -231,7 +232,7 @@ namespace TEN::Scripting /// Set this static's collision status. // @function Static:SetCollidable - // @tparam bool collidable New collision status. __true: can be collided with__, __false: no collision__ + // @tparam bool collidable New collision status. true if can be collided with, false: no collision. void Static::SetCollidable(bool collidable) { if (collidable) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp index 08d4a87cf..4e3f765d4 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp @@ -49,7 +49,7 @@ void Volume::Register(sol::table& parent) } /// Get the unique string identifier of this volume. -// @function Volume:GetName() +// @function Volume:GetName // @treturn string Name. std::string Volume::GetName() const { @@ -57,7 +57,7 @@ std::string Volume::GetName() const } /// Get the position of this volume. -// @function Volume:GetPosition() +// @function Volume:GetPosition // @treturn Vec3 Position. Vec3 Volume::GetPos() const { @@ -65,7 +65,7 @@ Vec3 Volume::GetPos() const } /// Get the rotation of this volume. -// @function Volume:GetRotation() +// @function Volume:GetRotation // @treturn Rotation Rotation. Rotation Volume::GetRot() const { @@ -74,7 +74,7 @@ Rotation Volume::GetRot() const } /// Get this scale of this volume. -// @function Volume:GetScale() +// @function Volume:GetScale // @treturn Vec3 Scale. Vec3 Volume::GetScale() const { @@ -82,7 +82,7 @@ Vec3 Volume::GetScale() const } /// Set the unique string identifier of this volume. -// @function Volume:SetName() +// @function Volume:SetName // @tparam string name New name. void Volume::SetName(const std::string& name) { @@ -103,7 +103,7 @@ void Volume::SetName(const std::string& name) } /// Set the position of this volume. -// @function Volume:SetPosition() +// @function Volume:SetPosition // @tparam Vec3 pos New position. void Volume::SetPos(const Vec3& pos) { @@ -112,7 +112,7 @@ void Volume::SetPos(const Vec3& pos) } /// Set the rotation of this volume. -// @function Volume:SetRotation() +// @function Volume:SetRotation // @tparam Rotation rot New rotation. void Volume::SetRot(const Rotation& rot) { @@ -121,7 +121,7 @@ void Volume::SetRot(const Rotation& rot) } /// Set the scale of the volume. -// @function Volume:SetScale() +// @function Volume:SetScale // @tparam Vec3 scale New scale. void Volume::SetScale(const Vec3& scale) { @@ -130,7 +130,7 @@ void Volume::SetScale(const Vec3& scale) } /// Determine if this volume is active. -// @function Volume:GetActive() +// @function Volume:GetActive // @treturn bool Boolean representing active status. bool Volume::GetActive() const { @@ -138,8 +138,8 @@ bool Volume::GetActive() const } /// Determine if a moveable is inside this volume. -// @function Volume:IsMoveableInside() -// @tparam Objects.Moveable Moveable to be checked for containment. +// @function Volume:IsMoveableInside +// @tparam Objects.Moveable moveable Moveable to be checked for containment. // @treturn bool Boolean representing containment status. bool Volume::IsMoveableInside(const Moveable& mov) { @@ -159,14 +159,14 @@ bool Volume::IsMoveableInside(const Moveable& mov) } /// Enable this volume. -// @function Volume:Enable() +// @function Volume:Enable void Volume::Enable() { _volume.Enabled = true; } /// Disable this volume. -// @function Volume:Disable() +// @function Volume:Disable void Volume::Disable() { ClearActivators(); @@ -174,7 +174,7 @@ void Volume::Disable() } /// Clear the activators for this volume, allowing it to trigger again. -// @function Volume:ClearActivators() +// @function Volume:ClearActivators void Volume::ClearActivators() { _volume.StateQueue.clear(); diff --git a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp index 73522ae03..8d55ba0aa 100644 --- a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp @@ -14,7 +14,7 @@ namespace TEN::Scripting::Sound { - /// Play an audio track. Supported formats are wav, mp3 and ogg. + /// Play an audio track. Should be placed in the `Audio` folder. Supported formats are wav, mp3 and ogg. // @function PlayAudioTrack // @tparam string filename Filename of a track (without file extension) to play. // @tparam Sound.SoundTrackType type Type of the audio track to play. @@ -87,7 +87,7 @@ namespace TEN::Scripting::Sound /// Check if the audio track is playing. // @function IsAudioTrackPlaying - // @tparam string Track Filename to check. Should be without extension and without full directory path. + // @tparam string track Filename to check. Should be without extension and without full directory path. static bool IsAudioTrackPlaying(const std::string& trackName) { return Sound_TrackIsPlaying(trackName); diff --git a/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h b/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h index 4ae631d98..0b8c79d8a 100644 --- a/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h +++ b/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h @@ -11,9 +11,9 @@ Constants for the type of the audio tracks. * 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. @table Sound.SoundTrackType */ diff --git a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp index fa883f704..4b2fb412c 100644 --- a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp +++ b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp @@ -47,13 +47,12 @@ DisplayString::DisplayString() For use in @{Strings.ShowString|ShowString} and @{Strings.HideString|HideString}. @function DisplayString @tparam string string The string to display or key of the translated string. -@tparam Vec2 Position of the string in pixel coordinates. -@tparam[opt] float scale size of the string, relative to the default size. __Default: 1.0__ -@tparam[opt] Color color the color of the text. __Default: white__ -@tparam[opt] bool translated 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__. -@tparam Strings.DisplayStringOption table -__Default: None.__ _Please note that Strings are automatically aligned to the LEFT_ +@tparam Vec2 position Position of the string in pixel coordinates. +@tparam[opt=1] float scale Size of the string, relative to the default size. +@tparam[opt=Color(255, 255, 255)] Color color The color of the text. +@tparam[opt=false] bool translated 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. +@tparam[opt] Strings.DisplayStringOption flags Flags which affect visual representation of a string, such as shadow or alignment. @treturn DisplayString A new DisplayString object. */ static std::unique_ptr CreateString(const std::string& key, const Vec2& pos, TypeOrNil scale, TypeOrNil color, @@ -140,55 +139,51 @@ void DisplayString::Register(sol::table& parent) ScriptReserved_DisplayString, sol::call_constructor, &DisplayStringWrapper, - /// Get the display string's color + /// Get the display string's color. // @function DisplayString:GetColor - // @treturn Color a copy of the display string's color + // @treturn Color Display string's color. ScriptReserved_GetColor, &DisplayString::GetColor, - /// Set the display string's color + /// Set the display string's color. // @function DisplayString:SetColor - // @tparam Color color the new color of the display string + // @tparam Color color The new color of the display string. ScriptReserved_SetColor, &DisplayString::SetColor, - /// 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. - // @function DisplayString:GetKey() - // @treturn string the string to use + /// Get the string key. + // @function DisplayString:GetKey + // @treturn string The string key. ScriptReserved_GetKey, &DisplayString::GetKey, - /// 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. - // @function DisplayString:SetKey() - // @tparam string string the new key for the display string + /// Set the string key to use. + // @function DisplayString:SetKey + // @tparam string key The new key for the display string. ScriptReserved_SetKey, &DisplayString::SetKey, /// Set the scale of the string. - // @function DisplayString:SetScale() + // @function DisplayString:SetScale // @tparam float scale New scale of the string relative to the default size. ScriptReserved_SetScale, &DisplayString::SetScale, /// Get the scale of the string. - // @function DisplayString:GetScale() + // @function DisplayString:GetScale // @treturn float Scale. ScriptReserved_GetScale, &DisplayString::GetScale, /// Set the position of the string. // Screen-space coordinates are expected. - // @function DisplayString:SetPosition() + // @function DisplayString:SetPosition // @tparam Vec2 pos New position in pixel coordinates. ScriptReserved_SetPosition, &DisplayString::SetPosition, /// Get the position of the string. // Screen-space coordinates are returned. - // @function DisplayString:GetPosition() + // @function DisplayString:GetPosition // @treturn Vec2 pos Position in pixel coordinates. ScriptReserved_GetPosition, &DisplayString::GetPosition, - /// Set the display string's flags - // @function DisplayString:SetFlags() - // @tparam table table the new table with display flags options + /// Set the display string's flags. + // @function DisplayString:SetFlags + // @tparam table table The new table with display flags options. // @usage // local varDisplayString = DisplayString('example string', 0, 0, Color(255, 255, 255), false) // possible values: @@ -200,10 +195,7 @@ void DisplayString::Register(sol::table& parent) // varDisplayString:SetFlags{ TEN.Strings.DisplayStringOption.CENTER } ScriptReserved_SetFlags, &DisplayString::SetFlags, - /// Set translated parameter of the string - // @function DisplayString:SetTranslated - // @tparam bool shouldTranslate 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 + // DEPRECATED ScriptReserved_SetTranslated, &DisplayString::SetTranslated); } diff --git a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h index 7d2497850..871de86ec 100644 --- a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h +++ b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h @@ -17,10 +17,10 @@ Constants for Display String Options. /*** Strings.DisplayStringOption constants. To be used with @{Strings.DisplayString} class. @table Strings.DisplayStringOption - - `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. */ enum class DisplayStringOptions diff --git a/TombEngine/Scripting/Internal/TEN/Strings/StringsHandler.cpp b/TombEngine/Scripting/Internal/TEN/Strings/StringsHandler.cpp index e2db6fd0a..55174cb68 100644 --- a/TombEngine/Scripting/Internal/TEN/Strings/StringsHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Strings/StringsHandler.cpp @@ -21,31 +21,26 @@ StringsHandler::StringsHandler(sol::state* lua, sol::table& parent) : /*** Show some text on-screen. -@tparam DisplayString str the string object to draw @function ShowString -@tparam float time the time in seconds for which to show the string. -If not given, the string will have an "infinite" life, and will show +@tparam DisplayString string The string object to draw. +@tparam[opt] float time 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) -@tparam bool autoDelete 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 +@tparam[opt=true] bool autoDelete 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. */ table.set_function(ScriptReserved_ShowString, &StringsHandler::ShowString, this); /*** Hide some on-screen text. @function HideString -@tparam DisplayString str the string object to hide. Must previously have been shown -with a call to @{ShowString}, or this function will have no effect. +@tparam DisplayString string The string object to hide. Must previously have been shown with a call to @{ShowString}, or this function will have no effect. */ table.set_function(ScriptReserved_HideString, [this](const DisplayString& string) { ShowString(string, 0.0f, false); }); /*** Checks if the string is shown @function IsStringDisplaying -@tparam DisplayString str the string object to be checked +@tparam DisplayString string The string object to be checked. @treturn bool true if it is shown, false if it is hidden */ table.set_function(ScriptReserved_IsStringDisplaying, &StringsHandler::IsStringDisplaying, this); diff --git a/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp b/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp index 6e6037236..64e38caa6 100644 --- a/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp +++ b/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp @@ -37,9 +37,9 @@ namespace TEN::Scripting::Types "a", sol::property(&ScriptColor::GetA, &ScriptColor::SetA)); } - /// @int R red component - // @int G green component - // @int B blue component + /// @int R Red component. + // @int G Green component. + // @int B Blue component. // @treturn Color A new Color object. // @function Color ScriptColor::ScriptColor(byte r, byte g, byte b) : diff --git a/TombEngine/Scripting/Internal/TEN/Util/Util.cpp b/TombEngine/Scripting/Internal/TEN/Util/Util.cpp index 851252605..9999ddd0d 100644 --- a/TombEngine/Scripting/Internal/TEN/Util/Util.cpp +++ b/TombEngine/Scripting/Internal/TEN/Util/Util.cpp @@ -26,13 +26,12 @@ namespace TEN::Scripting::Util // @tentable Util // @pragma nostrip - /// Determine if there is a clear line of sight between two positions. - // NOTE: Limited to room geometry. Objects are ignored. - // @function HasLineOfSight() + /// Determine if there is a clear line of sight between two positions. Limited to room geometry. Objects are ignored. + // @function HasLineOfSight // @tparam float roomID Room ID of the first position's room. // @tparam Vec3 posA First position. // @tparam Vec3 posB Second position. - // @treturn bool __true__ if there is a line of sight, __false__ if not. + // @treturn bool true if there is a line of sight, false if not. // @usage // local flamePlinthPos = flamePlinth:GetPosition() + Vec3(0, flamePlinthHeight, 0); // print(Misc.HasLineOfSight(enemyHead:GetRoomNumber(), enemyHead:GetPosition(), flamePlinthPos)) @@ -122,7 +121,7 @@ namespace TEN::Scripting::Util /// Pick a moveable by the given display position. // @function PickMoveableByDisplayPosition - // @tparam Vec2 Display space position in percent. + // @tparam Vec2 position Display space position in percent. // @treturn Objects.Moveable Picked moveable (nil if no moveable was found under the cursor). static sol::optional > PickMoveable(const Vec2& screenPos) { @@ -140,7 +139,7 @@ namespace TEN::Scripting::Util /// Pick a static mesh by the given display position. // @function PickStaticByDisplayPosition - // @tparam Vec2 Display space position in percent. + // @tparam Vec2 position Display space position in percent. // @treturn Objects.Static Picked static mesh (nil if no static mesh was found under the cursor). static sol::optional > PickStatic(const Vec2& screenPos) { @@ -165,9 +164,9 @@ namespace TEN::Scripting::Util // //debug.traceback //@function PrintLog - //@tparam string message to be displayed within the Log - //@tparam Util.LogLevel logLevel log level to be displayed - //@tparam[opt] bool allowSpam true allows spamming of the message + //@tparam string Message to be displayed within the log. + //@tparam Util.LogLevel logLevel Log level to be displayed. + //@tparam[opt] bool allowSpam If true, allows continuous spamming of the message. // //@usage //PrintLog('test info log', LogLevel.INFO) diff --git a/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h b/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h index abeb58748..e288ab9f8 100644 --- a/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h +++ b/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h @@ -21,13 +21,13 @@ enum class ScriptCameraType /*** Table of View.CameraType constants. To be used with @{View.GetCameraType} function. @table CameraType - - `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. */ static const std::unordered_map CAMERA_TYPE diff --git a/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp index 6f18e4454..986ab94c9 100644 --- a/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp +++ b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp @@ -25,7 +25,9 @@ namespace TEN::Scripting::DisplaySprite // NOTE: Single constructor with a sol::optional argument for the color doesn't work, hence the two constructors. -- Sezz 2023.10.19 using ctors = sol::constructors< ScriptDisplaySprite(GAME_OBJECT_ID, int, const Vec2&, float, const Vec2&, const ScriptColor&), - ScriptDisplaySprite(GAME_OBJECT_ID, int, const Vec2&, float, const Vec2&)>; + ScriptDisplaySprite(GAME_OBJECT_ID, int, const Vec2&, float, const Vec2&), + ScriptDisplaySprite(const Vec2&, float, const Vec2&, const ScriptColor&), + ScriptDisplaySprite(const Vec2&, float, const Vec2&)>; // Register type. parent.new_usertype( @@ -49,18 +51,18 @@ namespace TEN::Scripting::DisplaySprite } /// Create a DisplaySprite object. - // @function DisplaySprite() - // @tparam Objects.ObjID.SpriteConstants ID of the sprite sequence object. - // @tparam int int spriteID ID of the sprite in the sequence. + // @function DisplaySprite + // @tparam Objects.ObjID.SpriteConstants objectID ID of the sprite sequence object. + // @tparam int index Index of the sprite in the sequence. // @tparam Vec2 pos Display position in percent. // @tparam float rot Rotation in degrees. // @tparam Vec2 scale Horizontal and vertical scale in percent. Scaling is interpreted by the DisplaySpriteEnum.ScaleMode passed to the Draw() function call. - // @tparam[opt] Color color Color. __Default: Color(255, 255, 255, 255)__ + // @tparam[opt=Color(255, 255, 255)] Color color Color. // @treturn DisplaySprite A new DisplaySprite object. ScriptDisplaySprite::ScriptDisplaySprite(GAME_OBJECT_ID objectID, int spriteID, const Vec2& pos, float rot, const Vec2& scale, const ScriptColor& color) { _objectID = objectID; - _spriteID = spriteID; + _spriteID = std::clamp(spriteID, 0, INT_MAX); _position = pos; _rotation = rot; _scale = scale; @@ -69,13 +71,34 @@ namespace TEN::Scripting::DisplaySprite ScriptDisplaySprite::ScriptDisplaySprite(GAME_OBJECT_ID objectID, int spriteID, const Vec2& pos, float rot, const Vec2& scale) { - static const auto DEFAULT_COLOR = ScriptColor(255, 255, 255, 255); + *this = ScriptDisplaySprite(objectID, spriteID, pos, rot, scale, ScriptColor(255, 255, 255, 255)); + } - *this = ScriptDisplaySprite(objectID, spriteID, pos, rot, scale, DEFAULT_COLOR); + /// Create a DisplaySprite object with a video image. + // Video should be played using @{View.PlayVideo} function in a background mode. If no video is played, sprite will not show. + // @function DisplaySprite + // @tparam Vec2 pos Display position in percent. + // @tparam float rot Rotation in degrees. + // @tparam Vec2 scale Horizontal and vertical scale in percent. Scaling is interpreted by the DisplaySpriteEnum.ScaleMode passed to the Draw() function call. + // @tparam[opt] Color color Color. __Default: Color(255, 255, 255, 255)__ + // @treturn DisplaySprite A new DisplaySprite object with attached video image. + ScriptDisplaySprite::ScriptDisplaySprite(const Vec2& pos, float rot, const Vec2& scale, const ScriptColor& color) + { + _objectID = GAME_OBJECT_ID::ID_DEFAULT_SPRITES; + _spriteID = VIDEO_SPRITE_ID; + _position = pos; + _rotation = rot; + _scale = scale; + _color = color; + } + + ScriptDisplaySprite::ScriptDisplaySprite(const Vec2& pos, float rot, const Vec2& scale) + { + *this = ScriptDisplaySprite(pos, rot, scale, ScriptColor(255, 255, 255, 255)); } /// Get the object ID of the sprite sequence object used by the display sprite. - // @function DisplaySprite:GetObjectID() + // @function DisplaySprite:GetObjectID // @treturn Objects.ObjID.SpriteConstants Sprite sequence object ID. GAME_OBJECT_ID ScriptDisplaySprite::GetObjectID() const { @@ -83,15 +106,15 @@ namespace TEN::Scripting::DisplaySprite } /// Get the sprite ID in the sprite sequence object used by the display sprite. - // @function DisplaySprite:GetSpriteID() - // @treturn int Sprite ID in the sprite sequence object. + // @function DisplaySprite:GetSpriteID + // @treturn int Sprite ID in the sprite sequence object. Value __-1__ means that it is a background video, played using @{View.PlayVideo}. int ScriptDisplaySprite::GetSpriteID() const { return _spriteID; } /// Get the display position of the display sprite in percent. - // @function DisplaySprite:GetPosition() + // @function DisplaySprite:GetPosition // @treturn Vec2 Display position in percent. Vec2 ScriptDisplaySprite::GetPosition() const { @@ -99,7 +122,7 @@ namespace TEN::Scripting::DisplaySprite } /// Get the rotation of the display sprite in degrees. - // @function DisplaySprite:GetRotation() + // @function DisplaySprite:GetRotation // @treturn float Rotation in degrees. float ScriptDisplaySprite::GetRotation() const { @@ -107,7 +130,7 @@ namespace TEN::Scripting::DisplaySprite } /// Get the horizontal and vertical scale of the display sprite in percent. - // @function DisplaySprite:GetScale() + // @function DisplaySprite:GetScale // @treturn Vec2 Horizontal and vertical scale in percent. Vec2 ScriptDisplaySprite::GetScale() const { @@ -115,7 +138,7 @@ namespace TEN::Scripting::DisplaySprite } /// Get the color of the display sprite. - // @function DisplaySprite:GetColor() + // @function DisplaySprite:GetColor // @treturn Color Color. ScriptColor ScriptDisplaySprite::GetColor() const { @@ -123,48 +146,48 @@ namespace TEN::Scripting::DisplaySprite } /// Set the sprite sequence object ID used by the display sprite. - // @function DisplaySprite:SetObjectID(Objects.ObjID.SpriteConstants) - // @tparam Objects.ObjID.SpriteConstants New sprite sequence object ID. + // @function DisplaySprite:SetObjectID + // @tparam Objects.ObjID.SpriteConstants objectID New sprite sequence object ID. void ScriptDisplaySprite::SetObjectID(GAME_OBJECT_ID objectID) { _objectID = objectID; } /// Set the sprite ID in the sprite sequence object used by the display sprite. - // @function DisplaySprite:SetSpriteID(int) - // @tparam int New sprite ID in the sprite sequence object. + // @function DisplaySprite:SetSpriteID + // @tparam int spriteID New sprite ID in the sprite sequence object. void ScriptDisplaySprite::SetSpriteID(int spriteID) { _spriteID = spriteID; } /// Set the display position of the display sprite in percent. - // @function DisplaySprite:SetPosition(Vec2) - // @tparam Vec2 New display position in percent. + // @function DisplaySprite:SetPosition + // @tparam Vec2 position New display position in percent. void ScriptDisplaySprite::SetPosition(const Vec2& pos) { _position = pos; } /// Set the rotation of the display sprite in degrees. - // @function DisplaySprite:SetRotation(float) - // @tparam float New rotation in degrees. + // @function DisplaySprite:SetRotation + // @tparam float rotation New rotation in degrees. void ScriptDisplaySprite::SetRotation(float rot) { _rotation = rot; } /// Set the horizontal and vertical scale of the display sprite in percent. - // @function DisplaySprite:SetScale(Vec2) - // @tparam float New horizontal and vertical scale in percent. + // @function DisplaySprite:SetScale + // @tparam float scale New horizontal and vertical scale in percent. void ScriptDisplaySprite::SetScale(const Vec2& scale) { _scale = scale; } /// Set the color of the display sprite. - // @function DisplaySprite:SetColor(Color) - // @tparam float New color. + // @function DisplaySprite:SetColor + // @tparam Color color New color. void ScriptDisplaySprite::SetColor(const ScriptColor& color) { _color = color; @@ -172,10 +195,10 @@ namespace TEN::Scripting::DisplaySprite /// Draw the display sprite in display space for the current frame. // @function DisplaySprite:Draw - // @tparam[opt] int priority Draw priority. Can be thought of as a layer, with higher values having precedence. __Default: 0__ - // @tparam[opt] View.AlignMode alignMode Align mode interpreting an offset from the sprite's position. __Default: View.AlignMode.CENTER__ - // @tparam[opt] View.ScaleMode scaleMode Scale mode interpreting the display sprite's horizontal and vertical scale. __Default: View.ScaleMode.FIT__ - // @tparam[opt] Effects.BlendID blendMode Blend mode. __Default: Effects.BlendID.ALPHABLEND__ + // @tparam[opt=0] int priority Draw priority. Can be thought of as a layer, with higher values having precedence. + // @tparam[opt=View.AlignMode.CENTER] View.AlignMode alignMode Align mode interpreting an offset from the sprite's position. + // @tparam[opt=View.ScaleMode.FIT] View.ScaleMode scaleMode Scale mode interpreting the display sprite's horizontal and vertical scale. + // @tparam[opt=Effects.BlendID.ALPHABLEND] Effects.BlendID blendMode Blend mode. void ScriptDisplaySprite::Draw(sol::optional priority, sol::optional alignMode, sol::optional scaleMode, sol::optional blendMode) { @@ -190,7 +213,7 @@ namespace TEN::Scripting::DisplaySprite constexpr auto DEFAULT_BLEND_MODE = BlendMode::AlphaBlend; // Object is not a sprite sequence; return early. - if (_objectID < GAME_OBJECT_ID::ID_HORIZON || _objectID >= GAME_OBJECT_ID::ID_NUMBER_OBJECTS) + if (_spriteID != VIDEO_SPRITE_ID && (_objectID < GAME_OBJECT_ID::ID_HORIZON || _objectID >= GAME_OBJECT_ID::ID_NUMBER_OBJECTS)) { TENLog("Attempted to draw display sprite from non-sprite sequence object " + std::to_string(_objectID), LogLevel::Warning); return; diff --git a/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h index 6ae77e093..274f57233 100644 --- a/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h +++ b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h @@ -31,6 +31,8 @@ namespace TEN::Scripting::DisplaySprite // Constructors ScriptDisplaySprite(GAME_OBJECT_ID objectID, int spriteID, const Vec2& pos, float rot, const Vec2& scale, const ScriptColor& color); ScriptDisplaySprite(GAME_OBJECT_ID objectID, int spriteID, const Vec2& pos, float rot, const Vec2& scale); + ScriptDisplaySprite(const Vec2& pos, float rot, const Vec2& scale, const ScriptColor& color); + ScriptDisplaySprite(const Vec2& pos, float rot, const Vec2& scale); // Getters GAME_OBJECT_ID GetObjectID() const; diff --git a/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h b/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h index 605002855..d722f67b4 100644 --- a/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h +++ b/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h @@ -15,9 +15,9 @@ namespace TEN::Scripting::View /// 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. // // @table View.ScaleMode diff --git a/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp b/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp index 8076215b2..b889a8274 100644 --- a/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp @@ -12,6 +12,7 @@ #include "Scripting/Internal/TEN/Objects/Room/RoomObject.h" #include "Scripting/Internal/TEN/Types/Color/Color.h" #include "Scripting/Internal/TEN/Types/Rotation/Rotation.h" +#include "Scripting/Internal/TEN/Types/Time/Time.h" #include "Scripting/Internal/TEN/Types/Vec3/Vec3.h" #include "Scripting/Internal/TEN/View/AlignModes.h" #include "Scripting/Internal/TEN/View/CameraTypes.h" @@ -19,10 +20,14 @@ #include "Scripting/Internal/TEN/View/ScaleModes.h" #include "Scripting/Internal/TEN/View/PostProcessEffects.h" #include "Specific/clock.h" +#include "Specific/Video/Video.h" +#include "Specific/trutils.h" using namespace TEN::Effects::Environment; using namespace TEN::Scripting::DisplaySprite; using namespace TEN::Scripting::View; +using namespace TEN::Utils; +using namespace TEN::Video; using TEN::Renderer::g_Renderer; @@ -111,6 +116,59 @@ namespace TEN::Scripting::View InitializeSpotCam(seqID); } + static void PlayVideo(const std::string& fileName, TypeOrNil background, TypeOrNil silent, TypeOrNil loop) + { + auto mode = ValueOr(background, false) ? VideoPlaybackMode::Background : VideoPlaybackMode::Exclusive; + g_VideoPlayer.Play(fileName, mode, ValueOr(silent, false), ValueOr(loop, false)); + } + + static void StopVideo() + { + g_VideoPlayer.Stop(); + } + + static Time GetVideoPosition() + { + if (!g_VideoPlayer.IsPlaying()) + { + TENLog("Attempted to get video position while video is not playing.", LogLevel::Warning); + return 0; + } + + return g_VideoPlayer.GetPosition(); + } + + static void SetVideoPosition(Time frameCount) + { + if (!g_VideoPlayer.IsPlaying()) + { + TENLog("Attempted to set video position while video is not playing.", LogLevel::Warning); + return; + } + + g_VideoPlayer.SetPosition(frameCount); + return; + } + + static ScriptColor GetVideoDominantColor() + { + return g_VideoPlayer.GetDominantColor(); + } + + static bool IsVideoPlaying(sol::optional name) + { + bool isPlaying = g_VideoPlayer.IsPlaying(); + + if (!isPlaying || !name.has_value()) + return isPlaying; + + // Get the current playing video filename from the full path. + auto filePath = std::filesystem::path(g_VideoPlayer.GetFileName()); + auto currentVideoName = ToLower(filePath.filename().string()); + + return (currentVideoName == ToLower(name.value())); + } + static Vec3 GetFlybyPosition(int seqID, float progress, TypeOrNil loop) { constexpr auto PROGRESS_MAX = 100.0f; @@ -166,37 +224,37 @@ namespace TEN::Scripting::View ///Do a full-screen fade-in from black. //@function FadeIn - //@tparam float speed (default 1.0). Speed in units per second. A value of 1 will make the fade take one second. + //@tparam[opt=1] float speed Speed in units per second. A value of 1 will make the fade take one second. tableView.set_function(ScriptReserved_FadeIn, &FadeIn); ///Do a full-screen fade-to-black. The screen will remain black until a call to FadeIn. //@function FadeOut - //@tparam float speed (default 1.0). Speed in units per second. A value of 1 will make the fade take one second. + //@tparam[opt=1] float speed Speed in units per second. A value of 1 will make the fade take one second. tableView.set_function(ScriptReserved_FadeOut, &FadeOut); ///Check if fade out is complete and screen is completely black. - //@treturn bool state of the fade out + //@treturn bool State of the fade out. tableView.set_function(ScriptReserved_FadeOutComplete, &FadeOutComplete); ///Move black cinematic bars in from the top and bottom of the game window. //@function SetCineBars - //@tparam float height __(default 30)__ Percentage of the screen to be covered - //@tparam float speed __(default 30)__ Coverage percent per second + //@tparam[opt=30] float height Percentage of the screen to be covered. + //@tparam[opt=30] float speed Coverage percent per second. tableView.set_function(ScriptReserved_SetCineBars, &SetCineBars); ///Set field of view. //@function SetFOV - //@tparam float angle in degrees (clamped to [10, 170]) + //@tparam float angle Angle in degrees (clamped to [10, 170]). tableView.set_function(ScriptReserved_SetFOV, &SetFOV); ///Get field of view. //@function GetFOV - //@treturn float current FOV angle in degrees + //@treturn float Current FOV angle in degrees. tableView.set_function(ScriptReserved_GetFOV, &GetFOV); ///Shows the mode of the game camera. //@function GetCameraType - //@treturn View.CameraType value used by the Main Camera. + //@treturn View.CameraType Value used by the game camera. //@usage //LevelFuncs.OnLoop = function() // if (View.GetCameraType() == CameraType.COMBAT) then @@ -207,27 +265,27 @@ namespace TEN::Scripting::View ///Gets current camera position. //@function GetCameraPosition - //@treturn Vec3 current camera position + //@treturn Vec3 Current camera position. tableView.set_function(ScriptReserved_GetCameraPosition, &GetCameraPosition); ///Gets current camera target. //@function GetCameraTarget - //@treturn Vec3 current camera target + //@treturn Vec3 Current camera target. tableView.set_function(ScriptReserved_GetCameraTarget, &GetCameraTarget); ///Gets current room where camera is positioned. //@function GetCameraRoom - //@treturn Objects.Room current room of the camera + //@treturn Objects.Room Current room of the camera. tableView.set_function(ScriptReserved_GetCameraRoom, &GetCameraRoom); ///Sets the post-process effect mode, like negative or monochrome. //@function SetPostProcessMode - //@tparam View.PostProcessMode effect type to set. + //@tparam View.PostProcessMode effect Effect type to set. tableView.set_function(ScriptReserved_SetPostProcessMode, &SetPostProcessMode); ///Sets the post-process effect strength. //@function SetPostProcessStrength - //@tparam float strength (default 1.0). How strong the effect is. + //@tparam[opt=1] float strength How strong the effect is. tableView.set_function(ScriptReserved_SetPostProcessStrength, &SetPostProcessStrength); ///Sets the post-process tint. @@ -235,6 +293,40 @@ namespace TEN::Scripting::View //@tparam Color tint value to use. tableView.set_function(ScriptReserved_SetPostProcessTint, &SetPostProcessTint); + /// Play a video file. File should be placed in the `FMV` folder. + // @function PlayVideo + // @tparam string fileName Video file name. Can be provided without extension, if type is mp4, mkv, mov or avi. + // @tparam[opt=false] bool background 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}. + // @tparam[opt=false] bool silent Play video without sound. + // @tparam[opt=false] bool loop Play video in a loop. + tableView.set_function(ScriptReserved_PlayVideo, &PlayVideo); + + /// Stop the currently playing video. Only possible if video is playing in the background mode. + // @function StopVideo + tableView.set_function(ScriptReserved_StopVideo, &StopVideo); + + /// Gets the currently playing video position. + // @function GetVideoPosition + // @treturn Time Current video position. + tableView.set_function(ScriptReserved_GetVideoPosition, &GetVideoPosition); + + /// Sets the currently playing video position. + // @function SetVideoPosition + // @tparam Time position New video position. + tableView.set_function(ScriptReserved_SetVideoPosition, &SetVideoPosition); + + /// Gets the dominant color for the current video frame. If no video is playing, returns black. + // @function GetVideoDominantColor + // @treturn Color Dominant video color. + tableView.set_function(ScriptReserved_GetVideoDominantColor, &GetVideoDominantColor); + + /// Checks if video is currently playing. + // @function IsVideoPlaying + // @tparam[opt] string name Video file name. If provided, checks if the currently playing video file name is the same as the provided one. + // @treturn bool True if video is currently playing. + tableView.set_function(ScriptReserved_IsVideoPlaying, &IsVideoPlaying); + /// Play a flyby sequence. // @function PlayFlyby // @tparam int seqID Flyby sequence ID. @@ -262,8 +354,8 @@ namespace TEN::Scripting::View /// Flash screen. //@function FlashScreen - //@tparam Color color (default Color(255, 255, 255)) - //@tparam float speed (default 1.0). Speed in units per second. Value of 1 will make flash take one second. Clamped to [0.005, 1.0]. + //@tparam[opt=Color(255, 255, 255)] Color color Color. + //@tparam[opt=1] float speed Speed in units per second. Value of 1 will make flash take one second. Clamped to [0.005, 1.0]. tableView.set_function(ScriptReserved_FlashScreen, &FlashScreen); /// Get the display resolution's aspect ratio. diff --git a/TombEngine/Sound/sound.cpp b/TombEngine/Sound/sound.cpp index 647791188..cf2bf8417 100644 --- a/TombEngine/Sound/sound.cpp +++ b/TombEngine/Sound/sound.cpp @@ -15,10 +15,12 @@ #include "Specific/configuration.h" #include "Specific/level.h" #include "Specific/trutils.h" +#include "Specific/Video/Video.h" #include "Specific/winmain.h" using namespace TEN::Gui; using namespace TEN::Math; +using namespace TEN::Video; enum SoundSourceFlags { @@ -76,6 +78,7 @@ void SetVolumeTracks(int vol) void SetVolumeFX(int vol) { GlobalFXVolume = vol; + g_VideoPlayer.SetVolume(vol); } bool LoadSample(char* pointer, int compSize, int uncompSize, int index) diff --git a/TombEngine/Specific/Input/Input.cpp b/TombEngine/Specific/Input/Input.cpp index 40c55d79c..0f600d373 100644 --- a/TombEngine/Specific/Input/Input.cpp +++ b/TombEngine/Specific/Input/Input.cpp @@ -167,6 +167,8 @@ namespace TEN::Input void DeinitializeInput() { + TENLog("Shutting down OIS...", LogLevel::Info); + if (OisKeyboard != nullptr) OisInputManager->destroyInputObject(OisKeyboard); @@ -650,10 +652,10 @@ namespace TEN::Input RumbleInfo.LastPower = RumbleInfo.Power; } - void UpdateInputActions(ItemInfo* item, bool applyQueue) + void UpdateInputActions(bool allowAsyncUpdate, bool applyQueue) { // Don't update input data during frameskip. - if (!g_Synchronizer.Locked()) + if (allowAsyncUpdate || !g_Synchronizer.Locked()) { ClearInputData(); UpdateRumble(); diff --git a/TombEngine/Specific/Input/Input.h b/TombEngine/Specific/Input/Input.h index 6b704e41a..ba8f3d786 100644 --- a/TombEngine/Specific/Input/Input.h +++ b/TombEngine/Specific/Input/Input.h @@ -51,7 +51,7 @@ namespace TEN::Input void InitializeInput(HWND handle); void DeinitializeInput(); void DefaultConflict(); - void UpdateInputActions(ItemInfo* item, bool applyQueue = false); + void UpdateInputActions(bool allowAsyncUpdate = false, bool applyQueue = false); void ApplyActionQueue(); void ClearAllActions(); void Rumble(float power, float delayInSec = 0.3f, RumbleMode mode = RumbleMode::Both); diff --git a/TombEngine/Specific/Video/Video.cpp b/TombEngine/Specific/Video/Video.cpp new file mode 100644 index 000000000..a60697716 --- /dev/null +++ b/TombEngine/Specific/Video/Video.cpp @@ -0,0 +1,622 @@ +#include "framework.h" +#include "Specific/Video/Video.h" + +#include "Renderer/Renderer.h" +#include "Sound/sound.h" +#include "Specific/Input/Input.h" +#include "Specific/winmain.h" + +using namespace TEN::Input; + +namespace TEN::Video +{ + VideoHandler g_VideoPlayer = {}; + + static const std::string VIDEO_PATH = "FMV/"; + static const std::vector VIDEO_EXTENSIONS = { ".mp4", ".avi", ".mkv", ".mov" }; + + int VideoHandler::GetPosition() const + { + if (_player == nullptr) + return 0; + + auto* media = libvlc_media_player_get_media(_player); + long long duration = libvlc_media_get_duration(media); + float posNormalized = GetNormalizedPosition(); + + // Convert and return position in frames. + long long posMsec = posNormalized * duration; + return (int)((posMsec / 1000.0f) * FPS); + } + + float VideoHandler::GetNormalizedPosition() const + { + if (_player == nullptr) + return 0.0f; + + return (float)libvlc_media_player_get_position(_player); + } + + std::string VideoHandler::GetFileName() const + { + if (_player == nullptr) + return std::string(); + + return _fileName; + } + + Color VideoHandler::GetDominantColor() const + { + if (_player == nullptr || _frameBuffer.size() == 0) + return Color(0.0f, 0.0f, 0.0f); + + unsigned long long accR = 0; + unsigned long long accG = 0; + unsigned long long accB = 0; + + int pixelCount = 0; + int step = 8; + + for (int y = 0; y < _size.y; y += step) + { + for (int x = 0; x < _size.x; x += step) + { + int index = (y * (x * 4)) + (x * 4); + + unsigned char b = _frameBuffer[index]; + unsigned char g = _frameBuffer[index + 1]; + unsigned char r = _frameBuffer[index + 2]; + + accR += r; + accG += g; + accB += b; + pixelCount++; + } + } + + if (pixelCount == 0) + return Color(0.0f, 0.0f, 0.0f); + + unsigned char avgR = unsigned char(accR / pixelCount); + unsigned char avgG = unsigned char(accG / pixelCount); + unsigned char avgB = unsigned char(accB / pixelCount); + + auto result = Vector3((float)avgR / 255.0f, (float)avgG / 255.0f, (float)avgB / 255.0f); + + float luma = Luma(result); + if (luma < 0.3f && luma > 0.0f) + { + float boostFactor = 0.3f / luma; + result *= boostFactor; + result.Clamp(Vector3::Zero, Vector3::One); + } + + if (luma < 0.5f) + { + float desaturationFactor = (0.4f - luma) / 0.4f; + result.x = (result.x * (1.0f - desaturationFactor)) + (luma * desaturationFactor); + result.y = (result.y * (1.0f - desaturationFactor)) + (luma * desaturationFactor); + result.z = (result.z * (1.0f - desaturationFactor)) + (luma * desaturationFactor); + } + + return Color(result); + } + + bool VideoHandler::GetSilent() const + { + return _silent; + } + + bool VideoHandler::GetLooped() const + { + return _looped; + } + + void VideoHandler::SetPosition(int frameCount) + { + if (_player == nullptr) + return; + + auto* media = libvlc_media_player_get_media(_player); + long long duration = libvlc_media_get_duration(media); + + // Convert frames to time in milliseconds (assuming 30 FPS). + float posMsec = (frameCount / FPS) * 1000.0f; + float posNormalized = posMsec / (float)(duration); + + if (posNormalized > 1.0f) + { + TENLog("Video position is out of bounds.", LogLevel::Warning); + return; + } + + // Set normalized position. + SetNormalizedPosition(posNormalized); + HandleError(); + } + + void VideoHandler::SetNormalizedPosition(float pos) + { + if (_player == nullptr) + return; + + libvlc_media_player_set_position(_player, std::clamp(pos, 0.0f, 1.0f), false); + HandleError(); + } + + void VideoHandler::SetVolume(int volume) + { + // Set volume even if player is not available because volume may be externally changed from settings. + _volume = std::clamp(volume, 0, 100); + + if (_player != nullptr) + libvlc_audio_set_volume(_player, _silent ? 0.0f : _volume); + + HandleError(); + } + + bool VideoHandler::IsPlaying() const + { + if (_player == nullptr) + return false; + + auto state = libvlc_media_player_get_state(_player); + return (state == libvlc_Playing); + } + + void VideoHandler::Initialize(const std::string& gameDir, ID3D11Device* device, ID3D11DeviceContext* context) + { + TENLog("Initializing video player...", LogLevel::Info); + + // Disable video output and title because rendering is done to a D3D texture. +#ifdef _DEBUG + const char* args[] = { "--vout=none", "--no-video-title", "--no-media-library"}; + _vlcInstance = libvlc_new(3, args); + //libvlc_log_set(_vlcInstance, OnLog, nullptr); +#else + const char* args[] = { "--vout=none", "--no-video-title", "--no-media-library", "--quiet" }; + _vlcInstance = libvlc_new(4, args); +#endif + + HandleError(); + + _d3dDevice = device; + _d3dContext = context; + + _videoDirectory = gameDir + VIDEO_PATH; + _size = Vector2i::Zero; + _fileName = {}; + _playbackMode = VideoPlaybackMode::Exclusive; + _looped = false; + _silent = false; + } + + void VideoHandler::DeInitialize() + { + TENLog("Shutting down VLC...", LogLevel::Info); + + // This flag is needed to avoid race conditions with update callbacks. + _deInitializing = true; + + if (_player != nullptr) + { + if (libvlc_media_player_is_playing(_player)) + libvlc_media_player_stop_async(_player); + + while (libvlc_media_player_is_playing(_player)) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + libvlc_media_player_release(_player); + + _player = nullptr; + } + + if (_vlcInstance) + libvlc_release(_vlcInstance); + + _vlcInstance = nullptr; + } + + bool VideoHandler::Play(const std::string& filename, VideoPlaybackMode mode, bool silent, bool loop) + { + auto fullVideoName = filename; + + // At first, attempt to load video file with original filename. Then proceed with asset directory. + // Then, if not found, try all common video file extensions, and only quit if none are found. + if (!std::filesystem::is_regular_file(fullVideoName)) + { + fullVideoName = _videoDirectory + filename; + + if (!std::filesystem::is_regular_file(fullVideoName)) + { + for (const auto& ext : VIDEO_EXTENSIONS) + { + if (std::filesystem::is_regular_file(fullVideoName + ext)) + { + fullVideoName += ext; + break; + } + } + + if (!std::filesystem::is_regular_file(fullVideoName)) + { + TENLog("Video file " + fullVideoName + " not found.", LogLevel::Warning); + return false; + } + } + } + + // Don't start playback if same video is already playing. + if (_player != nullptr) + { + if (libvlc_media_player_get_state(_player) == libvlc_Playing && + _playbackMode == mode && _fileName == fullVideoName) + { + TENLog("Video file " + fullVideoName + " is already playing.", LogLevel::Warning); + return false; + } + } + + // Stop previous player instance if it exists. + Stop(); + + _looped = loop; + _silent = silent; + _playbackMode = mode; + _fileName = fullVideoName; + _needRender = _updateInput = false; + + auto* media = libvlc_media_new_path(_fileName.c_str()); + if (media == nullptr) + { + TENLog("Failed to create media from path: " + _fileName, LogLevel::Error); + return false; + } + + // VLC requires to initialize media. Load into player and release right away. + _player = libvlc_media_player_new_from_media(_vlcInstance, media); + libvlc_media_release(media); + + if (_player == nullptr) + { + TENLog("Failed to create media player.", LogLevel::Error); + return false; + } + + libvlc_video_set_callbacks(_player, OnLockFrame, OnUnlockFrame, nullptr, this); + libvlc_video_set_format_callbacks(_player, OnSetup, nullptr); + libvlc_media_player_play(_player); + + SetVolume(_volume); + + if (!HandleError()) + return false; + + auto filePath = std::filesystem::path(_fileName); + TENLog("Playing video file: " + filePath.filename().string() + " (" + (mode == VideoPlaybackMode::Exclusive ? "Exclusive" : "Background") + " mode)", LogLevel::Info); + + if (_playbackMode == VideoPlaybackMode::Exclusive) + PauseAllSounds(SoundPauseMode::Global); + + return true; + } + + bool VideoHandler::Pause() + { + if (_player == nullptr) + return false; + + if (libvlc_media_player_get_state(_player) != libvlc_Paused) + { + libvlc_media_player_pause(_player); + HandleError(); + + return (_playbackMode == VideoPlaybackMode::Exclusive); + } + + HandleError(); + return false; + } + + bool VideoHandler::Resume() + { + if (_player == nullptr) + return false; + + if (libvlc_media_player_get_state(_player) == libvlc_Paused) + { + libvlc_media_player_play(_player); + HandleError(); + + return (_playbackMode == VideoPlaybackMode::Exclusive); + } + + HandleError(); + return false; + } + + void VideoHandler::Stop() + { + DeinitializePlayer(); + DeinitializeD3DTexture(); + + // Don't unset this flag until D3D texture is released, otherwise it may crash when trying to render the texture. + _needRender = false; + + HandleError(); + } + + bool VideoHandler::Update() + { + if (_deInitializing || _player == nullptr) + return false; + + // Attempt to map and render texture only if callback has set frame to be rendered. + if (_needRender) + { + auto mappedResource = D3D11_MAPPED_SUBRESOURCE{}; + if (_videoTexture && SUCCEEDED(_d3dContext->Map(_videoTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + // Copy framebuffer row by row, otherwise skewing may occur. + unsigned char* pData = reinterpret_cast(mappedResource.pData); + for (int row = 0; row < _size.y; row++) + memcpy(pData + row * mappedResource.RowPitch, _frameBuffer.data() + row * _size.x * 4, _size.x * 4); + _d3dContext->Unmap(_videoTexture, 0); + + if (_playbackMode == VideoPlaybackMode::Exclusive) + { + RenderExclusive(); + } + else if (_playbackMode == VideoPlaybackMode::Background) + { + RenderBackground(); + } + } + else + { + TENLog("Failed to render video texture", LogLevel::Error); + } + + _needRender = false; + } + + if (_playbackMode == VideoPlaybackMode::Exclusive) + { + UpdateExclusive(); + } + else if (_playbackMode == VideoPlaybackMode::Background) + { + UpdateBackground(); + } + + return (_playbackMode == VideoPlaybackMode::Exclusive); + } + + void VideoHandler::UpdateExclusive() + { + if (_deInitializing || _player == nullptr) + return; + + bool interruptPlayback = false; + + if (_updateInput) + { + App.ResetClock = true; + UpdateInputActions(true); + interruptPlayback = IsHeld(In::Deselect) || IsHeld(In::Look); + _updateInput = false; + } + + auto state = libvlc_media_player_get_state(_player); + + // If player is just opening, buffering, or stopping, always return early and wait for process to end. + if (state == libvlc_Opening || state == libvlc_Buffering) + return; + + // Reset playback to start if video is looped. + if (_looped && !interruptPlayback && (state == libvlc_Stopping || state == libvlc_Stopped)) + libvlc_media_player_play(_player); + + // If user pressed a key to break out from video or video has finished playback or in an error, stop and delete it. + if (interruptPlayback || state == libvlc_Error || state == libvlc_Stopped) + { + Stop(); + ClearAction(In::Pause); // HACK: Otherwise pause key won't work after video ends. + ResumeAllSounds(SoundPauseMode::Global); + } + + HandleError(); + } + + void VideoHandler::RenderExclusive() + { + g_Renderer.RenderFullScreenTexture(_textureView, (float)_size.x / (float)_size.y); + } + + void VideoHandler::UpdateBackground() + { + if (_deInitializing || _player == nullptr) + return; + + auto state = libvlc_media_player_get_state(_player); + + // If video has finished playback, stop and delete it. + if (!_looped && (state == libvlc_Error || state == libvlc_Stopped)) + { + Stop(); + return; + } + + // Reset playback to start if video is looped. + if (_looped && (state == libvlc_Stopping || state == libvlc_Stopped)) + libvlc_media_player_play(_player); + + HandleError(); + } + + void VideoHandler::RenderBackground() + { + _texture.Width = _size.x; + _texture.Height = _size.y; + _texture.Texture = _videoTexture; + _texture.ShaderResourceView = _textureView; + + g_Renderer.UpdateVideoTexture(&_texture); + } + + bool VideoHandler::HandleError() + { + if (_vlcInstance == nullptr) + return false; + + const char* vlcMsg = libvlc_errmsg(); + if (vlcMsg && strlen(vlcMsg) > 0) + { + TENLog("Video player error: " + std::string(vlcMsg), LogLevel::Error); + return false; + } + + return true; + } + + bool VideoHandler::InitializeD3DTexture() + { + if (_videoTexture != nullptr || _textureView != nullptr) + { + TENLog("Video texture already exists", LogLevel::Error); + return false; + } + + _frameBuffer.resize(_size.x * _size.y * 4); + + auto texDesc = D3D11_TEXTURE2D_DESC{}; + texDesc.Width = _size.x; + texDesc.Height = _size.y; + texDesc.MipLevels = 1; + texDesc.ArraySize = 1; + texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + texDesc.SampleDesc.Count = 1; + texDesc.Usage = D3D11_USAGE_DYNAMIC; + texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + texDesc.MiscFlags = 0; + + if (FAILED(_d3dDevice->CreateTexture2D(&texDesc, nullptr, &_videoTexture))) + { + TENLog("Failed to create video texture", LogLevel::Error); + return false; + } + + if (_videoTexture != nullptr && FAILED(_d3dDevice->CreateShaderResourceView(_videoTexture, nullptr, &_textureView))) + { + TENLog("Failed to create shader resource view", LogLevel::Error); + return false; + } + + return true; + } + + void VideoHandler::DeinitializeD3DTexture() + { + if (_videoTexture != nullptr) + { + _videoTexture->Release(); + _videoTexture = nullptr; + } + + if (_textureView != nullptr) + { + _textureView->Release(); + _textureView = nullptr; + } + + _texture = {}; + _frameBuffer.clear(); + + _size = Vector2i::Zero; + } + + void VideoHandler::DeinitializePlayer() + { + if (_deInitializing || _player == nullptr) + return; + + DeinitializeD3DTexture(); + + libvlc_media_player_stop_async(_player); + libvlc_media_player_release(_player); + + _player = nullptr; + _fileName = {}; + + HandleError(); + } + + void* VideoHandler::OnLockFrame(void* data, void** pixels) + { + auto* player = static_cast(data); + *pixels = player->_frameBuffer.data(); + return nullptr; + } + + void VideoHandler::OnUnlockFrame(void* data, void* picture, void* const* pixels) + { + auto* player = static_cast(data); + player->_needRender = true; + + if (player->_playbackMode == VideoPlaybackMode::Exclusive) + player->_updateInput = true; + } + + void VideoHandler::OnLog(void* data, int level, const libvlc_log_t* ctx, const char* fmt, va_list args) + { + LogLevel logLevel = LogLevel::Info; + + switch (level) + { + case LIBVLC_ERROR: + logLevel = LogLevel::Error; + break; + + case LIBVLC_WARNING: + logLevel = LogLevel::Warning; + break; + + case LIBVLC_NOTICE: + logLevel = LogLevel::Info; + break; + + case LIBVLC_DEBUG: + logLevel = LogLevel::Info; + break; + + default: + logLevel = LogLevel::Info; + break; + } + + char logMgs[1024]; + vsnprintf(logMgs, sizeof(logMgs), fmt, args); + + TENLog("VLC: " + std::string(logMgs), logLevel); + } + + unsigned int VideoHandler::OnSetup(void** data, char* chroma, unsigned* width, unsigned* height, unsigned* pitches, unsigned* lines) + { + strncpy(chroma, "BGRA", 4); + + *pitches = *width * 4; + *lines = *height; + + auto* player = static_cast(*data); + + // Fetch video size only once when playback is just started. + if (player->_size == Vector2i::Zero) + { + player->_size = Vector2i(*width, *height); + player->InitializeD3DTexture(); + } + + return 1; + } +} \ No newline at end of file diff --git a/TombEngine/Specific/Video/Video.h b/TombEngine/Specific/Video/Video.h new file mode 100644 index 000000000..744bc06c2 --- /dev/null +++ b/TombEngine/Specific/Video/Video.h @@ -0,0 +1,107 @@ +#pragma once + +#include "Renderer/Graphics/Texture2D.h" + +using namespace TEN::Math; +using namespace TEN::Renderer::Graphics; + +namespace TEN::Video +{ + enum class VideoPlaybackMode + { + Exclusive, + Background + }; + + class VideoHandler + { + private: + // VLC core components + + libvlc_instance_t* _vlcInstance = nullptr; + libvlc_media_player_t* _player = nullptr; + + // Video properties + + int _volume = 100; + bool _silent = false; + bool _looped = false; + VideoPlaybackMode _playbackMode = VideoPlaybackMode::Exclusive; + Vector2i _size = Vector2i::Zero; + std::string _fileName = {}; + std::string _videoDirectory = {}; + + // Render synchronization + + bool _needRender = false; + bool _updateInput = false; + bool _deInitializing = false; + + // Renderer Resources + + std::vector _frameBuffer = {}; + Texture2D _texture = {}; + ID3D11Texture2D* _videoTexture = nullptr; + ID3D11Device* _d3dDevice = nullptr; + ID3D11DeviceContext* _d3dContext = nullptr; + ID3D11ShaderResourceView* _textureView = nullptr; + + public: + // Constructors + + VideoHandler() = default; + + // Getters + + int GetPosition() const; + float GetNormalizedPosition() const; + std::string GetFileName() const; + Color GetDominantColor() const; + bool GetSilent() const; + bool GetLooped() const; + + // Setters + + void SetPosition(int frameCount); + void SetNormalizedPosition(float pos); + void SetVolume(int volume); + + // Inquirers + + bool IsPlaying() const; + + // Utilties + + void Initialize(const std::string& gameDir, ID3D11Device* device, ID3D11DeviceContext* context); + void DeInitialize(); + bool Play(const std::string& filename, VideoPlaybackMode mode = VideoPlaybackMode::Exclusive, bool silent = false, bool looped = false); + bool Pause(); + bool Resume(); + void Stop(); + bool Update(); + + private: + // Update + + void UpdateExclusive(); + void RenderExclusive(); + void UpdateBackground(); + void RenderBackground(); + + // Helpers + + bool HandleError(); + bool InitializeD3DTexture(); + void DeinitializeD3DTexture(); + void DeinitializePlayer(); + + // VLC callbacks + + static void* OnLockFrame(void* data, void** pixels); + static void OnUnlockFrame(void* data, void* picture, void* const* pixels); + static void OnLog(void* data, int level, const libvlc_log_t* ctx, const char* fmt, va_list args); + static unsigned int OnSetup(void** data, char* chroma, unsigned* width, unsigned* height, unsigned* pitches, unsigned* lines); + }; + + extern VideoHandler g_VideoPlayer; +} diff --git a/TombEngine/Specific/level.cpp b/TombEngine/Specific/level.cpp index 95f3c022e..cf7702a2e 100644 --- a/TombEngine/Specific/level.cpp +++ b/TombEngine/Specific/level.cpp @@ -736,7 +736,7 @@ void LoadDynamicRoomData() mesh.pos.Orientation.y = ReadUInt16(); mesh.pos.Orientation.x = ReadUInt16(); mesh.pos.Orientation.z = ReadUInt16(); - mesh.scale = ReadFloat(); + mesh.pos.Scale = Vector3(ReadFloat()); mesh.flags = ReadUInt16(); mesh.color = ReadVector4(); mesh.staticNumber = ReadUInt16(); @@ -1069,11 +1069,13 @@ void LoadAnimatedTextures() for (int i = 0; i < animatedTextureCount; i++) { auto sequence = ANIMATED_TEXTURES_SEQUENCE{}; - sequence.atlas = ReadInt32(); - sequence.Fps = ReadInt32(); - sequence.numFrames = ReadCount(); + sequence.Atlas = ReadInt32(); + sequence.Fps = ReadUInt8(); + sequence.Type = ReadUInt8(); + ReadUInt16(); // Unused. + sequence.NumFrames = ReadCount(); - for (int j = 0; j < sequence.numFrames; j++) + for (int j = 0; j < sequence.NumFrames; j++) { auto frame = ANIMATED_TEXTURES_FRAME{}; frame.x1 = ReadFloat(); @@ -1084,7 +1086,7 @@ void LoadAnimatedTextures() frame.y3 = ReadFloat(); frame.x4 = ReadFloat(); frame.y4 = ReadFloat(); - sequence.frames.push_back(frame); + sequence.Frames.push_back(frame); } g_Level.AnimatedTexturesSequences.push_back(sequence); diff --git a/TombEngine/Specific/level.h b/TombEngine/Specific/level.h index b99b4f963..cd6118e13 100644 --- a/TombEngine/Specific/level.h +++ b/TombEngine/Specific/level.h @@ -44,10 +44,11 @@ struct ANIMATED_TEXTURES_FRAME struct ANIMATED_TEXTURES_SEQUENCE { - int atlas; + int Type; + int Atlas; int Fps; - int numFrames; - std::vector frames; + int NumFrames; + std::vector Frames; }; struct AI_OBJECT diff --git a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h index 3c85b7494..391bc92d8 100644 --- a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h +++ b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h @@ -137,6 +137,10 @@ struct Soundtrack; struct SoundtrackBuilder; struct SoundtrackT; +struct VideoInfo; +struct VideoInfoBuilder; +struct VideoInfoT; + struct SwarmObjectInfo; struct SwarmObjectInfoBuilder; struct SwarmObjectInfoT; @@ -3798,7 +3802,6 @@ struct WeaponControlDataT : public flatbuffers::NativeTable { typedef WeaponControlData TableType; int32_t weapon_item = 0; bool has_fired = false; - bool fired = false; bool uzi_left = false; bool uzi_right = false; int32_t gun_type = 0; @@ -3817,16 +3820,15 @@ struct WeaponControlData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_WEAPON_ITEM = 4, VT_HAS_FIRED = 6, - VT_FIRED = 8, - VT_UZI_LEFT = 10, - VT_UZI_RIGHT = 12, - VT_GUN_TYPE = 14, - VT_REQUEST_GUN_TYPE = 16, - VT_LAST_GUN_TYPE = 18, - VT_HOLSTER_INFO = 20, - VT_NUM_SHOTS_FIRED = 22, - VT_INTERVAL = 24, - VT_TIMER = 26 + VT_UZI_LEFT = 8, + VT_UZI_RIGHT = 10, + VT_GUN_TYPE = 12, + VT_REQUEST_GUN_TYPE = 14, + VT_LAST_GUN_TYPE = 16, + VT_HOLSTER_INFO = 18, + VT_NUM_SHOTS_FIRED = 20, + VT_INTERVAL = 22, + VT_TIMER = 24 }; int32_t weapon_item() const { return GetField(VT_WEAPON_ITEM, 0); @@ -3834,9 +3836,6 @@ struct WeaponControlData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { bool has_fired() const { return GetField(VT_HAS_FIRED, 0) != 0; } - bool fired() const { - return GetField(VT_FIRED, 0) != 0; - } bool uzi_left() const { return GetField(VT_UZI_LEFT, 0) != 0; } @@ -3868,7 +3867,6 @@ struct WeaponControlData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { return VerifyTableStart(verifier) && VerifyField(verifier, VT_WEAPON_ITEM) && VerifyField(verifier, VT_HAS_FIRED) && - VerifyField(verifier, VT_FIRED) && VerifyField(verifier, VT_UZI_LEFT) && VerifyField(verifier, VT_UZI_RIGHT) && VerifyField(verifier, VT_GUN_TYPE) && @@ -3896,9 +3894,6 @@ struct WeaponControlDataBuilder { void add_has_fired(bool has_fired) { fbb_.AddElement(WeaponControlData::VT_HAS_FIRED, static_cast(has_fired), 0); } - void add_fired(bool fired) { - fbb_.AddElement(WeaponControlData::VT_FIRED, static_cast(fired), 0); - } void add_uzi_left(bool uzi_left) { fbb_.AddElement(WeaponControlData::VT_UZI_LEFT, static_cast(uzi_left), 0); } @@ -3941,7 +3936,6 @@ inline flatbuffers::Offset CreateWeaponControlData( flatbuffers::FlatBufferBuilder &_fbb, int32_t weapon_item = 0, bool has_fired = false, - bool fired = false, bool uzi_left = false, bool uzi_right = false, int32_t gun_type = 0, @@ -3962,7 +3956,6 @@ inline flatbuffers::Offset CreateWeaponControlData( builder_.add_weapon_item(weapon_item); builder_.add_uzi_right(uzi_right); builder_.add_uzi_left(uzi_left); - builder_.add_fired(fired); builder_.add_has_fired(has_fired); return builder_.Finish(); } @@ -5212,7 +5205,6 @@ struct StaticMeshInfoT : public flatbuffers::NativeTable { int32_t number = 0; int32_t room_number = 0; std::unique_ptr pose{}; - float scale = 0.0f; std::unique_ptr color{}; int32_t hit_points = 0; int32_t flags = 0; @@ -5226,10 +5218,9 @@ struct StaticMeshInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_NUMBER = 4, VT_ROOM_NUMBER = 6, VT_POSE = 8, - VT_SCALE = 10, - VT_COLOR = 12, - VT_HIT_POINTS = 14, - VT_FLAGS = 16 + VT_COLOR = 10, + VT_HIT_POINTS = 12, + VT_FLAGS = 14 }; int32_t number() const { return GetField(VT_NUMBER, 0); @@ -5240,9 +5231,6 @@ struct StaticMeshInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const TEN::Save::Pose *pose() const { return GetStruct(VT_POSE); } - float scale() const { - return GetField(VT_SCALE, 0.0f); - } const TEN::Save::Vector4 *color() const { return GetStruct(VT_COLOR); } @@ -5257,7 +5245,6 @@ struct StaticMeshInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VerifyField(verifier, VT_NUMBER) && VerifyField(verifier, VT_ROOM_NUMBER) && VerifyField(verifier, VT_POSE) && - VerifyField(verifier, VT_SCALE) && VerifyField(verifier, VT_COLOR) && VerifyField(verifier, VT_HIT_POINTS) && VerifyField(verifier, VT_FLAGS) && @@ -5281,9 +5268,6 @@ struct StaticMeshInfoBuilder { void add_pose(const TEN::Save::Pose *pose) { fbb_.AddStruct(StaticMeshInfo::VT_POSE, pose); } - void add_scale(float scale) { - fbb_.AddElement(StaticMeshInfo::VT_SCALE, scale, 0.0f); - } void add_color(const TEN::Save::Vector4 *color) { fbb_.AddStruct(StaticMeshInfo::VT_COLOR, color); } @@ -5309,7 +5293,6 @@ inline flatbuffers::Offset CreateStaticMeshInfo( int32_t number = 0, int32_t room_number = 0, const TEN::Save::Pose *pose = 0, - float scale = 0.0f, const TEN::Save::Vector4 *color = 0, int32_t hit_points = 0, int32_t flags = 0) { @@ -5317,7 +5300,6 @@ inline flatbuffers::Offset CreateStaticMeshInfo( builder_.add_flags(flags); builder_.add_hit_points(hit_points); builder_.add_color(color); - builder_.add_scale(scale); builder_.add_pose(pose); builder_.add_room_number(room_number); builder_.add_number(number); @@ -5965,6 +5947,113 @@ inline flatbuffers::Offset CreateSoundtrackDirect( flatbuffers::Offset CreateSoundtrack(flatbuffers::FlatBufferBuilder &_fbb, const SoundtrackT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +struct VideoInfoT : public flatbuffers::NativeTable { + typedef VideoInfo TableType; + std::string name{}; + float position = 0.0f; + bool silent = false; + bool looped = false; +}; + +struct VideoInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef VideoInfoT NativeTableType; + typedef VideoInfoBuilder Builder; + struct Traits; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NAME = 4, + VT_POSITION = 6, + VT_SILENT = 8, + VT_LOOPED = 10 + }; + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + float position() const { + return GetField(VT_POSITION, 0.0f); + } + bool silent() const { + return GetField(VT_SILENT, 0) != 0; + } + bool looped() const { + return GetField(VT_LOOPED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_POSITION) && + VerifyField(verifier, VT_SILENT) && + VerifyField(verifier, VT_LOOPED) && + verifier.EndTable(); + } + VideoInfoT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(VideoInfoT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const VideoInfoT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct VideoInfoBuilder { + typedef VideoInfo Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(VideoInfo::VT_NAME, name); + } + void add_position(float position) { + fbb_.AddElement(VideoInfo::VT_POSITION, position, 0.0f); + } + void add_silent(bool silent) { + fbb_.AddElement(VideoInfo::VT_SILENT, static_cast(silent), 0); + } + void add_looped(bool looped) { + fbb_.AddElement(VideoInfo::VT_LOOPED, static_cast(looped), 0); + } + explicit VideoInfoBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateVideoInfo( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + float position = 0.0f, + bool silent = false, + bool looped = false) { + VideoInfoBuilder builder_(_fbb); + builder_.add_position(position); + builder_.add_name(name); + builder_.add_looped(looped); + builder_.add_silent(silent); + return builder_.Finish(); +} + +struct VideoInfo::Traits { + using type = VideoInfo; + static auto constexpr Create = CreateVideoInfo; +}; + +inline flatbuffers::Offset CreateVideoInfoDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, + float position = 0.0f, + bool silent = false, + bool looped = false) { + auto name__ = name ? _fbb.CreateString(name) : 0; + return TEN::Save::CreateVideoInfo( + _fbb, + name__, + position, + silent, + looped); +} + +flatbuffers::Offset CreateVideoInfo(flatbuffers::FlatBufferBuilder &_fbb, const VideoInfoT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + struct SwarmObjectInfoT : public flatbuffers::NativeTable { typedef SwarmObjectInfo TableType; bool on = false; @@ -6899,7 +6988,7 @@ struct FireflyDataT : public flatbuffers::NativeTable { int32_t b = 0; bool on = false; float size = 0.0f; - int32_t rot_Ang = 0; + int32_t rot_ang = 0; }; struct FireflyData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6993,7 +7082,7 @@ struct FireflyData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { float size() const { return GetField(VT_SIZE, 0.0f); } - int32_t rot_Ang() const { + int32_t rot_ang() const { return GetField(VT_ROT_ANG, 0); } bool Verify(flatbuffers::Verifier &verifier) const { @@ -7094,8 +7183,8 @@ struct FireflyDataBuilder { void add_size(float size) { fbb_.AddElement(FireflyData::VT_SIZE, size, 0.0f); } - void add_rot_Ang(int32_t rot_Ang) { - fbb_.AddElement(FireflyData::VT_ROT_ANG, rot_Ang, 0); + void add_rot_ang(int32_t rot_ang) { + fbb_.AddElement(FireflyData::VT_ROT_ANG, rot_ang, 0); } explicit FireflyDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { @@ -7131,9 +7220,9 @@ inline flatbuffers::Offset CreateFireflyData( int32_t b = 0, bool on = false, float size = 0.0f, - int32_t rot_Ang = 0) { + int32_t rot_ang = 0) { FireflyDataBuilder builder_(_fbb); - builder_.add_rot_Ang(rot_Ang); + builder_.add_rot_ang(rot_ang); builder_.add_size(size); builder_.add_b(b); builder_.add_g(g); @@ -8327,6 +8416,7 @@ struct SaveGameT : public flatbuffers::NativeTable { std::vector action_queue{}; std::vector> soundtracks{}; std::vector cd_flags{}; + std::unique_ptr video{}; int32_t postprocess_mode = 0; float postprocess_strength = 0.0f; std::unique_ptr postprocess_tint{}; @@ -8394,30 +8484,31 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_ACTION_QUEUE = 70, VT_SOUNDTRACKS = 72, VT_CD_FLAGS = 74, - VT_POSTPROCESS_MODE = 76, - VT_POSTPROCESS_STRENGTH = 78, - VT_POSTPROCESS_TINT = 80, - VT_ROPE = 82, - VT_PENDULUM = 84, - VT_ALTERNATE_PENDULUM = 86, - VT_VOLUMES = 88, - VT_GLOBAL_EVENT_SETS = 90, - VT_VOLUME_EVENT_SETS = 92, - VT_SCRIPT_VARS = 94, - VT_CALLBACKS_PRE_START = 96, - VT_CALLBACKS_POST_START = 98, - VT_CALLBACKS_PRE_END = 100, - VT_CALLBACKS_POST_END = 102, - VT_CALLBACKS_PRE_SAVE = 104, - VT_CALLBACKS_POST_SAVE = 106, - VT_CALLBACKS_PRE_LOAD = 108, - VT_CALLBACKS_POST_LOAD = 110, - VT_CALLBACKS_PRE_LOOP = 112, - VT_CALLBACKS_POST_LOOP = 114, - VT_CALLBACKS_PRE_USEITEM = 116, - VT_CALLBACKS_POST_USEITEM = 118, - VT_CALLBACKS_PRE_FREEZE = 120, - VT_CALLBACKS_POST_FREEZE = 122 + VT_VIDEO = 76, + VT_POSTPROCESS_MODE = 78, + VT_POSTPROCESS_STRENGTH = 80, + VT_POSTPROCESS_TINT = 82, + VT_ROPE = 84, + VT_PENDULUM = 86, + VT_ALTERNATE_PENDULUM = 88, + VT_VOLUMES = 90, + VT_GLOBAL_EVENT_SETS = 92, + VT_VOLUME_EVENT_SETS = 94, + VT_SCRIPT_VARS = 96, + VT_CALLBACKS_PRE_START = 98, + VT_CALLBACKS_POST_START = 100, + VT_CALLBACKS_PRE_END = 102, + VT_CALLBACKS_POST_END = 104, + VT_CALLBACKS_PRE_SAVE = 106, + VT_CALLBACKS_POST_SAVE = 108, + VT_CALLBACKS_PRE_LOAD = 110, + VT_CALLBACKS_POST_LOAD = 112, + VT_CALLBACKS_PRE_LOOP = 114, + VT_CALLBACKS_POST_LOOP = 116, + VT_CALLBACKS_PRE_USEITEM = 118, + VT_CALLBACKS_POST_USEITEM = 120, + VT_CALLBACKS_PRE_FREEZE = 122, + VT_CALLBACKS_POST_FREEZE = 124 }; const TEN::Save::SaveGameHeader *header() const { return GetPointer(VT_HEADER); @@ -8527,6 +8618,9 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const flatbuffers::Vector *cd_flags() const { return GetPointer *>(VT_CD_FLAGS); } + const TEN::Save::VideoInfo *video() const { + return GetPointer(VT_VIDEO); + } int32_t postprocess_mode() const { return GetField(VT_POSTPROCESS_MODE, 0); } @@ -8678,6 +8772,8 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyVectorOfTables(soundtracks()) && VerifyOffset(verifier, VT_CD_FLAGS) && verifier.VerifyVector(cd_flags()) && + VerifyOffset(verifier, VT_VIDEO) && + verifier.VerifyTable(video()) && VerifyField(verifier, VT_POSTPROCESS_MODE) && VerifyField(verifier, VT_POSTPROCESS_STRENGTH) && VerifyField(verifier, VT_POSTPROCESS_TINT) && @@ -8859,6 +8955,9 @@ struct SaveGameBuilder { void add_cd_flags(flatbuffers::Offset> cd_flags) { fbb_.AddOffset(SaveGame::VT_CD_FLAGS, cd_flags); } + void add_video(flatbuffers::Offset video) { + fbb_.AddOffset(SaveGame::VT_VIDEO, video); + } void add_postprocess_mode(int32_t postprocess_mode) { fbb_.AddElement(SaveGame::VT_POSTPROCESS_MODE, postprocess_mode, 0); } @@ -8980,6 +9079,7 @@ inline flatbuffers::Offset CreateSaveGame( flatbuffers::Offset> action_queue = 0, flatbuffers::Offset>> soundtracks = 0, flatbuffers::Offset> cd_flags = 0, + flatbuffers::Offset video = 0, int32_t postprocess_mode = 0, float postprocess_strength = 0.0f, const TEN::Save::Vector3 *postprocess_tint = 0, @@ -9029,6 +9129,7 @@ inline flatbuffers::Offset CreateSaveGame( builder_.add_postprocess_tint(postprocess_tint); builder_.add_postprocess_strength(postprocess_strength); builder_.add_postprocess_mode(postprocess_mode); + builder_.add_video(video); builder_.add_cd_flags(cd_flags); builder_.add_soundtracks(soundtracks); builder_.add_action_queue(action_queue); @@ -9111,6 +9212,7 @@ inline flatbuffers::Offset CreateSaveGameDirect( const std::vector *action_queue = nullptr, const std::vector> *soundtracks = nullptr, const std::vector *cd_flags = nullptr, + flatbuffers::Offset video = 0, int32_t postprocess_mode = 0, float postprocess_strength = 0.0f, const TEN::Save::Vector3 *postprocess_tint = 0, @@ -9210,6 +9312,7 @@ inline flatbuffers::Offset CreateSaveGameDirect( action_queue__, soundtracks__, cd_flags__, + video, postprocess_mode, postprocess_strength, postprocess_tint, @@ -10201,7 +10304,6 @@ inline void WeaponControlData::UnPackTo(WeaponControlDataT *_o, const flatbuffer (void)_resolver; { auto _e = weapon_item(); _o->weapon_item = _e; } { auto _e = has_fired(); _o->has_fired = _e; } - { auto _e = fired(); _o->fired = _e; } { auto _e = uzi_left(); _o->uzi_left = _e; } { auto _e = uzi_right(); _o->uzi_right = _e; } { auto _e = gun_type(); _o->gun_type = _e; } @@ -10223,7 +10325,6 @@ inline flatbuffers::Offset CreateWeaponControlData(flatbuffer struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WeaponControlDataT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _weapon_item = _o->weapon_item; auto _has_fired = _o->has_fired; - auto _fired = _o->fired; auto _uzi_left = _o->uzi_left; auto _uzi_right = _o->uzi_right; auto _gun_type = _o->gun_type; @@ -10237,7 +10338,6 @@ inline flatbuffers::Offset CreateWeaponControlData(flatbuffer _fbb, _weapon_item, _has_fired, - _fired, _uzi_left, _uzi_right, _gun_type, @@ -10677,7 +10777,6 @@ inline void StaticMeshInfo::UnPackTo(StaticMeshInfoT *_o, const flatbuffers::res { auto _e = number(); _o->number = _e; } { auto _e = room_number(); _o->room_number = _e; } { auto _e = pose(); if (_e) _o->pose = std::unique_ptr(new TEN::Save::Pose(*_e)); } - { auto _e = scale(); _o->scale = _e; } { auto _e = color(); if (_e) _o->color = std::unique_ptr(new TEN::Save::Vector4(*_e)); } { auto _e = hit_points(); _o->hit_points = _e; } { auto _e = flags(); _o->flags = _e; } @@ -10694,7 +10793,6 @@ inline flatbuffers::Offset CreateStaticMeshInfo(flatbuffers::Fla auto _number = _o->number; auto _room_number = _o->room_number; auto _pose = _o->pose ? _o->pose.get() : 0; - auto _scale = _o->scale; auto _color = _o->color ? _o->color.get() : 0; auto _hit_points = _o->hit_points; auto _flags = _o->flags; @@ -10703,7 +10801,6 @@ inline flatbuffers::Offset CreateStaticMeshInfo(flatbuffers::Fla _number, _room_number, _pose, - _scale, _color, _hit_points, _flags); @@ -10899,6 +10996,41 @@ inline flatbuffers::Offset CreateSoundtrack(flatbuffers::FlatBufferB _position); } +inline VideoInfoT *VideoInfo::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = std::make_unique(); + UnPackTo(_o.get(), _resolver); + return _o.release(); +} + +inline void VideoInfo::UnPackTo(VideoInfoT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = name(); if (_e) _o->name = _e->str(); } + { auto _e = position(); _o->position = _e; } + { auto _e = silent(); _o->silent = _e; } + { auto _e = looped(); _o->looped = _e; } +} + +inline flatbuffers::Offset VideoInfo::Pack(flatbuffers::FlatBufferBuilder &_fbb, const VideoInfoT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateVideoInfo(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateVideoInfo(flatbuffers::FlatBufferBuilder &_fbb, const VideoInfoT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const VideoInfoT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _name = _o->name.empty() ? _fbb.CreateSharedString("") : _fbb.CreateString(_o->name); + auto _position = _o->position; + auto _silent = _o->silent; + auto _looped = _o->looped; + return TEN::Save::CreateVideoInfo( + _fbb, + _name, + _position, + _silent, + _looped); +} + inline SwarmObjectInfoT *SwarmObjectInfo::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = std::make_unique(); UnPackTo(_o.get(), _resolver); @@ -11242,7 +11374,7 @@ inline void FireflyData::UnPackTo(FireflyDataT *_o, const flatbuffers::resolver_ { auto _e = b(); _o->b = _e; } { auto _e = on(); _o->on = _e; } { auto _e = size(); _o->size = _e; } - { auto _e = rot_Ang(); _o->rot_Ang = _e; } + { auto _e = rot_ang(); _o->rot_ang = _e; } } inline flatbuffers::Offset FireflyData::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FireflyDataT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -11274,7 +11406,7 @@ inline flatbuffers::Offset CreateFireflyData(flatbuffers::FlatBuffe auto _b = _o->b; auto _on = _o->on; auto _size = _o->size; - auto _rot_Ang = _o->rot_Ang; + auto _rot_ang = _o->rot_ang; return TEN::Save::CreateFireflyData( _fbb, _sprite_index, @@ -11298,7 +11430,7 @@ inline flatbuffers::Offset CreateFireflyData(flatbuffers::FlatBuffe _b, _on, _size, - _rot_Ang); + _rot_ang); } inline ScriptTableT *ScriptTable::UnPack(const flatbuffers::resolver_function_t *_resolver) const { @@ -11758,6 +11890,7 @@ inline void SaveGame::UnPackTo(SaveGameT *_o, const flatbuffers::resolver_functi { auto _e = action_queue(); if (_e) { _o->action_queue.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->action_queue[_i] = _e->Get(_i); } } } { auto _e = soundtracks(); if (_e) { _o->soundtracks.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->soundtracks[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = cd_flags(); if (_e) { _o->cd_flags.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->cd_flags[_i] = _e->Get(_i); } } } + { auto _e = video(); if (_e) _o->video = std::unique_ptr(_e->UnPack(_resolver)); } { auto _e = postprocess_mode(); _o->postprocess_mode = _e; } { auto _e = postprocess_strength(); _o->postprocess_strength = _e; } { auto _e = postprocess_tint(); if (_e) _o->postprocess_tint = std::unique_ptr(new TEN::Save::Vector3(*_e)); } @@ -11828,6 +11961,7 @@ inline flatbuffers::Offset CreateSaveGame(flatbuffers::FlatBufferBuild auto _action_queue = _fbb.CreateVector(_o->action_queue); auto _soundtracks = _fbb.CreateVector> (_o->soundtracks.size(), [](size_t i, _VectorArgs *__va) { return CreateSoundtrack(*__va->__fbb, __va->__o->soundtracks[i].get(), __va->__rehasher); }, &_va ); auto _cd_flags = _fbb.CreateVector(_o->cd_flags); + auto _video = _o->video ? CreateVideoInfo(_fbb, _o->video.get(), _rehasher) : 0; auto _postprocess_mode = _o->postprocess_mode; auto _postprocess_strength = _o->postprocess_strength; auto _postprocess_tint = _o->postprocess_tint ? _o->postprocess_tint.get() : 0; @@ -11890,6 +12024,7 @@ inline flatbuffers::Offset CreateSaveGame(flatbuffers::FlatBufferBuild _action_queue, _soundtracks, _cd_flags, + _video, _postprocess_mode, _postprocess_strength, _postprocess_tint, diff --git a/TombEngine/Specific/savegame/schema/ten_savegame.fbs b/TombEngine/Specific/savegame/schema/ten_savegame.fbs index 11d988d99..f2bd003cd 100644 --- a/TombEngine/Specific/savegame/schema/ten_savegame.fbs +++ b/TombEngine/Specific/savegame/schema/ten_savegame.fbs @@ -265,7 +265,6 @@ table TightropeControlData { table WeaponControlData { weapon_item: int32; has_fired: bool; - fired: bool; uzi_left: bool; uzi_right: bool; gun_type: int32; @@ -373,7 +372,6 @@ table StaticMeshInfo { number: int32; room_number: int32; pose: Pose; - scale: float; color: Vector4; hit_points: int32; flags: int32; @@ -433,6 +431,13 @@ table Soundtrack { position: uint64; } +table VideoInfo { + name: string; + position: float; + silent: bool; + looped: bool; +} + table SwarmObjectInfo { on: bool; pose: Pose; @@ -522,7 +527,7 @@ table FireflyData { b: int32; on: bool; size: float; - rot_Ang: int32; + rot_ang: int32; } struct KeyValPair { @@ -651,6 +656,7 @@ table SaveGame { action_queue: [int32]; soundtracks: [Soundtrack]; cd_flags: [int32]; + video: VideoInfo; postprocess_mode: int32; postprocess_strength: float; diff --git a/TombEngine/Specific/winmain.cpp b/TombEngine/Specific/winmain.cpp index 560073115..049aa9108 100644 --- a/TombEngine/Specific/winmain.cpp +++ b/TombEngine/Specific/winmain.cpp @@ -19,11 +19,12 @@ #include "Scripting/Internal/LanguageScript.h" #include "Scripting/Include/ScriptInterfaceState.h" #include "Scripting/Include/ScriptInterfaceLevel.h" +#include "Video/Video.h" using namespace TEN::Renderer; using namespace TEN::Input; using namespace TEN::Utils; - +using namespace TEN::Video; WINAPP App; unsigned int ThreadID, ConsoleThreadID; @@ -354,8 +355,11 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) if (!DebugMode && ThreadHandle > 0) { TENLog("Resuming game thread", LogLevel::Info); + + if (!g_VideoPlayer.Resume()) + ResumeAllSounds(SoundPauseMode::Global); + ResumeThread((HANDLE)ThreadHandle); - ResumeAllSounds(SoundPauseMode::Global); } return 0; @@ -369,8 +373,11 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) if (!DebugMode) { TENLog("Suspending game thread", LogLevel::Info); + + if (!g_VideoPlayer.Pause()) + PauseAllSounds(SoundPauseMode::Global); + SuspendThread((HANDLE)ThreadHandle); - PauseAllSounds(SoundPauseMode::Global); } } @@ -592,7 +599,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine CoInitializeEx(NULL, COINIT_MULTITHREADED); // Initialize renderer. - g_Renderer.Initialize(g_Configuration.ScreenWidth, g_Configuration.ScreenHeight, g_Configuration.EnableWindowedMode, App.WindowHandle); + g_Renderer.Initialize(gameDir, g_Configuration.ScreenWidth, g_Configuration.ScreenHeight, g_Configuration.EnableWindowedMode, App.WindowHandle); // Initialize audio. Sound_Init(gameDir); @@ -646,25 +653,7 @@ void WinClose() CloseHandle((HANDLE)ConsoleThreadHandle); WaitForSingleObject((HANDLE)ThreadHandle, 5000); - DestroyAcceleratorTable(hAccTable); - - 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; - ShutdownTENLog(); - CoUninitialize(); } diff --git a/TombEngine/TombEngine.vcxproj b/TombEngine/TombEngine.vcxproj index 81555ad89..ed3268b48 100644 --- a/TombEngine/TombEngine.vcxproj +++ b/TombEngine/TombEngine.vcxproj @@ -73,14 +73,14 @@ true $(SolutionDir)Build\$(Configuration)\Bin\x86\ $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86 - $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) - $(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)Libs\spdlog\x86;$(SolutionDir)Libs\lua\x86;$(SolutionDir)Libs\zlib\x86;$(SolutionDir)Libs\bass\x86;$(SolutionDir)Libs\ois\x86 + $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\vlc;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) + $(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)Libs\spdlog\x86;$(SolutionDir)Libs\lua\x86;$(SolutionDir)Libs\zlib\x86;$(SolutionDir)Libs\vlc\x86;$(SolutionDir)Libs\bass\x86;$(SolutionDir)Libs\ois\x86 .exe $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64 - $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) - $(LibraryPath);$(DXSDK_DIR)Lib\x64;$(SolutionDir)Libs\spdlog\x64;$(SolutionDir)Libs\lua\x64;$(SolutionDir)Libs\zlib\x64;$(SolutionDir)Libs\bass\x64;$(SolutionDir)Libs\ois\x64 + $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\vlc;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) + $(LibraryPath);$(DXSDK_DIR)Lib\x64;$(SolutionDir)Libs\spdlog\x64;$(SolutionDir)Libs\lua\x64;$(SolutionDir)Libs\zlib\x64;$(SolutionDir)Libs\vlc\x64;$(SolutionDir)Libs\bass\x64;$(SolutionDir)Libs\ois\x64 .exe true $(ProjectName) @@ -91,14 +91,14 @@ false $(SolutionDir)Build\$(Configuration)\Bin\x86\ $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86 - $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) - $(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)Libs\spdlog\x86;$(SolutionDir)Libs\lua\x86;$(SolutionDir)Libs\zlib\x86;$(SolutionDir)Libs\bass\x86;$(SolutionDir)Libs\ois\x86 + $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\vlc;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) + $(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)Libs\spdlog\x86;$(SolutionDir)Libs\lua\x86;$(SolutionDir)Libs\zlib\x86;$(SolutionDir)Libs\vlc\x86;$(SolutionDir)Libs\bass\x86;$(SolutionDir)Libs\ois\x86 .exe $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64 - $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) - $(LibraryPath);$(DXSDK_DIR)Lib\x64;$(SolutionDir)Libs\spdlog\x64;$(SolutionDir)Libs\lua\x64;$(SolutionDir)Libs\zlib\x64;$(SolutionDir)Libs\bass\x64;$(SolutionDir)Libs\ois\x64 + $(SolutionDir)Libs;$(SolutionDir)Libs\lua;$(SolutionDir)Libs\sol;$(SolutionDir)Libs\zlib;$(SolutionDir)Libs\spdlog;$(SolutionDir)Libs\ois;$(SolutionDir)Libs\vlc;$(SolutionDir)Libs\bass;$(SolutionDir)Libs\srtparser;$(IncludePath) + $(LibraryPath);$(DXSDK_DIR)Lib\x64;$(SolutionDir)Libs\spdlog\x64;$(SolutionDir)Libs\lua\x64;$(SolutionDir)Libs\zlib\x64;$(SolutionDir)Libs\vlc\x64;$(SolutionDir)Libs\bass\x64;$(SolutionDir)Libs\ois\x64 .exe false $(SolutionDir)Build\$(Configuration)\Bin\x64\ @@ -129,7 +129,7 @@ Console true $(OutDir)$(TargetName)$(TargetExt) - comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlogd.lib;OIS_d.lib;%(AdditionalDependencies) + comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlogd.lib;libvlc.lib;libvlccore.lib;OIS_d.lib;%(AdditionalDependencies) false true Default @@ -159,6 +159,7 @@ xcopy /D /Y /I /E "$(ProjectDir)Shaders\*.*" %ShaderDir% xcopy /Y "$(SolutionDir)Libs\bass\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\lua\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\ois\x86\*.dll" "$(TargetDir)" +xcopy /Y "$(SolutionDir)Libs\vlc\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\zlib\x86\*.dll" "$(TargetDir)" xcopy /D /Y /I /E "$(SolutionDir)Scripts\Engine\*.*" %EngineDir% @@ -194,7 +195,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings. Console true $(OutDir)$(TargetName)$(TargetExt) - comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlogd.lib;OIS_d.lib;%(AdditionalDependencies) + comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlogd.lib;libvlc.lib;libvlccore.lib;OIS_d.lib;%(AdditionalDependencies) false true Default @@ -224,6 +225,7 @@ xcopy /D /Y /I /E "$(ProjectDir)Shaders\*.*" %ShaderDir% xcopy /Y "$(SolutionDir)Libs\bass\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\lua\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\ois\x64\*.dll" "$(TargetDir)" +xcopy /Y "$(SolutionDir)Libs\vlc\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\zlib\x64\*.dll" "$(TargetDir)" xcopy /D /Y /I /E "$(SolutionDir)Scripts\Engine\*.*" %EngineDir% @@ -269,7 +271,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings. Console false $(OutDir)$(TargetName)$(TargetExt) - comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlog.lib;OIS.lib;%(AdditionalDependencies) + comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlog.lib;libvlc.lib;libvlccore.lib;OIS.lib;%(AdditionalDependencies) false true MachineX86 @@ -304,6 +306,7 @@ xcopy /D /Y /I /E "$(ProjectDir)Shaders\*.*" %ShaderDir% xcopy /Y "$(SolutionDir)Libs\bass\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\lua\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\ois\x86\*.dll" "$(TargetDir)" +xcopy /Y "$(SolutionDir)Libs\vlc\x86\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\zlib\x86\*.dll" "$(TargetDir)" xcopy /D /Y /I /E "$(SolutionDir)Scripts\Engine\*.*" %EngineDir% @@ -351,7 +354,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings. Console false $(OutDir)$(TargetName)$(TargetExt) - comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlog.lib;OIS.lib;%(AdditionalDependencies) + comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;version.lib;zlib.lib;spdlog.lib;libvlc.lib;libvlccore.lib;OIS.lib;%(AdditionalDependencies) false true UseLinkTimeCodeGeneration @@ -385,6 +388,7 @@ xcopy /D /Y /I /E "$(ProjectDir)Shaders\*.*" %ShaderDir% xcopy /Y "$(SolutionDir)Libs\bass\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\lua\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\ois\x64\*.dll" "$(TargetDir)" +xcopy /Y "$(SolutionDir)Libs\vlc\x64\*.dll" "$(TargetDir)" xcopy /Y "$(SolutionDir)Libs\zlib\x64\*.dll" "$(TargetDir)" xcopy /D /Y /I /E "$(SolutionDir)Scripts\Engine\*.*" %EngineDir% @@ -933,6 +937,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings. + @@ -1354,6 +1359,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings. + diff --git a/TombEngine/framework.h b/TombEngine/framework.h index eac52766c..c20be70e8 100644 --- a/TombEngine/framework.h +++ b/TombEngine/framework.h @@ -23,6 +23,7 @@ #include #include #include +#include using namespace DirectX; using namespace DirectX::SimpleMath;