Files
OpenRCT2-Web/src/object/FootpathObject.cpp
T

77 lines
2.6 KiB
C++
Raw Normal View History

2016-06-25 17:09:56 +01:00
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 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.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "../core/IStream.hpp"
#include "FootpathObject.h"
extern "C"
{
#include "../drawing/drawing.h"
#include "../localisation/localisation.h"
#include "../world/footpath.h"
}
enum OBJ_STRING_ID
{
OBJ_STRING_ID_NAME,
};
2016-07-01 21:01:06 +01:00
void FootpathObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
2016-06-25 17:09:56 +01:00
{
_legacyType.string_idx = stream->ReadValue<rct_string_id>();
2016-07-01 20:01:31 +01:00
_legacyType.image = stream->ReadValue<uint32>();
2016-06-25 17:09:56 +01:00
_legacyType.bridge_image = stream->ReadValue<uint32>();
_legacyType.var_0A = stream->ReadValue<uint8>();
_legacyType.flags = stream->ReadValue<uint8>();
_legacyType.scrolling_mode = stream->ReadValue<uint8>();
2016-07-01 20:01:31 +01:00
stream->Seek(1, STREAM_SEEK_CURRENT);
2016-06-25 17:09:56 +01:00
2016-07-01 21:01:06 +01:00
GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME);
GetImageTable()->Read(context, stream);
2016-07-02 17:23:06 +01:00
// Validate properties
if (_legacyType.var_0A > 1)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "VAR_0A can not be greater than 1.");
}
2016-06-25 17:09:56 +01:00
}
void FootpathObject::Load()
{
_legacyType.string_idx = language_allocate_object_string(GetName());
2016-06-26 21:43:30 +01:00
_legacyType.image = gfx_object_allocate_images(GetImageTable()->GetImages(), GetImageTable()->GetCount());
2016-06-25 17:09:56 +01:00
_legacyType.bridge_image = _legacyType.image + 109;
}
void FootpathObject::Unload()
{
language_free_object_string(_legacyType.string_idx);
2016-06-26 21:43:30 +01:00
gfx_object_free_images(_legacyType.image, GetImageTable()->GetCount());
2016-06-25 17:09:56 +01:00
}
2016-07-02 12:29:13 +01:00
void FootpathObject::DrawPreview(rct_drawpixelinfo * dpi) const
{
int x = dpi->width / 2;
int y = dpi->height / 2;
gfx_draw_sprite(dpi, _legacyType.image + 71, x - 49, y - 17, 0);
gfx_draw_sprite(dpi, _legacyType.image + 72, x + 4, y - 17, 0);
}
2016-06-30 21:55:18 +01:00
const utf8 * FootpathObject::GetName() const
2016-06-25 17:09:56 +01:00
{
2016-06-26 21:43:30 +01:00
const utf8 * name = GetStringTable()->GetString(OBJ_STRING_ID_NAME);
return name != nullptr ? name : "";
2016-06-25 17:09:56 +01:00
}