File diff r23537:f6a6d4ce4bd5 → r23538:8df50944b27a
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -26,49 +26,49 @@
 
#include "object_base.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "vehicle_base.h"
 
#include "train.h"
 
#include "roadveh.h"
 

	
 
#include "newgrf_airporttiles.h"
 
#include "newgrf_debug.h"
 
#include "newgrf_object.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_station.h"
 
#include "newgrf_town.h"
 
#include "newgrf_railtype.h"
 
#include "newgrf_industries.h"
 
#include "newgrf_industrytiles.h"
 

	
 
#include "widgets/newgrf_debug_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The sprite picker. */
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() };
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, std::vector<SpriteID>() };
 

	
 
/**
 
 * Get the feature index related to the window number.
 
 * @param window_number The window to get the feature index from.
 
 * @return the feature index
 
 */
 
static inline uint GetFeatureIndex(uint window_number)
 
{
 
	return GB(window_number, 0, 24);
 
}
 

	
 
/**
 
 * Get the window number for the inspect window given a
 
 * feature and index.
 
 * @param feature The feature we want to inspect.
 
 * @param index   The index/identifier of the feature to inspect.
 
 * @return the InspectWindow (Window)Number
 
 */
 
static inline uint GetInspectWindowNumber(GrfSpecFeature feature, uint index)
 
{
 
	assert((index >> 24) == 0);
 
	return (feature << 24) | index;
 
}
 

	
 
@@ -873,49 +873,49 @@ struct SpriteAlignerWindow : Window {
 
			case WID_SA_SPRITE: {
 
				/* Center the sprite ourselves */
 
				const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
 
				int width  = r.right  - r.left + 1 - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
 
				int height = r.bottom - r.top  + 1 - WD_BEVEL_TOP - WD_BEVEL_BOTTOM;
 
				int x = -UnScaleGUI(spr->x_offs) + (width  - UnScaleGUI(spr->width) ) / 2;
 
				int y = -UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;
 

	
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, r.left + WD_BEVEL_LEFT, r.top + WD_BEVEL_TOP, width, height)) break;
 
				DrawPixelInfo *old_dpi = _cur_dpi;
 
				_cur_dpi = &new_dpi;
 

	
 
				DrawSprite(this->current_sprite, PAL_NONE, x, y, NULL, ZOOM_LVL_GUI);
 

	
 
				_cur_dpi = old_dpi;
 

	
 
				break;
 
			}
 

	
 
			case WID_SA_LIST: {
 
				const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
				int step_size = nwid->resize_y;
 

	
 
				SmallVector<SpriteID, 256> &list = _newgrf_debug_sprite_picker.sprites;
 
				std::vector<SpriteID> &list = _newgrf_debug_sprite_picker.sprites;
 
				int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size());
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (int i = this->vscroll->GetPosition(); i < max; i++) {
 
					SetDParam(0, list[i]);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
					y += step_size;
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SA_PREVIOUS:
 
				do {
 
					this->current_sprite = (this->current_sprite == 0 ? GetMaxSpriteID() :  this->current_sprite) - 1;
 
				} while (GetSpriteType(this->current_sprite) != ST_NORMAL);
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_SA_GOTO: