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

69 lines
2.3 KiB
C++
Raw Normal View History

#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 "EntranceObject.h"
2016-06-25 16:34:35 +01:00
extern "C"
{
#include "../drawing/drawing.h"
#include "../localisation/localisation.h"
}
2016-06-25 14:44:04 +01:00
enum OBJ_STRING_ID
{
OBJ_STRING_ID_NAME,
};
2016-07-01 21:01:06 +01:00
void EntranceObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
{
_legacyType.string_idx = stream->ReadValue<rct_string_id>();
_legacyType.image_id = stream->ReadValue<uint32>();
_legacyType.scrolling_mode = stream->ReadValue<uint8>();
_legacyType.text_height = stream->ReadValue<uint8>();
2016-07-01 21:01:06 +01:00
GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME);
GetImageTable()->Read(context, stream);
}
2016-06-25 12:30:20 +01:00
void EntranceObject::Load()
{
2016-06-25 16:34:35 +01:00
_legacyType.string_idx = language_allocate_object_string(GetName());
2016-06-26 21:43:30 +01:00
_legacyType.image_id = gfx_object_allocate_images(GetImageTable()->GetImages(), GetImageTable()->GetCount());
2016-06-25 12:30:20 +01:00
}
void EntranceObject::Unload()
{
2016-06-25 16:34:35 +01:00
language_free_object_string(_legacyType.string_idx);
2016-06-26 21:43:30 +01:00
gfx_object_free_images(_legacyType.image_id, GetImageTable()->GetCount());
2016-06-25 12:30:20 +01:00
}
2016-06-25 14:44:04 +01:00
2016-07-02 12:29:13 +01:00
void EntranceObject::DrawPreview(rct_drawpixelinfo * dpi) const
{
int x = dpi->width / 2;
int y = dpi->height / 2;
uint32 imageId = _legacyType.image_id;
gfx_draw_sprite(dpi, imageId + 1, x - 32, y + 14, 0);
gfx_draw_sprite(dpi, imageId + 0, x + 0, y + 28, 0);
gfx_draw_sprite(dpi, imageId + 2, x + 32, y + 44, 0);
}
2016-06-30 21:55:18 +01:00
const utf8 * EntranceObject::GetName() const
2016-06-25 14:44:04 +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 14:44:04 +01:00
}