Road stops: Add height property for build window preview
This commit is contained in:
		@@ -5175,6 +5175,13 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const
 | 
			
		||||
				rs->clear_cost_multiplier = buf->ReadByte();
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case A0RPI_ROADSTOP_HEIGHT:
 | 
			
		||||
				if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
 | 
			
		||||
				FALLTHROUGH;
 | 
			
		||||
			case 0x16: // Height
 | 
			
		||||
				rs->height = buf->ReadByte();
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
				ret = HandleAction0PropertyDefault(buf, prop);
 | 
			
		||||
				break;
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
 | 
			
		||||
	GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
 | 
			
		||||
	GRFFeatureInfo("action0_object_flood_resistant", 1),
 | 
			
		||||
	GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
 | 
			
		||||
	GRFFeatureInfo("road_stops", 5),
 | 
			
		||||
	GRFFeatureInfo("road_stops", 6),
 | 
			
		||||
	GRFFeatureInfo("new_landscape", 2),
 | 
			
		||||
	GRFFeatureInfo(),
 | 
			
		||||
};
 | 
			
		||||
@@ -124,6 +124,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT, "roadstop_min_bridge_height"),
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS, "roadstop_disallowed_bridge_pillars"),
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_COST_MULTIPLIERS, "roadstop_cost_multipliers"),
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_HEIGHT, "roadstop_height"),
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_NEWLANDSCAPE, A0RPI_NEWLANDSCAPE_ENABLE_RECOLOUR, "newlandscape_enable_recolour"),
 | 
			
		||||
	GRFPropertyMapDefinition(GSF_NEWLANDSCAPE, A0RPI_NEWLANDSCAPE_ENABLE_DRAW_SNOWY_ROCKS, "newlandscape_enable_draw_snowy_rocks"),
 | 
			
		||||
	GRFPropertyMapDefinition(),
 | 
			
		||||
 
 | 
			
		||||
@@ -67,6 +67,7 @@ enum Action0RemapPropertyIds {
 | 
			
		||||
	A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT,
 | 
			
		||||
	A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS,
 | 
			
		||||
	A0RPI_ROADSTOP_COST_MULTIPLIERS,
 | 
			
		||||
	A0RPI_ROADSTOP_HEIGHT,
 | 
			
		||||
	A0RPI_NEWLANDSCAPE_ENABLE_RECOLOUR,
 | 
			
		||||
	A0RPI_NEWLANDSCAPE_ENABLE_DRAW_SNOWY_ROCKS,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -154,6 +154,8 @@ struct RoadStopSpec {
 | 
			
		||||
	uint8 build_cost_multiplier = 16;  ///< Build cost multiplier per tile.
 | 
			
		||||
	uint8 clear_cost_multiplier = 16;  ///< Clear cost multiplier per tile.
 | 
			
		||||
 | 
			
		||||
	uint8 height;                      ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the cost for building a road stop of this type.
 | 
			
		||||
	 * @return The cost for building.
 | 
			
		||||
 
 | 
			
		||||
@@ -1222,6 +1222,7 @@ private:
 | 
			
		||||
	uint coverage_height; ///< Height of the coverage texts.
 | 
			
		||||
	Scrollbar *vscrollList; ///< Vertical scrollbar of the new station list.
 | 
			
		||||
	Scrollbar *vscrollMatrix; ///< Vertical scrollbar of the station picker matrix.
 | 
			
		||||
	uint building_height = 2; ///< Road stop building height for image size
 | 
			
		||||
 | 
			
		||||
	typedef GUIList<RoadStopClassID, StringFilter &> GUIRoadStopClassList; ///< Type definition for the list to hold available road stop classes.
 | 
			
		||||
 | 
			
		||||
@@ -1246,17 +1247,18 @@ private:
 | 
			
		||||
		this->vscrollList->ScrollTowards(pos);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void CheckOrientationValid()
 | 
			
		||||
	void CheckSelectedSpec()
 | 
			
		||||
	{
 | 
			
		||||
		if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
 | 
			
		||||
		const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
 | 
			
		||||
		if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
 | 
			
		||||
		if (spec == nullptr) return;
 | 
			
		||||
		if (_roadstop_gui_settings.orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
 | 
			
		||||
			this->RaiseWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 | 
			
		||||
			_roadstop_gui_settings.orientation = DIAGDIR_END;
 | 
			
		||||
			this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 | 
			
		||||
			this->SetDirty();
 | 
			
		||||
			DeleteWindowById(WC_SELECT_STATION, 0);
 | 
			
		||||
		}
 | 
			
		||||
		this->UpdateBuildingHeight(spec->height);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -1337,7 +1339,7 @@ public:
 | 
			
		||||
			matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
 | 
			
		||||
 | 
			
		||||
			this->EnsureSelectedClassIsVisible();
 | 
			
		||||
			this->CheckOrientationValid();
 | 
			
		||||
			this->CheckSelectedSpec();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -1471,6 +1473,14 @@ public:
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void UpdateBuildingHeight(uint height)
 | 
			
		||||
	{
 | 
			
		||||
		if (height > this->building_height) {
 | 
			
		||||
			this->building_height = height;
 | 
			
		||||
			this->ReInit();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 | 
			
		||||
	{
 | 
			
		||||
		switch (widget) {
 | 
			
		||||
@@ -1507,6 +1517,10 @@ public:
 | 
			
		||||
			case WID_BROS_STATION_NW:
 | 
			
		||||
			case WID_BROS_STATION_X:
 | 
			
		||||
			case WID_BROS_STATION_Y:
 | 
			
		||||
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 | 
			
		||||
				size->height = ScaleGUITrad(32 + (this->building_height * 8)) + WidgetDimensions::scaled.fullbevel.Vertical();
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case WID_BROS_IMAGE:
 | 
			
		||||
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 | 
			
		||||
				size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 | 
			
		||||
@@ -1554,6 +1568,7 @@ public:
 | 
			
		||||
					_cur_dpi = &tmp_dpi;
 | 
			
		||||
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 | 
			
		||||
					int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 | 
			
		||||
					if (spec != nullptr && spec->height > 2) y += (spec->height - 2) * ScaleSpriteTrad(4);
 | 
			
		||||
					if (spec == nullptr || disabled) {
 | 
			
		||||
						StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
 | 
			
		||||
						if (disabled) GfxFillRect(1, 1, r.Width() - 1, r.Height() - 1, PC_BLACK, FILLRECT_CHECKER);
 | 
			
		||||
@@ -1668,7 +1683,7 @@ public:
 | 
			
		||||
					NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
 | 
			
		||||
					matrix->SetCount(_roadstop_gui_settings.roadstop_count);
 | 
			
		||||
					matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
 | 
			
		||||
					this->CheckOrientationValid();
 | 
			
		||||
					this->CheckSelectedSpec();
 | 
			
		||||
				}
 | 
			
		||||
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 | 
			
		||||
				this->SetDirty();
 | 
			
		||||
@@ -1693,7 +1708,7 @@ public:
 | 
			
		||||
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 | 
			
		||||
				this->SetDirty();
 | 
			
		||||
				DeleteWindowById(WC_SELECT_STATION, 0);
 | 
			
		||||
				this->CheckOrientationValid();
 | 
			
		||||
				this->CheckSelectedSpec();
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1878,7 +1878,7 @@ class NIHRoadStop : public NIHelper {
 | 
			
		||||
			output.print(buffer);
 | 
			
		||||
			seprintf(buffer, lastof(buffer), "  spec: callback mask: %X, flags: %X, intl flags: %X", spec->callback_mask, spec->flags, spec->internal_flags);
 | 
			
		||||
			output.print(buffer);
 | 
			
		||||
			seprintf(buffer, lastof(buffer), "  spec: build: %u, clear: %u", spec->build_cost_multiplier, spec->clear_cost_multiplier);
 | 
			
		||||
			seprintf(buffer, lastof(buffer), "  spec: build: %u, clear: %u, height: %u", spec->build_cost_multiplier, spec->clear_cost_multiplier, spec->height);
 | 
			
		||||
			output.print(buffer);
 | 
			
		||||
			seprintf(buffer, lastof(buffer), "  animation: frames: %u, status: %u, speed: %u, triggers: 0x%X", spec->animation.frames, spec->animation.status, spec->animation.speed, spec->animation.triggers);
 | 
			
		||||
			output.print(buffer);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user