Changeset - r12331:4957eff8b184
[Not reviewed]
master
0 7 0
rubidium - 15 years ago 2009-07-07 16:51:20
rubidium@openttd.org
(svn r16761) -Codechange: make UpdateViewportSignPos(ition) a class function of ViewportSign
7 files changed with 20 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/signs.cpp
Show inline comments
 
@@ -42,7 +42,7 @@ void UpdateSignVirtCoords(Sign *si)
 
{
 
	Point pt = RemapCoords(si->x, si->y, si->z);
 
	SetDParam(0, si->index);
 
	UpdateViewportSignPos(&si->sign, pt.x, pt.y - 6, STR_SIGN_WHITE);
 
	si->sign.UpdatePosition(pt.x, pt.y - 6, STR_SIGN_WHITE);
 
}
 

	
 
/** Update the coordinates of all signs */
src/station_cmd.cpp
Show inline comments
 
@@ -380,7 +380,7 @@ void Station::UpdateVirtCoord()
 

	
 
	SetDParam(0, this->index);
 
	SetDParam(1, this->facilities);
 
	UpdateViewportSignPos(&this->sign, pt.x, pt.y, STR_STATION_SIGN);
 
	this->sign.UpdatePosition(pt.x, pt.y, STR_STATION_SIGN);
 
}
 

	
 
/** Update the virtual coords needed to draw the station sign for all stations. */
src/town_cmd.cpp
Show inline comments
 
@@ -350,7 +350,7 @@ void UpdateTownVirtCoord(Town *t)
 
	Point pt = RemapCoords2(TileX(t->xy) * TILE_SIZE, TileY(t->xy) * TILE_SIZE);
 
	SetDParam(0, t->index);
 
	SetDParam(1, t->population);
 
	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24,
 
	t->sign.UpdatePosition(pt.x, pt.y - 24,
 
		_settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL);
 
	MarkTownSignDirty(t);
 
}
src/viewport.cpp
Show inline comments
 
@@ -1279,23 +1279,26 @@ static void ViewportAddWaypoints(DrawPix
 
	}
 
}
 

	
 
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str)
 
/**
 
 * Update the position of the viewport sign.
 
 * @param center the (preferred) center of the viewport sign
 
 * @param top    the new top of the sign
 
 * @param str    the string to show in the sign
 
 */
 
void ViewportSign::UpdatePosition(int center, int top, StringID str)
 
{
 
	char buffer[256];
 
	uint w;
 

	
 
	sign->top = top;
 
	this->top = top;
 

	
 
	char buffer[DRAW_STRING_BUFFER];
 

	
 
	GetString(buffer, str, lastof(buffer));
 
	w = GetStringBoundingBox(buffer).width + 3;
 
	sign->width_1 = w;
 
	sign->left = left - w / 2;
 
	this->width_1 = GetStringBoundingBox(buffer).width + 3;
 
	this->left = center - this->width_1 / 2;
 

	
 
	/* zoomed out version */
 
	_cur_fontsize = FS_SMALL;
 
	w = GetStringBoundingBox(buffer).width + 3;
 
	this->width_2 = GetStringBoundingBox(buffer).width + 3;
 
	_cur_fontsize = FS_NORMAL;
 
	sign->width_2 = w;
 
}
 

	
 

	
src/viewport_func.h
Show inline comments
 
@@ -8,7 +8,6 @@
 
#include "gfx_type.h"
 
#include "viewport_type.h"
 
#include "vehicle_type.h"
 
#include "strings_type.h"
 
#include "window_type.h"
 
#include "tile_type.h"
 

	
 
@@ -19,7 +18,6 @@ void InitializeWindowViewport(Window *w,
 
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
 
Point GetTileBelowCursor();
 
void UpdateViewportPosition(Window *w);
 
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str);
 

	
 
bool DoZoomInOutWindow(int how, Window *w);
 
void ZoomInOrOutToCursorWindow(bool in, Window * w);
src/viewport_type.h
Show inline comments
 
@@ -6,6 +6,7 @@
 
#define VIEWPORT_TYPE_H
 

	
 
#include "zoom_type.h"
 
#include "strings_type.h"
 

	
 
/**
 
 * Data structure for viewport, display of a part of the world
 
@@ -28,6 +29,8 @@ struct ViewportSign {
 
	int32 left;
 
	int32 top;
 
	uint16 width_1, width_2;
 

	
 
	void UpdatePosition(int center, int top, StringID str);
 
};
 

	
 
enum {
src/waypoint_cmd.cpp
Show inline comments
 
@@ -32,7 +32,7 @@ void UpdateWaypointSign(Waypoint *wp)
 
{
 
	Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
 
	SetDParam(0, wp->index);
 
	UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
 
	wp->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
 
}
 

	
 
/**
0 comments (0 inline, 0 general)