Add documentation for SetGameFarView, Level.FarView, and Level.UVRotate, as well as some value checking.

This commit is contained in:
hispidence 2021-08-17 13:36:34 +01:00
parent 011c5b2222
commit 672f90e238
6 changed files with 174 additions and 8 deletions

View file

@ -1,6 +1,6 @@
#include "framework.h"
#include "GameScriptLevel.h"
#include <unordered_map>
#include "ScriptAssert.h"
/***
A container for level metadata - things which aren't present in the compiled
@ -48,7 +48,8 @@ void GameScriptLevel::Register(sol::state* state)
"layer2", &GameScriptLevel::Layer2,
/// (@{Color}) distance fog RGB color (as seen in TR4's Desert Railroad).
// if not provided, distance fog will be black.
// If not provided, distance fog will be black.
//
// __(not yet implemented)__
//@mem fog
"fog", &GameScriptLevel::Fog,
@ -59,17 +60,20 @@ void GameScriptLevel::Register(sol::state* state)
/// (bool) if true, the horizon graphic will transition smoothly to the sky layer.
// If set to false, there will be a black band between the two.
//
// __(not yet implemented)__
//@mem colAddHorizon
"colAddHorizon", &GameScriptLevel::ColAddHorizon,
/// (bool) equivalent to classic TRLE's LIGHTNING setting.
// If true, there will be a flickering lightning in the skylayer, as in the TRC Ireland levels.
//
// __(thunder sounds not yet implemented)__
//@mem storm
"storm", &GameScriptLevel::Storm,
/// (WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW.
//
// __(not yet implemented)__
//@mem weather
"weather", &GameScriptLevel::Weather,
@ -96,12 +100,68 @@ e.g. `myLevel.laraType = LaraType.DIVESUIT`
"rumble", &GameScriptLevel::Rumble,
/// (@{Mirror}) object holding the location and size of the room's mirror, if present.
//
// __(not yet implemented)__
//@mem mirror
"mirror", &GameScriptLevel::Mirror,
/*** (byte) Default speed of "UVRotate" animated textures.
Must be in the range [-64, 64].
A level texture can be set in Tomb Editor to use "UVRotate" animation.
This gives the effect of the texture looping downwards or upwards in place.
Positive values will cause the texture to loop downwards, and negative values
will cause an upwards loop. The higher a positive number or the lower a negative
number, the faster the scroll will be.
__(not yet implemented)__
@mem UVRotate*/
"UVRotate", sol::property(&GameScriptLevel::SetUVRotate),
/*** (byte) The maximum draw distance, in sectors (blocks), of this particular level.
Must be in the range [1, 127], and equal to or less than the value passed to SetGameFarView.
This is equivalent to TRNG's LevelFarView variable.
__(not yet implemented)__
@mem farView
*/
"farView", sol::property(&GameScriptLevel::SetLevelFarView),
/// (table of @{InventoryObject}s) table of inventory object overrides
//@mem objects
"objects", &GameScriptLevel::InventoryObjects
);
}
void GameScriptLevel::SetUVRotate(byte val)
{
bool cond = val <= 64 && val >= -64;
std::string msg{ "UVRotate value must be in the range [-64, 64]." };
if (!ScriptAssert(cond, msg))
{
ScriptWarn("Setting UVRotate to 0.");
UVRotate = 0;
}
else
{
UVRotate = val;
}
}
void GameScriptLevel::SetLevelFarView(byte val)
{
bool cond = val <= 127 && val >= 1;
std::string msg{ "levelFarView value must be in the range [1, 127]." };
if (!ScriptAssert(cond, msg))
{
ScriptWarn("Setting levelFarView view to 32.");
LevelFarView = 32;
}
else
{
LevelFarView = val;
}
}