2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD 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, version 2.
|
|
|
|
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file signs.cpp Handling of signs. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2005-01-12 11:21:28 +00:00
|
|
|
#include "stdafx.h"
|
2007-04-12 13:07:15 +00:00
|
|
|
#include "landscape.h"
|
2008-03-31 07:25:49 +00:00
|
|
|
#include "signs_base.h"
|
|
|
|
#include "signs_func.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2009-05-22 15:13:50 +00:00
|
|
|
#include "core/pool_func.hpp"
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2011-05-01 19:51:52 +00:00
|
|
|
/** Initialize the sign-pool */
|
2009-05-22 15:13:50 +00:00
|
|
|
SignPool _sign_pool("Sign");
|
|
|
|
INSTANTIATE_POOL_METHODS(Sign)
|
2007-08-02 13:27:45 +00:00
|
|
|
|
2011-01-18 23:09:43 +00:00
|
|
|
/**
|
|
|
|
* Creates a new sign
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
Sign::Sign(Owner owner)
|
2005-02-04 14:45:32 +00:00
|
|
|
{
|
2008-01-12 19:58:06 +00:00
|
|
|
this->owner = owner;
|
2007-08-02 13:27:45 +00:00
|
|
|
}
|
2005-02-04 14:45:32 +00:00
|
|
|
|
2011-01-18 23:09:43 +00:00
|
|
|
/** Destroy the sign */
|
2007-08-02 13:27:45 +00:00
|
|
|
Sign::~Sign()
|
|
|
|
{
|
2008-01-12 19:58:06 +00:00
|
|
|
free(this->name);
|
2008-09-16 19:05:38 +00:00
|
|
|
|
|
|
|
if (CleaningPool()) return;
|
|
|
|
|
|
|
|
DeleteRenameSignWindow(this->index);
|
2007-08-02 13:27:45 +00:00
|
|
|
}
|
2005-02-04 14:45:32 +00:00
|
|
|
|
2005-01-12 11:21:28 +00:00
|
|
|
/**
|
|
|
|
* Update the coordinate of one sign
|
|
|
|
*/
|
2009-07-13 22:33:25 +00:00
|
|
|
void Sign::UpdateVirtCoord()
|
2005-01-12 11:21:28 +00:00
|
|
|
{
|
2009-07-13 22:33:25 +00:00
|
|
|
Point pt = RemapCoords(this->x, this->y, this->z);
|
|
|
|
SetDParam(0, this->index);
|
2011-11-24 17:37:20 +00:00
|
|
|
this->sign.UpdatePosition(pt.x, pt.y - 6 * ZOOM_LVL_BASE, STR_WHITE_SIGN);
|
2005-01-12 11:21:28 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
/** Update the coordinates of all signs */
|
2007-03-07 11:47:46 +00:00
|
|
|
void UpdateAllSignVirtCoords()
|
2005-01-12 11:21:28 +00:00
|
|
|
{
|
2006-08-22 16:38:50 +00:00
|
|
|
Sign *si;
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2009-07-13 22:33:25 +00:00
|
|
|
FOR_ALL_SIGNS(si) {
|
|
|
|
si->UpdateVirtCoord();
|
|
|
|
}
|
2005-01-12 11:21:28 +00:00
|
|
|
}
|