feat(statusbar): add reverse fill, rotated texture, fill styles, color fill and desaturation

StatusBar gains SetReverseFill / GetReverseFill, SetRotatesTexture /
GetRotatesTexture, SetFillStyle / GetFillStyle (with
Enum.StatusBarFillStyle), SetColorFill, and SetStatusBarDesaturated /
IsStatusBarDesaturated / SetStatusBarDesaturation /
GetStatusBarDesaturation.

1.12 draws the fill by cropping the bar texture from its bottom-left
corner. A bar with a mode on takes 4.3.4's layout instead: its
OnFrameUpdate co-hook sets the coordinates and moves the texture's four
points, with the crop flag off. A bar with every mode off runs 1.12's
own update. SetColorFill creates a bar texture the way
SetStatusBarTexture does when the bar has none, then fills it through
the engine's Texture:SetTexture handler. The desaturation methods use
the bar texture's Texture::Desaturation state, now exposed in
texture/Desaturation.h.
This commit is contained in:
Brues
2026-10-20 15:06:57 -05:00
parent f112a13695
commit 1d3ca3db6e
8 changed files with 717 additions and 17 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ reference in **[docs/API.md](docs/API.md)**.
| [Expansion](docs/API.md#expansion) | `ClassicExpansionAtLeast`, `ClassicExpansionAtMost`, `GetClassicExpansionLevel` |
| [Faction](docs/API.md#faction) | `C_Reputation.GetFactionDataByID`, `C_Reputation.GetFactionDataByIndex`, `C_Reputation.GetFactionStandings`, `C_Reputation.GetLastStandingChange`, `C_Reputation.GetWatchedFactionData`, `C_Reputation.IsFactionActive`, `C_Reputation.IsFactionActiveByID`, `C_Reputation.IsFactionInactive`, `C_Reputation.SetFactionActive`, `C_Reputation.SetFactionActiveByID`, `C_Reputation.SetFactionInactive`, `C_Reputation.SetFactionInactiveByID`, `C_Reputation.SetSelectedFaction`, `C_Reputation.SetSelectedFactionByID`, `C_Reputation.SetWatchedFactionByID`, `C_Reputation.ToggleFactionAtWar`, `C_Reputation.ToggleFactionAtWarByID`, `GetFactionIDByIndex`, `GetFactionInfoByID`, `GetFactionParentID` |
| [Focus](docs/API.md#focus) | `ClearFocus`, `FocusUnit` |
| [Frame](docs/API.md#frame) | `region:SetPoint("point")` (one-arg form), `region:SetSize`, `region:GetSize`, `region:IsMouseOver`, `region:GetRect`, `region:IsDragging`, `GetMouseFoci`, `CreateFrame` template lists and `id`, `CreateFrame("Cooldown")`, `cooldown:SetCooldown`, `cooldown:SetReverse`, `cooldown:GetReverse`, `cooldown:SetDrawEdge`, `cooldown:GetDrawEdge`, `frame:SetShown`, `frame:SetClampRectInsets`, `frame:GetClampRectInsets`, `smf:SetHyperlinksEnabled`, `smf:GetHyperlinksEnabled`, `editBox:SetCountInvisibleLetters`, `editBox:IsCountInvisibleLetters`, `fontstring:GetStringHeight`, `fontstring:GetUnboundedStringWidth`, `fontstring:GetWrappedWidth`, `fontstring:GetNumLines`, `fontstring:GetLineHeight`, `fontstring:IsTruncated`, `fontstring:SetMaxLines`, `fontstring:GetMaxLines`, `fontstring:SetWordWrap`, `fontstring:CanWordWrap`, `fontstring:GetFieldSize`, `SetIndentedWordWrap`, `GetIndentedWordWrap` (font strings, fonts, edit boxes, message frames, SimpleHTML), `fontstring:SetFormattedText`, `button:SetFormattedText`, `texture:SetRotation`, `texture:GetRotation`, `texture:SetVertexOffset`, `texture:GetVertexOffset`, `texture:SetColorTexture`, `texture:SetAtlas`, `texture:GetAtlas`, `texture:ResetTexCoord`, `texture:SetSpriteSheetCell`, `texture:SetDesaturation`, `texture:GetDesaturation`, `texture:SetMask`, `frame:CreateMaskTexture`, `texture:AddMaskTexture`, `texture:RemoveMaskTexture`, `texture:GetNumMaskTextures`, `texture:GetMaskTexture`, `fontstring:SetRotation`, `fontstring:GetRotation`, `editBox:SetCursorPosition`, `editBox:GetCursorPosition`, `editBox:GetUTF8CursorPosition`, `editBox:ClearHighlightText`, `editBox:HasFocus`, `editBox:HasText`, `editBox:SetHighlightColor`, `editBox:GetHighlightColor`, `editBox:ClearHistory`, `editBox:Enable`, `editBox:Disable`, `editBox:IsEnabled`, `slider:Enable`, `slider:Disable`, `slider:IsEnabled`, `editBox:IsInIMECompositionMode`, `OnEnable` (script), `OnDisable` (script), `OnMinMaxChanged` (script), `OnCharComposition` (script), `OnTextChanged` `userInput`, `frame:SetResizeBounds`, `frame:HookScript`, `region:IsProtected`, `region:CanChangeProtectedState`, `frame:CanChangeAttribute`, `frame:AllowAttributeChanges`, `frame:SetPropagateKeyboardInput`, `frame:GetPropagateKeyboardInput`, `frame:SetDontSavePosition`, `frame:GetDontSavePosition`, `frame:GetBoundsRect`, `button:SetNormalFontObject`, `button:GetNormalFontObject`, `button:SetMotionScriptsWhileDisabled`, `button:GetMotionScriptsWhileDisabled`, `button:SetEnabled`, `frame:IsEventRegistered`, `frame:RegisterUnitEvent`, `frame:GetEffectiveAlpha`, `frame:SetAttribute`, `frame:SetAttributeNoHandler`, `frame:ClearAttribute`, `frame:GetAttribute`, `OnAttributeChanged` (script), `SetModernScriptArgs`, `GetModernScriptArgs`, `PreClick` (script), `PostClick` (script), `button:RegisterForClicks("AnyUp"/"AnyDown")`, `button:RegisterForMouse`, `GetClickFrame` |
| [Frame](docs/API.md#frame) | `region:SetPoint("point")` (one-arg form), `region:SetSize`, `region:GetSize`, `region:IsMouseOver`, `region:GetRect`, `region:IsDragging`, `GetMouseFoci`, `CreateFrame` template lists and `id`, `CreateFrame("Cooldown")`, `cooldown:SetCooldown`, `cooldown:SetReverse`, `cooldown:GetReverse`, `cooldown:SetDrawEdge`, `cooldown:GetDrawEdge`, `frame:SetShown`, `frame:SetClampRectInsets`, `frame:GetClampRectInsets`, `smf:SetHyperlinksEnabled`, `smf:GetHyperlinksEnabled`, `editBox:SetCountInvisibleLetters`, `editBox:IsCountInvisibleLetters`, `fontstring:GetStringHeight`, `fontstring:GetUnboundedStringWidth`, `fontstring:GetWrappedWidth`, `fontstring:GetNumLines`, `fontstring:GetLineHeight`, `fontstring:IsTruncated`, `fontstring:SetMaxLines`, `fontstring:GetMaxLines`, `fontstring:SetWordWrap`, `fontstring:CanWordWrap`, `fontstring:GetFieldSize`, `SetIndentedWordWrap`, `GetIndentedWordWrap` (font strings, fonts, edit boxes, message frames, SimpleHTML), `fontstring:SetFormattedText`, `button:SetFormattedText`, `texture:SetRotation`, `texture:GetRotation`, `texture:SetVertexOffset`, `texture:GetVertexOffset`, `texture:SetColorTexture`, `texture:SetAtlas`, `texture:GetAtlas`, `texture:ResetTexCoord`, `texture:SetSpriteSheetCell`, `texture:SetDesaturation`, `texture:GetDesaturation`, `texture:SetMask`, `frame:CreateMaskTexture`, `texture:AddMaskTexture`, `texture:RemoveMaskTexture`, `texture:GetNumMaskTextures`, `texture:GetMaskTexture`, `fontstring:SetRotation`, `fontstring:GetRotation`, `editBox:SetCursorPosition`, `editBox:GetCursorPosition`, `editBox:GetUTF8CursorPosition`, `editBox:ClearHighlightText`, `editBox:HasFocus`, `editBox:HasText`, `editBox:SetHighlightColor`, `editBox:GetHighlightColor`, `editBox:ClearHistory`, `editBox:Enable`, `editBox:Disable`, `editBox:IsEnabled`, `slider:Enable`, `slider:Disable`, `slider:IsEnabled`, `editBox:IsInIMECompositionMode`, `OnEnable` (script), `OnDisable` (script), `OnMinMaxChanged` (script), `statusBar:SetReverseFill`, `statusBar:GetReverseFill`, `statusBar:SetRotatesTexture`, `statusBar:GetRotatesTexture`, `statusBar:SetFillStyle`, `statusBar:GetFillStyle`, `statusBar:SetColorFill`, `statusBar:SetStatusBarDesaturated`, `statusBar:IsStatusBarDesaturated`, `statusBar:SetStatusBarDesaturation`, `statusBar:GetStatusBarDesaturation`, `OnCharComposition` (script), `OnTextChanged` `userInput`, `frame:SetResizeBounds`, `frame:HookScript`, `region:IsProtected`, `region:CanChangeProtectedState`, `frame:CanChangeAttribute`, `frame:AllowAttributeChanges`, `frame:SetPropagateKeyboardInput`, `frame:GetPropagateKeyboardInput`, `frame:SetDontSavePosition`, `frame:GetDontSavePosition`, `frame:GetBoundsRect`, `button:SetNormalFontObject`, `button:GetNormalFontObject`, `button:SetMotionScriptsWhileDisabled`, `button:GetMotionScriptsWhileDisabled`, `button:SetEnabled`, `frame:IsEventRegistered`, `frame:RegisterUnitEvent`, `frame:GetEffectiveAlpha`, `frame:SetAttribute`, `frame:SetAttributeNoHandler`, `frame:ClearAttribute`, `frame:GetAttribute`, `OnAttributeChanged` (script), `SetModernScriptArgs`, `GetModernScriptArgs`, `PreClick` (script), `PostClick` (script), `button:RegisterForClicks("AnyUp"/"AnyDown")`, `button:RegisterForMouse`, `GetClickFrame` |
| [FriendList](docs/API.md#friendlist) | `C_FriendList.GetFriendInfo`, `C_FriendList.GetFriendInfoByIndex`, `C_FriendList.GetNumFriends`, `C_FriendList.GetNumOnlineFriends`, `C_FriendList.GetNumWhoResults`, `C_FriendList.GetWhoInfo`, `C_FriendList.IsFriend`, `C_FriendList.IsIgnored`, `C_FriendList.IsIgnoredByGuid`, `C_FriendList.IsWhoQueryPending`, `C_FriendList.SendWhoQueryByName`, `C_FriendList.SetFriendNotes`, `C_FriendList.SetFriendNotesByIndex` |
| [GameObject](docs/API.md#gameobject) | `C_GameObjectInfo.GetGameObjectInfoByID`, `C_GameObjectInfo.RequestLoadGameObjectByID`, `ClosestGameObjectPosition` |
| [Glue](docs/API.md#glue) | `C_Glue.IsOnGlueScreen` |
+3 -1
View File
@@ -4082,7 +4082,9 @@ Each entry still needs the usual check of how the engine does it before building
- **DONE** (`src/frame/MinMaxChanged.cpp`). **OnMinMaxChanged** (Slider, StatusBar): `SetMinMaxValues` runs it with
`(min, max)` when the range changes (`CSimpleStatusBar.cpp:39/141`). 1.12 has
no such script.
- **StatusBar** `SetReverseFill` / `GetReverseFill`, `SetRotatesTexture` /
- **DONE** (`src/statusbar/Fill.cpp`, `src/statusbar/BarTexture.cpp`; XML
`reverseFill` / `rotatesTexture` / `fillStyle` attributes not backported).
**StatusBar** `SetReverseFill` / `GetReverseFill`, `SetRotatesTexture` /
`GetRotatesTexture` (`CSimpleStatusBar.cpp:135`, the vertical texcoord path
at `:285`). Retail adds `SetFillStyle` (STANDARD / CENTER / REVERSE),
`SetColorFill`, `SetStatusBarDesaturated` / `Desaturation`.
+67
View File
@@ -296,6 +296,11 @@ build instructions.
- [`slider:Enable()` / `slider:Disable()` / `slider:IsEnabled()`](#sliderenable--sliderdisable--sliderisenabled)
- [`OnEnable` and `OnDisable` (scripts)](#onenable-and-ondisable-scripts)
- [`OnMinMaxChanged(self, min, max)` (script)](#onminmaxchangedself-min-max-script)
- [`statusBar:SetReverseFill(isReverseFill)` / `statusBar:GetReverseFill()`](#statusbarsetreversefillisreversefill--statusbargetreversefill)
- [`statusBar:SetRotatesTexture(rotatesTexture)` / `statusBar:GetRotatesTexture()`](#statusbarsetrotatestexturerotatestexture--statusbargetrotatestexture)
- [`statusBar:SetFillStyle(fillStyle)` / `statusBar:GetFillStyle()`](#statusbarsetfillstylefillstyle--statusbargetfillstyle)
- [`statusBar:SetColorFill(colorR, colorG, colorB [, a])`](#statusbarsetcolorfillcolorr-colorg-colorb--a)
- [`statusBar:SetStatusBarDesaturation(desaturation)` / `statusBar:GetStatusBarDesaturation()`](#statusbarsetstatusbardesaturationdesaturation--statusbargetstatusbardesaturation)
- [`editBox:IsInIMECompositionMode()`](#editboxisinimecompositionmode)
- [`OnCharComposition(self, text)` (script)](#oncharcompositionself-text-script)
- [`OnTextChanged(self, userInput)` (script)](#ontextchangedself-userinput-script)
@@ -6773,6 +6778,68 @@ bar:SetScript("OnMinMaxChanged", function(self, min, max)
end)
```
### `statusBar:SetReverseFill(isReverseFill)` / `statusBar:GetReverseFill()`
`statusBar:SetReverseFill(true)` makes the bar fill from the right edge. A
vertical bar fills from the top edge. `statusBar:GetReverseFill()` returns
`true` or `false`.
- The bar texture shows the same part of its image as in a normal fill. Only
the side that the fill grows from changes.
- The fill style `Enum.StatusBarFillStyle.Reverse` has the same result.
### `statusBar:SetRotatesTexture(rotatesTexture)` / `statusBar:GetRotatesTexture()`
`statusBar:SetRotatesTexture(true)` turns the image of the bar texture by a
quarter turn. Use it to put a horizontal bar image on a vertical bar.
`statusBar:GetRotatesTexture()` returns `true` or `false`.
### `statusBar:SetFillStyle(fillStyle)` / `statusBar:GetFillStyle()`
Sets how the bar fills as its value increases. `fillStyle` is a value of
`Enum.StatusBarFillStyle`, or its name as a string:
| Value | String | Fill |
|---|---|---|
| `Enum.StatusBarFillStyle.Standard` (0) | `"STANDARD"` | From the left edge, or from the bottom edge of a vertical bar. This is the default. |
| `Enum.StatusBarFillStyle.StandardNoRangeFill` (1) | `"STANDARD_NO_RANGE_FILL"` | As `Standard`. A bar whose `min` and `max` are equal shows full, but a bar whose `min` and `max` are both 0 shows empty. |
| `Enum.StatusBarFillStyle.Center` (2) | `"CENTER"` | From the center to the two edges. |
| `Enum.StatusBarFillStyle.Reverse` (3) | `"REVERSE"` | From the right edge, or from the top edge of a vertical bar. |
`statusBar:GetFillStyle()` returns the number.
- A string is not case-sensitive. Any other value is an error.
- The `Center` style ignores `statusBar:SetReverseFill()`.
```lua
bar:SetFillStyle(Enum.StatusBarFillStyle.Center)
```
### `statusBar:SetColorFill(colorR, colorG, colorB [, a])`
Fills the bar texture with one color. The values go from 0 to 1, and `a` is
1 when you do not give it. If the bar has no bar texture, the method makes
one in the `ARTWORK` layer.
```lua
bar:SetColorFill(0, 0.8, 0)
```
### `statusBar:SetStatusBarDesaturation(desaturation)` / `statusBar:GetStatusBarDesaturation()`
Sets how much color the bar texture loses, from 0 (full color) to 1 (gray).
This is `texture:SetDesaturation()` on the bar texture.
`statusBar:GetStatusBarDesaturation()` returns the value.
`statusBar:SetStatusBarDesaturated(desaturated)` sets the value to 1 when
`desaturated` is `true`, and to 0 when it is `false`.
`statusBar:IsStatusBarDesaturated()` returns `true` when the value is more
than 0.
- The value belongs to the bar texture. A new bar texture starts with full
color.
- A bar with no bar texture ignores the setters and returns 0 or `false`.
### `editBox:IsInIMECompositionMode()`
Returns `1` while an input method (for example, one for Chinese, Japanese,
+31
View File
@@ -3170,6 +3170,37 @@ enum Offsets {
// CSimpleStatusBar::SetValue's vtable slot (0x007832D0), `void
// __thiscall(bar, float)`, as FUN_STATUSBAR_SET_MIN_MAX_VALUES calls it.
OFF_VMT_STATUSBAR_SET_VALUE = 0x90,
// The method hash StatusBar's 10 methods (table 0x0087B010) register into
// (RegisterStatusBarMethods 0x007900A0).
VAR_STATUSBAR_METHOD_REGISTRY = 0x00CF51CC,
// The bar texture (CSimpleTexture *) and the orientation (0 HORIZONTAL,
// 1 VERTICAL), as CSimpleStatusBar::OnFrameUpdate reads them.
OFF_STATUSBAR_BAR_TEXTURE = 0x324,
OFF_STATUSBAR_ORIENTATION = 0x328,
// Flags bit 0: the fill needs laying out. SetValue, SetMinMaxValues and
// FUN_STATUSBAR_INSTALL_BAR_TEXTURE set it; OnFrameUpdate clears it.
VALUE_FLAG_CHANGED = 0x1,
// CSimpleStatusBar::OnFrameUpdate — `void __thiscall(bar, float
// elapsed)`, `ret 4` (the decompile hides the argument), vtable slot 14:
// passes `elapsed` to FUN_FRAME_ON_UPDATE, then with VALUE_FLAG_CHANGED, a range, a
// value and a bar texture sets the texture's coordinates to {0, 0, 1,
// fill} (horizontal) or {0, 0, fill, 1} (vertical) through
// FUN_SIMPLETEXTURE_SET_TEXCOORD and clears the bit. The texture's
// OFF_REGION_TEXCOORD_MODIFIES_RECT crop draws the filled part.
FUN_STATUSBAR_ON_FRAME_UPDATE = 0x007833C0,
// CSimpleStatusBar::InstallBarTexture — `void __thiscall(bar, texture,
// int drawLayer)`, `ret 8`: deletes the old bar texture, parents the new
// one to the bar in the layer, sets its OFF_REGION_TEXCOORD_MODIFIES_RECT
// to 1 and sets VALUE_FLAG_CHANGED. Pins no points.
FUN_STATUSBAR_INSTALL_BAR_TEXTURE = 0x007831F0,
// CLayoutFrame::SetAllPoints — `void __thiscall(region+OFF_REGION_ANCHOR,
// relative+OFF_REGION_ANCHOR, int doResize)`, `ret 8`. The bar's
// SetBarTexture-by-path (0x00783140) pins a new texture with (bar, 1).
FUN_LAYOUT_SET_ALL_POINTS = 0x00767DB0,
// CSimpleTexture::SetTexCoord, corner form — `void __thiscall(tex, const
// float[8])`: UL, LL, UR, LR (x, y) pairs into +0x104, crop and store only
// with OFF_REGION_TEXCOORD_MODIFIES_RECT. The 8-argument SetTexCoord.
FUN_SIMPLETEXTURE_SET_TEXCOORD_CORNERS = 0x007704C0,
// CFrameScriptObject vtable slot 4 — the `IsA(typeId)` predicate every
// frame class implements, and the gate every engine method applies to its
+172
View File
@@ -0,0 +1,172 @@
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
// `bar:SetColorFill(r, g, b [, a])` and the bar texture's desaturation:
// `SetStatusBarDesaturated`, `IsStatusBarDesaturated`,
// `SetStatusBarDesaturation`, `GetStatusBarDesaturation`.
//
// SetColorFill fills the bar texture with a solid colour. A bar with no
// texture gets one the way SetStatusBarTexture-by-path (0x00783140) makes it -
// a pooled CSimpleTexture in ARTWORK, pinned to every point of the bar and
// installed with FUN_STATUSBAR_INSTALL_BAR_TEXTURE - less the file. The colour
// goes through the engine's own Texture:SetTexture handler with the texture as
// self, whose numeric form is the solid fill (the same reuse as
// Texture:SetColorTexture), so the clamp and opaque default alpha are the
// engine's.
//
// The desaturation methods act on the bar texture through Texture::
// Desaturation; a bar with no texture reports 0 / false.
#include "Game.h"
#include "Offsets.h"
#include "texture/Desaturation.h"
namespace StatusBar::BarTexture {
namespace {
using PoolAlloc_t = void *(__thiscall *)(void *pool, int zeroInit, const char *tag, int line);
using TexCtor_t = void *(__thiscall *)(void *mem, void *parent, int layer, int sublayer);
using SetAllPoints_t = void(__thiscall *)(void *anchor, void *relative, int doResize);
using Install_t = void(__thiscall *)(void *bar, void *texture, int drawLayer);
void *BarTextureOf(void *bar) { return Game::Read<void *>(bar, Offsets::OFF_STATUSBAR_BAR_TEXTURE); }
void *CreateBarTexture(void *bar) {
void *mem = reinterpret_cast<PoolAlloc_t>(Offsets::FUN_REGION_POOL_ALLOC)(
reinterpret_cast<void *>(Offsets::VAR_SIMPLETEXTURE_POOL), 0,
reinterpret_cast<const char *>(Offsets::VAR_SIMPLETEXTURE_CLASS_TAG), -2);
if (mem == nullptr)
return nullptr;
void *texture =
reinterpret_cast<TexCtor_t>(Offsets::FUN_SIMPLETEXTURE_CTOR)(mem, nullptr, Offsets::DRAWLAYER_ARTWORK, 1);
reinterpret_cast<SetAllPoints_t>(Offsets::FUN_LAYOUT_SET_ALL_POINTS)(
Game::Ptr<uint8_t>(texture, Offsets::OFF_REGION_ANCHOR), Game::Ptr<uint8_t>(bar, Offsets::OFF_REGION_ANCHOR),
1);
reinterpret_cast<Install_t>(Offsets::FUN_STATUSBAR_INSTALL_BAR_TEXTURE)(bar, texture,
Offsets::DRAWLAYER_ARTWORK);
return texture;
}
void *ResolveBar(void *L) { return Game::Lua::ResolveTypedObject(L, 1, Offsets::VAR_STATUSBAR_LUA_TYPE_ID); }
int __fastcall Script_SetColorFill(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
if (!Game::Lua::IsNumber(L, 2) || !Game::Lua::IsNumber(L, 3) || !Game::Lua::IsNumber(L, 4)) {
Game::Lua::Error(L, "Usage: %s:SetColorFill(r, g, b [, a])", Game::Lua::ObjectDisplayName(bar));
return 0;
}
void *texture = BarTextureOf(bar);
if (texture == nullptr)
texture = CreateBarTexture(bar);
if (texture == nullptr)
return 0;
Game::Lua::PushObject(L, texture);
Game::Lua::Remove(L, 1);
Game::Lua::Insert(L, 1);
reinterpret_cast<Game::Lua::CFunction>(Offsets::FUN_SCRIPT_TEXTURE_SET_TEXTURE)(L);
return 0;
}
int __fastcall Script_SetStatusBarDesaturated(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
if (void *texture = BarTextureOf(bar))
Texture::Desaturation::SetAmount(texture, Game::Lua::ToBoolean(L, 2) != 0 ? 1.0 : 0.0);
return 0;
}
int __fastcall Script_IsStatusBarDesaturated(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
void *texture = BarTextureOf(bar);
Game::Lua::PushBool(L, texture != nullptr && Texture::Desaturation::GetAmount(texture) > 0.0);
return 1;
}
int __fastcall Script_SetStatusBarDesaturation(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
if (!Game::Lua::IsNumber(L, 2)) {
Game::Lua::Error(L, "Usage: %s:SetStatusBarDesaturation(desaturation)", Game::Lua::ObjectDisplayName(bar));
return 0;
}
if (void *texture = BarTextureOf(bar))
Texture::Desaturation::SetAmount(texture, Game::Lua::ToNumber(L, 2));
return 0;
}
int __fastcall Script_GetStatusBarDesaturation(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
void *texture = BarTextureOf(bar);
Game::Lua::PushNumber(L, texture != nullptr ? Texture::Desaturation::GetAmount(texture) : 0.0);
return 1;
}
const Game::Lua::FrameMethodEntry g_methods[] = {
{"SetColorFill", &Script_SetColorFill},
{"SetStatusBarDesaturated", &Script_SetStatusBarDesaturated},
{"IsStatusBarDesaturated", &Script_IsStatusBarDesaturated},
{"SetStatusBarDesaturation", &Script_SetStatusBarDesaturation},
{"GetStatusBarDesaturation", &Script_GetStatusBarDesaturation},
};
const Game::Doc::Field kSetColorFillArgs[] = {
Game::Doc::Req("colorR", "number"),
Game::Doc::Req("colorG", "number"),
Game::Doc::Req("colorB", "number"),
Game::Doc::Opt("a", "SingleColorValue"),
};
const Game::Doc::Field kSetDesaturatedArgs[] = {Game::Doc::Opt("desaturated", "bool", "false")};
const Game::Doc::Field kIsDesaturatedRets[] = {Game::Doc::Req("desaturated", "bool")};
const Game::Doc::Field kSetDesaturationArgs[] = {Game::Doc::Req("desaturation", "normalizedValue")};
const Game::Doc::Field kGetDesaturationRets[] = {Game::Doc::Req("desaturation", "normalizedValue")};
const Game::Doc::Function kSetColorFill{"Fills the bar texture with a solid colour, creating the texture if the bar has none.",
kSetColorFillArgs, {}};
const Game::Doc::Function kSetDesaturated{"Sets whether the bar texture is drawn fully desaturated.",
kSetDesaturatedArgs, {}};
const Game::Doc::Function kIsDesaturated{"Returns whether the bar texture is desaturated at all.", {},
kIsDesaturatedRets};
const Game::Doc::Function kSetDesaturation{"Sets how desaturated the bar texture is drawn, from 0 to 1.",
kSetDesaturationArgs, {}};
const Game::Doc::Function kGetDesaturation{"Returns how desaturated the bar texture is drawn, from 0 to 1.", {},
kGetDesaturationRets};
const Game::Doc::Method g_methodDocs[] = {
{"SetColorFill", &kSetColorFill},
{"SetStatusBarDesaturated", &kSetDesaturated},
{"IsStatusBarDesaturated", &kIsDesaturated},
{"SetStatusBarDesaturation", &kSetDesaturation},
{"GetStatusBarDesaturation", &kGetDesaturation},
};
void RegisterLuaFunctions() {
Game::Lua::RegisterFrameMethods(
reinterpret_cast<void *>(Offsets::VAR_STATUSBAR_METHOD_REGISTRY), g_methods,
static_cast<int>(sizeof(g_methods) / sizeof(g_methods[0])), g_methodDocs,
static_cast<int>(sizeof(g_methodDocs) / sizeof(g_methodDocs[0])));
}
const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
} // namespace
} // namespace StatusBar::BarTexture
+390
View File
@@ -0,0 +1,390 @@
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
// `bar:SetReverseFill` / `GetReverseFill`, `SetRotatesTexture` /
// `GetRotatesTexture` and `SetFillStyle` / `GetFillStyle`.
//
// 1.12 draws the fill by cropping: the bar texture is installed with
// OFF_REGION_TEXCOORD_MODIFIES_RECT, and OnFrameUpdate sets its coordinates to
// the filled part, which shrinks its rectangle from the bottom-left corner.
// That crop can only grow a fill from the left or the bottom.
//
// 4.3.4's CSimpleStatusBar::OnLayerUpdate (CSimpleStatusBar.cpp:248) does not
// crop: it sets the coordinates and moves the texture's four points in from
// the bar's edges by the empty part, from the right / top or, reversed, from
// the left / bottom (`m_reverseFill`), and with `m_rotatesTexture` maps the
// image turned a quarter. A bar with any of these modes on takes that layout
// here: the co-hook on OnFrameUpdate runs the base frame update and lays the
// texture out as 4.3.4 does, with the crop flag cleared on the texture. A bar
// with them all off runs 1.12's own update untouched. Turning the last mode
// off pins the texture to the bar again and gives it back its crop flag, as
// InstallBarTexture and SetBarTexture leave it.
//
// The retail fill styles (Enum.StatusBarFillStyle) fit the same layout:
// Reverse is the reversed fill; Center insets both ends by half the empty
// part and shows the middle of the image; StandardNoRangeFill draws a bar
// with an empty range full unless min and max are both 0.
//
// 4.3.4 lays out again when m_changed is set, and its SetWidth sets it; a
// bar's height change re-lays nothing there. Here a size change in either
// axis does, since the offsets are lengths in the bar's units.
#include "Game.h"
#include "Offsets.h"
#include "baselib/Ascii.h"
#include "frame/Destruction.h"
#include <cstdint>
#include <unordered_map>
namespace StatusBar::Fill {
namespace {
enum FillStyle : int {
kStandard = 0,
kStandardNoRangeFill = 1,
kCenter = 2,
kReverse = 3,
};
const Game::Lua::EnumIntegerEntry kFillStyleEntries[] = {
{"Standard", kStandard},
{"StandardNoRangeFill", kStandardNoRangeFill},
{"Center", kCenter},
{"Reverse", kReverse},
};
// The names retail's XML `fillStyle` attribute takes, for SetFillStyle("...").
const char *const kFillStyleTokens[] = {"STANDARD", "STANDARD_NO_RANGE_FILL", "CENTER", "REVERSE"};
struct State {
bool reverseFill = false;
bool rotatesTexture = false;
int fillStyle = kStandard;
// The texture's crop flag and points are ours until Restore.
bool owned = false;
bool laidOut = false;
float width = 0.0f;
float height = 0.0f;
bool Active() const { return reverseFill || rotatesTexture || fillStyle != kStandard; }
};
// Bars with a mode on, or laid out by us and not yet restored. Dropped when the
// bar is destroyed.
std::unordered_map<const void *, State> g_state;
using Update_t = void(__fastcall *)(void *bar, void *edx, float elapsed);
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relative, int relativePoint, float x,
float y, int doResize);
using SetAllPoints_t = void(__thiscall *)(void *anchor, void *relative, int doResize);
using SetTexCoordRect_t = void(__thiscall *)(void *texture, const float *rect);
using SetTexCoordCorners_t = void(__thiscall *)(void *texture, const float *corners);
Update_t g_origUpdate = nullptr;
uint32_t &Flags(void *bar) { return Game::Ref<uint32_t>(bar, Offsets::OFF_VALUE_FLAGS); }
void *BarTexture(void *bar) { return Game::Read<void *>(bar, Offsets::OFF_STATUSBAR_BAR_TEXTURE); }
bool IsVertical(void *bar) { return Game::Read<int>(bar, Offsets::OFF_STATUSBAR_ORIENTATION) != 0; }
// The bar's size in its own units, as CSimpleSlider::OnFrameUpdate measures
// its track: the resolved rect's extent over the effective scale.
void BarSize(void *bar, float &width, float &height) {
const float scale = Game::Read<float>(bar, Offsets::OFF_REGION_EFFECTIVE_SCALE);
const float *rect = Game::Ptr<float>(bar, Offsets::OFF_REGION_RECT); // bottom, left, top, right
width = (rect[3] - rect[1]) / scale;
height = (rect[2] - rect[0]) / scale;
}
// 4.3.4's GetAnimValue, with StandardNoRangeFill's full bar for an empty range.
float FillFraction(void *bar, int fillStyle) {
const float min = Game::Read<float>(bar, Offsets::OFF_VALUE_MIN);
const float max = Game::Read<float>(bar, Offsets::OFF_STATUSBAR_MAX);
const float range = max - min;
if (range > 0.0f)
return (Game::Read<float>(bar, Offsets::OFF_VALUE_VALUE) - min) / range;
if (fillStyle == kStandardNoRangeFill && (min != 0.0f || max != 0.0f))
return 1.0f;
return 0.0f;
}
void SetPoint(void *texture, int point, void *bar, float x, float y) {
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
Game::Ptr<uint8_t>(texture, Offsets::OFF_REGION_ANCHOR), point,
Game::Ptr<uint8_t>(bar, Offsets::OFF_REGION_ANCHOR), point, x, y, 1);
}
// The image's full coordinates, as 4.3.4's SetRotatesTexture sets them.
void SetFullTexCoord(void *texture, bool rotates) {
if (rotates) {
const float corners[8] = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};
reinterpret_cast<SetTexCoordCorners_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD_CORNERS)(texture,
corners);
} else {
const float rect[4] = {0.0f, 0.0f, 1.0f, 1.0f}; // top, left, bottom, right
reinterpret_cast<SetTexCoordRect_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD)(texture, rect);
}
}
// 4.3.4's OnLayerUpdate body. [s0, s1] is the filled part of the bar along the
// fill axis, from its start edge; [t0, t1] the part of the image drawn there.
void LayOut(void *bar, State &state) {
void *texture = BarTexture(bar);
float width, height;
BarSize(bar, width, height);
const float v = FillFraction(bar, state.fillStyle);
float s0 = 0.0f, s1 = v, t0 = 0.0f, t1 = v;
if (state.fillStyle == kCenter) {
s0 = t0 = (1.0f - v) * 0.5f;
s1 = t1 = (1.0f + v) * 0.5f;
} else if (state.reverseFill || state.fillStyle == kReverse) {
s0 = 1.0f - v;
s1 = 1.0f;
}
Game::Ref<int>(texture, Offsets::OFF_REGION_TEXCOORD_MODIFIES_RECT) = 0; // a new texture is installed with it
state.owned = true;
float left = 0.0f, right = 0.0f, top = 0.0f, bottom = 0.0f;
if (IsVertical(bar)) {
if (state.rotatesTexture) {
const float corners[8] = {t1, 0.0f, t0, 0.0f, t1, 1.0f, t0, 1.0f}; // UL, LL, UR, LR
reinterpret_cast<SetTexCoordCorners_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD_CORNERS)(texture,
corners);
} else {
const float rect[4] = {1.0f - t1, 0.0f, 1.0f - t0, 1.0f};
reinterpret_cast<SetTexCoordRect_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD)(texture, rect);
}
bottom = s0 * height;
top = -((1.0f - s1) * height);
} else {
if (state.rotatesTexture) {
const float corners[8] = {0.0f, 1.0f - t0, 1.0f, 1.0f - t0, 0.0f, 1.0f - t1, 1.0f, 1.0f - t1};
reinterpret_cast<SetTexCoordCorners_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD_CORNERS)(texture,
corners);
} else {
const float rect[4] = {0.0f, t0, 1.0f, t1};
reinterpret_cast<SetTexCoordRect_t>(Offsets::FUN_SIMPLETEXTURE_SET_TEXCOORD)(texture, rect);
}
left = s0 * width;
right = -((1.0f - s1) * width);
}
SetPoint(texture, Offsets::FRAMEPOINT_TOPLEFT, bar, left, top);
SetPoint(texture, Offsets::FRAMEPOINT_TOPRIGHT, bar, right, top);
SetPoint(texture, Offsets::FRAMEPOINT_BOTTOMLEFT, bar, left, bottom);
SetPoint(texture, Offsets::FRAMEPOINT_BOTTOMRIGHT, bar, right, bottom);
state.laidOut = true;
state.width = width;
state.height = height;
}
// Hands the texture back to 1.12's crop: pinned to the bar, crop flag on, and
// the fill marked for 1.12's next update.
void Restore(void *bar) {
if (void *texture = BarTexture(bar)) {
reinterpret_cast<SetAllPoints_t>(Offsets::FUN_LAYOUT_SET_ALL_POINTS)(
Game::Ptr<uint8_t>(texture, Offsets::OFF_REGION_ANCHOR),
Game::Ptr<uint8_t>(bar, Offsets::OFF_REGION_ANCHOR), 1);
Game::Ref<int>(texture, Offsets::OFF_REGION_TEXCOORD_MODIFIES_RECT) = 1;
}
Flags(bar) |= Offsets::VALUE_FLAG_CHANGED;
}
void __fastcall Update_h(void *bar, void *edx, float elapsed) {
const auto it = g_state.find(bar);
if (it == g_state.end()) {
g_origUpdate(bar, edx, elapsed);
return;
}
State &state = it->second;
reinterpret_cast<Update_t>(Offsets::FUN_FRAME_ON_UPDATE)(bar, edx, elapsed);
constexpr uint32_t kReady = Offsets::VALUE_FLAG_RANGE_SET | Offsets::VALUE_FLAG_VALUE_SET;
const uint32_t flags = Flags(bar);
if ((flags & kReady) != kReady || BarTexture(bar) == nullptr)
return;
bool changed = (flags & Offsets::VALUE_FLAG_CHANGED) != 0;
if (!changed && state.laidOut) { // a resize moves the offsets' lengths
float width, height;
BarSize(bar, width, height);
changed = width != state.width || height != state.height;
}
if (!changed)
return;
LayOut(bar, state);
Flags(bar) &= ~Offsets::VALUE_FLAG_CHANGED;
}
const Game::HookAutoRegister _updateHook{Offsets::FUN_STATUSBAR_ON_FRAME_UPDATE,
reinterpret_cast<void *>(&Update_h),
reinterpret_cast<void **>(&g_origUpdate)};
void OnFrameDestroyed(void *frame) { g_state.erase(frame); }
const Frame::Destruction::AutoSubscribe _destructionSub{&OnFrameDestroyed};
// Applies a mode change. A bar with a mode on takes its texture off the crop
// at once - a turned image's coordinates would crop it to nothing - and is laid
// out on its next update; one with none goes back to 1.12's fill.
template <typename Change> void Modify(void *bar, Change change) {
State &state = g_state[bar];
change(state);
Flags(bar) |= Offsets::VALUE_FLAG_CHANGED;
if (state.Active()) {
if (void *texture = BarTexture(bar)) {
Game::Ref<int>(texture, Offsets::OFF_REGION_TEXCOORD_MODIFIES_RECT) = 0;
state.owned = true;
}
return;
}
if (state.owned || state.laidOut)
Restore(bar);
g_state.erase(bar);
}
const State *Find(void *bar) {
const auto it = g_state.find(bar);
return it != g_state.end() ? &it->second : nullptr;
}
void *ResolveBar(void *L) { return Game::Lua::ResolveTypedObject(L, 1, Offsets::VAR_STATUSBAR_LUA_TYPE_ID); }
using LooseBool_t = int(__fastcall *)(void *L, int idx, int defaultValue);
bool ArgBool(void *L, int idx) {
return reinterpret_cast<LooseBool_t>(Offsets::FUN_LUA_TO_BOOLEAN_LOOSE)(L, idx, 0) != 0;
}
int __fastcall Script_SetReverseFill(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
const bool reverse = ArgBool(L, 2);
Modify(bar, [reverse](State &s) { s.reverseFill = reverse; });
return 0;
}
int __fastcall Script_GetReverseFill(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
const State *state = Find(bar);
Game::Lua::PushBool(L, state != nullptr && state->reverseFill);
return 1;
}
int __fastcall Script_SetRotatesTexture(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
const bool rotates = ArgBool(L, 2);
Modify(bar, [rotates](State &s) { s.rotatesTexture = rotates; });
// 4.3.4 sets the full coordinates at once, so a bar with no value yet
// shows its image turned, or not, before the first layout. Full
// coordinates crop nothing, so a texture back on the crop takes them too.
if (void *texture = BarTexture(bar))
SetFullTexCoord(texture, rotates);
return 0;
}
int __fastcall Script_GetRotatesTexture(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
const State *state = Find(bar);
Game::Lua::PushBool(L, state != nullptr && state->rotatesTexture);
return 1;
}
int __fastcall Script_SetFillStyle(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
int style = -1;
if (Game::Lua::Type(L, 2) == Game::Lua::TYPE_NUMBER) {
const double n = Game::Lua::ToNumber(L, 2);
if (n >= kStandard && n <= kReverse && n == static_cast<int>(n))
style = static_cast<int>(n);
} else if (Game::Lua::Type(L, 2) == Game::Lua::TYPE_STRING) {
const char *name = Game::Lua::ToString(L, 2);
for (int i = 0; i < static_cast<int>(sizeof(kFillStyleTokens) / sizeof(kFillStyleTokens[0])); ++i)
if (Ascii::EqualCI(name, kFillStyleTokens[i]))
style = i;
}
if (style < 0) {
Game::Lua::Error(L, "Usage: %s:SetFillStyle(fillStyle)", Game::Lua::ObjectDisplayName(bar));
return 0;
}
Modify(bar, [style](State &s) { s.fillStyle = style; });
return 0;
}
int __fastcall Script_GetFillStyle(void *L) {
void *bar = ResolveBar(L);
if (bar == nullptr)
return 0;
const State *state = Find(bar);
Game::Lua::PushNumber(L, state != nullptr ? state->fillStyle : kStandard);
return 1;
}
const Game::Lua::FrameMethodEntry g_methods[] = {
{"SetReverseFill", &Script_SetReverseFill}, {"GetReverseFill", &Script_GetReverseFill},
{"SetRotatesTexture", &Script_SetRotatesTexture}, {"GetRotatesTexture", &Script_GetRotatesTexture},
{"SetFillStyle", &Script_SetFillStyle}, {"GetFillStyle", &Script_GetFillStyle},
};
const Game::Doc::Field kSetReverseFillArgs[] = {Game::Doc::Req("isReverseFill", "bool")};
const Game::Doc::Field kGetReverseFillRets[] = {Game::Doc::Req("isReverseFill", "bool")};
const Game::Doc::Field kSetRotatesTextureArgs[] = {Game::Doc::Req("rotatesTexture", "bool")};
const Game::Doc::Field kGetRotatesTextureRets[] = {Game::Doc::Req("rotatesTexture", "bool")};
const Game::Doc::Field kSetFillStyleArgs[] = {Game::Doc::Req("fillStyle", "StatusBarFillStyle")};
const Game::Doc::Field kGetFillStyleRets[] = {Game::Doc::Req("fillStyle", "StatusBarFillStyle")};
const Game::Doc::Function kSetReverseFill{"Sets whether the bar fills from the right, or from the top when vertical.",
kSetReverseFillArgs, {}};
const Game::Doc::Function kGetReverseFill{"Returns whether the bar fills from the right, or from the top when vertical.",
{}, kGetReverseFillRets};
const Game::Doc::Function kSetRotatesTexture{"Sets whether the bar texture is drawn turned a quarter.",
kSetRotatesTextureArgs, {}};
const Game::Doc::Function kGetRotatesTexture{"Returns whether the bar texture is drawn turned a quarter.", {},
kGetRotatesTextureRets};
const Game::Doc::Function kSetFillStyle{"Sets how the bar fills as its value grows.", kSetFillStyleArgs, {}};
const Game::Doc::Function kGetFillStyle{"Returns how the bar fills as its value grows.", {}, kGetFillStyleRets};
const Game::Doc::Method g_methodDocs[] = {
{"SetReverseFill", &kSetReverseFill}, {"GetReverseFill", &kGetReverseFill},
{"SetRotatesTexture", &kSetRotatesTexture}, {"GetRotatesTexture", &kGetRotatesTexture},
{"SetFillStyle", &kSetFillStyle}, {"GetFillStyle", &kGetFillStyle},
};
void RegisterLuaFunctions() {
Game::Lua::RegisterFrameMethods(
reinterpret_cast<void *>(Offsets::VAR_STATUSBAR_METHOD_REGISTRY), g_methods,
static_cast<int>(sizeof(g_methods) / sizeof(g_methods[0])), g_methodDocs,
static_cast<int>(sizeof(g_methodDocs) / sizeof(g_methodDocs[0])));
Game::Lua::RegisterIntegerEnum("Enum", "StatusBarFillStyle", kFillStyleEntries,
static_cast<int>(sizeof(kFillStyleEntries) / sizeof(kFillStyleEntries[0])),
"SimpleStatusBarConstants");
}
const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
} // namespace
} // namespace StatusBar::Fill
+26 -15
View File
@@ -43,6 +43,8 @@
// the first call inside FUN_LOAD_SCRIPT_FUNCTIONS and ModuleAutoRegister runs
// after the original, so ours wins on every /reload. No hook is involved.
#include "texture/Desaturation.h"
#include "Game.h"
#include "Offsets.h"
#include "debug/Log.h"
@@ -308,6 +310,28 @@ int LevelOf(void *region) {
return kFull;
}
} // namespace
void SetAmount(void *region, double amount) {
if (amount != amount) // NaN
amount = 0.0;
if (amount < 0.0)
amount = 0.0;
else if (amount > 1.0)
amount = 1.0;
const int level = static_cast<int>(amount * kFull + 0.5);
if (!g_enabled || !Available()) {
ApplyStock(region, level > 0);
return;
}
Apply(region, level);
}
double GetAmount(void *region) { return static_cast<double>(LevelOf(region)) / kFull; }
namespace {
void *ResolveSelf(void *L) {
if (Game::Lua::Type(L, 1) != Game::Lua::TYPE_TABLE)
return nullptr;
@@ -323,20 +347,7 @@ int __fastcall Script_SetDesaturation(void *L) {
Game::Lua::Error(L, "Usage: texture:SetDesaturation(amount)");
return 0;
}
double amount = Game::Lua::ToNumber(L, 2);
if (amount != amount) // NaN
amount = 0.0;
if (amount < 0.0)
amount = 0.0;
else if (amount > 1.0)
amount = 1.0;
const int level = static_cast<int>(amount * kFull + 0.5);
if (!g_enabled || !Available()) {
ApplyStock(region, level > 0);
return 0;
}
Apply(region, level);
SetAmount(region, Game::Lua::ToNumber(L, 2));
return 0;
}
@@ -347,7 +358,7 @@ int __fastcall Script_GetDesaturation(void *L) {
Game::Lua::Error(L, "Usage: texture:GetDesaturation()");
return 0;
}
Game::Lua::PushNumber(L, static_cast<double>(LevelOf(region)) / kFull);
Game::Lua::PushNumber(L, GetAmount(region));
return 1;
}
+27
View File
@@ -0,0 +1,27 @@
// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#pragma once
// A texture's desaturation, the state behind texture:SetDesaturation /
// GetDesaturation, for other classes that desaturate a texture they own (the
// StatusBar's bar texture).
namespace Texture::Desaturation {
// `amount` 0..1, clamped (NaN is 0); quantised to 1/255.
void SetAmount(void *region, double amount);
// The amount the region draws with: 0, or level / 255.
double GetAmount(void *region);
} // namespace Texture::Desaturation