-
Notifications
You must be signed in to change notification settings - Fork 148
/
DockObject.cpp
60 lines (52 loc) · 1.61 KB
/
DockObject.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "DockObject.h"
#include "Drawing/SoftwareDrawingEngine.h"
#include "Graphics/Colour.h"
#include "Graphics/Gfx.h"
#include "Interop/Interop.hpp"
#include "ObjectManager.h"
namespace OpenLoco
{
// 0x00490F14
void DockObject::drawPreviewImage(Gfx::RenderTarget& rt, const int16_t x, const int16_t y) const
{
auto colourImage = Gfx::recolour(image, Colour::mutedDarkRed);
auto drawingCtx = Gfx::getDrawingEngine().getDrawingContext();
drawingCtx.drawImage(&rt, x - 34, y - 34, colourImage);
}
// 0x00490F2C
void DockObject::drawDescription(Gfx::RenderTarget& rt, const int16_t x, const int16_t y, [[maybe_unused]] const int16_t width) const
{
Ui::Point rowPosition = { x, y };
ObjectManager::drawGenericDescription(rt, rowPosition, designedYear, obsoleteYear);
}
// 0x00490EED
bool DockObject::validate() const
{
if (costIndex > 32)
{
return false;
}
if (-sellCostFactor > buildCostFactor)
{
return false;
}
return buildCostFactor > 0;
}
// 0x00490E49
void DockObject::load(const LoadedObjectHandle& handle, stdx::span<const std::byte> data, ObjectManager::DependentObjects*)
{
Interop::registers regs;
regs.esi = Interop::X86Pointer(this);
regs.ebx = handle.id;
regs.ecx = enumValue(handle.type);
Interop::call(0x00490E49, regs);
}
// 0x00490EC9
void DockObject::unload()
{
name = 0;
image = 0;
var_0C = 0;
std::fill(std::begin(var_1C), std::end(var_1C), 0);
}
}