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 engine_gui.cpp GUI to show engine related information. */
|
2007-02-23 18:55:07 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "gfx_func.h"
|
2008-04-29 21:31:29 +00:00
|
|
|
#include "engine_base.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2008-05-27 12:24:23 +00:00
|
|
|
#include "engine_gui.h"
|
2008-06-20 07:23:00 +00:00
|
|
|
#include "articulated_vehicles.h"
|
2009-05-27 17:18:53 +00:00
|
|
|
#include "vehicle_func.h"
|
|
|
|
#include "company_func.h"
|
2008-08-24 21:31:24 +00:00
|
|
|
#include "rail.h"
|
2009-10-27 19:56:00 +00:00
|
|
|
#include "settings_type.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-08-30 17:54:11 +00:00
|
|
|
/** Return the category of an engine.
|
|
|
|
* @param engine Engine to examine.
|
|
|
|
* @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine.
|
|
|
|
*/
|
2008-05-13 10:17:04 +00:00
|
|
|
StringID GetEngineCategoryName(EngineID engine)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-10-06 19:17:07 +00:00
|
|
|
const Engine *e = Engine::Get(engine);
|
|
|
|
switch (e->type) {
|
2007-03-03 22:03:15 +00:00
|
|
|
default: NOT_REACHED();
|
2009-04-21 23:40:56 +00:00
|
|
|
case VEH_ROAD: return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
|
|
|
|
case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT;
|
|
|
|
case VEH_SHIP: return STR_ENGINE_PREVIEW_SHIP;
|
2007-03-08 16:27:54 +00:00
|
|
|
case VEH_TRAIN:
|
2009-10-06 19:17:07 +00:00
|
|
|
return GetRailTypeInfo(e->u.rail.railtype)->strings.new_loco;
|
2004-11-19 19:13:32 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 20:39:37 +00:00
|
|
|
/** Widgets used for the engine preview window */
|
|
|
|
enum EnginePreviewWidgets {
|
2009-11-08 19:22:45 +00:00
|
|
|
EPW_QUESTION, ///< The container for the question
|
2009-03-21 20:39:37 +00:00
|
|
|
EPW_NO, ///< No button
|
|
|
|
EPW_YES, ///< Yes button
|
|
|
|
};
|
|
|
|
|
2009-03-28 13:35:07 +00:00
|
|
|
static const NWidgetPart _nested_engine_preview_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-03-28 13:35:07 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_EMPTY, INVALID_COLOUR, EPW_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
|
2009-11-08 19:22:45 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, 10, 85),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
|
2009-03-28 13:35:07 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2008-05-18 20:49:22 +00:00
|
|
|
struct EnginePreviewWindow : Window {
|
2009-11-08 19:22:45 +00:00
|
|
|
static const int VEHICLE_SPACE = 40; // The space to show the vehicle image
|
|
|
|
|
|
|
|
EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-18 20:49:22 +00:00
|
|
|
{
|
2009-11-08 19:22:45 +00:00
|
|
|
this->InitNested(desc, window_number);
|
2008-05-18 20:49:22 +00:00
|
|
|
}
|
2005-10-01 12:43:34 +00:00
|
|
|
|
2008-05-18 20:49:22 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2009-11-08 19:22:45 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-11-08 19:22:45 +00:00
|
|
|
{
|
|
|
|
if (widget != EPW_QUESTION) return;
|
|
|
|
|
|
|
|
EngineID engine = this->window_number;
|
|
|
|
SetDParam(0, GetEngineCategoryName(engine));
|
|
|
|
size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WD_PAR_VSEP_WIDE + FONT_HEIGHT_NORMAL + VEHICLE_SPACE;
|
|
|
|
SetDParam(0, engine);
|
|
|
|
size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
if (widget != EPW_QUESTION) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 20:49:22 +00:00
|
|
|
EngineID engine = this->window_number;
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, GetEngineCategoryName(engine));
|
2009-11-08 19:22:45 +00:00
|
|
|
int y = r.top + GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, r.right - r.top + 1);
|
|
|
|
y = DrawStringMultiLine(r.left, r.right, r.top, y, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_CENTER) + WD_PAR_VSEP_WIDE;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-06-25 14:46:32 +00:00
|
|
|
SetDParam(0, engine);
|
2010-07-02 13:53:05 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
|
2009-11-08 19:22:45 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
|
2009-11-16 17:15:42 +00:00
|
|
|
DrawVehicleEngine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, this->width >> 1, y + VEHICLE_SPACE / 2, engine, GetEnginePalette(engine, _local_company));
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:22:45 +00:00
|
|
|
y += VEHICLE_SPACE;
|
|
|
|
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
|
2005-10-01 12:43:34 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 20:49:22 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2009-03-21 20:39:37 +00:00
|
|
|
case EPW_YES:
|
2008-12-28 14:37:19 +00:00
|
|
|
DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
|
2006-11-18 17:04:44 +00:00
|
|
|
/* Fallthrough */
|
2009-03-21 20:39:37 +00:00
|
|
|
case EPW_NO:
|
2008-05-18 20:49:22 +00:00
|
|
|
delete this;
|
2005-11-14 19:48:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-18 20:49:22 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _engine_preview_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_CENTER, 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_ENGINE_PREVIEW, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_engine_preview_widgets, lengthof(_nested_engine_preview_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2005-10-01 12:43:34 +00:00
|
|
|
void ShowEnginePreviewWindow(EngineID engine)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-18 20:49:22 +00:00
|
|
|
AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 19:52:38 +00:00
|
|
|
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
|
2008-06-20 07:23:00 +00:00
|
|
|
{
|
|
|
|
uint total = 0;
|
|
|
|
|
2009-10-06 19:52:38 +00:00
|
|
|
CargoArray cap = GetCapacityOfArticulatedParts(engine);
|
2009-06-27 21:36:04 +00:00
|
|
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
2008-06-20 07:23:00 +00:00
|
|
|
total += cap[c];
|
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2009-08-30 18:41:03 +00:00
|
|
|
static StringID GetTrainEngineInfoString(const Engine *e)
|
2005-07-01 14:05:44 +00:00
|
|
|
{
|
2009-01-25 00:57:03 +00:00
|
|
|
SetDParam(0, e->GetCost());
|
2009-02-01 16:10:06 +00:00
|
|
|
SetDParam(2, e->GetDisplayMaxSpeed());
|
|
|
|
SetDParam(3, e->GetPower());
|
|
|
|
SetDParam(1, e->GetDisplayWeight());
|
2009-10-27 19:56:00 +00:00
|
|
|
SetDParam(7, e->GetDisplayMaxTractiveEffort());
|
2005-07-01 14:05:44 +00:00
|
|
|
|
2009-01-25 00:57:03 +00:00
|
|
|
SetDParam(4, e->GetRunningCost());
|
2005-07-01 14:05:44 +00:00
|
|
|
|
2009-10-06 19:52:38 +00:00
|
|
|
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
|
2008-06-20 07:23:00 +00:00
|
|
|
if (capacity != 0) {
|
2009-02-21 12:52:41 +00:00
|
|
|
SetDParam(5, e->GetDefaultCargoType());
|
2008-07-26 22:00:59 +00:00
|
|
|
SetDParam(6, capacity);
|
2005-10-23 13:04:44 +00:00
|
|
|
} else {
|
2006-10-20 19:48:25 +00:00
|
|
|
SetDParam(5, CT_INVALID);
|
2005-07-01 14:05:44 +00:00
|
|
|
}
|
2010-01-30 16:27:35 +00:00
|
|
|
return (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(e->u.rail.railtype)->acceleration_type != 2) ? STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE : STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER;
|
2005-07-01 14:05:44 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 18:41:03 +00:00
|
|
|
static StringID GetAircraftEngineInfoString(const Engine *e)
|
2005-07-01 14:05:44 +00:00
|
|
|
{
|
2009-03-13 23:49:12 +00:00
|
|
|
CargoID cargo = e->GetDefaultCargoType();
|
2009-10-31 17:48:09 +00:00
|
|
|
uint16 mail_capacity;
|
|
|
|
uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
|
2009-01-25 00:57:03 +00:00
|
|
|
|
2010-01-07 16:39:04 +00:00
|
|
|
SetDParam(0, e->GetCost());
|
|
|
|
SetDParam(1, e->GetDisplayMaxSpeed());
|
|
|
|
SetDParam(2, cargo);
|
|
|
|
SetDParam(3, capacity);
|
|
|
|
|
2009-10-31 17:48:09 +00:00
|
|
|
if (mail_capacity > 0) {
|
|
|
|
SetDParam(4, CT_MAIL);
|
|
|
|
SetDParam(5, mail_capacity);
|
2009-04-20 22:41:09 +00:00
|
|
|
SetDParam(6, e->GetRunningCost());
|
2009-08-30 18:41:03 +00:00
|
|
|
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_CAPACITY_RUNCOST;
|
2009-03-13 23:49:12 +00:00
|
|
|
} else {
|
|
|
|
SetDParam(4, e->GetRunningCost());
|
2009-08-30 18:41:03 +00:00
|
|
|
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
|
2009-03-13 23:49:12 +00:00
|
|
|
}
|
2005-07-01 14:05:44 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 18:41:03 +00:00
|
|
|
static StringID GetRoadVehEngineInfoString(const Engine *e)
|
2005-07-01 14:05:44 +00:00
|
|
|
{
|
2010-03-06 12:59:28 +00:00
|
|
|
if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) {
|
|
|
|
SetDParam(0, e->GetCost());
|
|
|
|
SetDParam(1, e->GetDisplayMaxSpeed());
|
|
|
|
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
|
|
|
|
if (capacity != 0) {
|
|
|
|
SetDParam(2, e->GetDefaultCargoType());
|
|
|
|
SetDParam(3, capacity);
|
|
|
|
} else {
|
|
|
|
SetDParam(2, CT_INVALID);
|
|
|
|
}
|
|
|
|
SetDParam(4, e->GetRunningCost());
|
|
|
|
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
|
2009-02-21 12:52:41 +00:00
|
|
|
} else {
|
2010-03-06 12:59:28 +00:00
|
|
|
SetDParam(0, e->GetCost());
|
|
|
|
SetDParam(2, e->GetDisplayMaxSpeed());
|
|
|
|
SetDParam(3, e->GetPower());
|
|
|
|
SetDParam(1, e->GetDisplayWeight());
|
|
|
|
SetDParam(7, e->GetDisplayMaxTractiveEffort());
|
|
|
|
|
|
|
|
SetDParam(4, e->GetRunningCost());
|
|
|
|
|
|
|
|
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
|
|
|
|
if (capacity != 0) {
|
|
|
|
SetDParam(5, e->GetDefaultCargoType());
|
|
|
|
SetDParam(6, capacity);
|
|
|
|
} else {
|
|
|
|
SetDParam(5, CT_INVALID);
|
|
|
|
}
|
|
|
|
return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
|
2009-02-21 12:52:41 +00:00
|
|
|
}
|
2005-07-01 14:05:44 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 18:41:03 +00:00
|
|
|
static StringID GetShipEngineInfoString(const Engine *e)
|
2005-07-01 14:05:44 +00:00
|
|
|
{
|
2009-01-25 00:57:03 +00:00
|
|
|
SetDParam(0, e->GetCost());
|
2009-02-01 16:10:06 +00:00
|
|
|
SetDParam(1, e->GetDisplayMaxSpeed());
|
2009-02-21 12:52:41 +00:00
|
|
|
SetDParam(2, e->GetDefaultCargoType());
|
2009-03-18 19:32:13 +00:00
|
|
|
SetDParam(3, e->GetDisplayDefaultCapacity());
|
2009-01-25 00:57:03 +00:00
|
|
|
SetDParam(4, e->GetRunningCost());
|
2009-08-30 18:41:03 +00:00
|
|
|
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a multi-line string with some technical data, describing the engine.
|
|
|
|
* @param engine Engine to describe.
|
|
|
|
* @return String describing the engine.
|
|
|
|
* @post \c DParam array is set up for printing the string.
|
|
|
|
*/
|
|
|
|
StringID GetEngineInfoString(EngineID engine)
|
|
|
|
{
|
|
|
|
const Engine *e = Engine::Get(engine);
|
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case VEH_TRAIN:
|
|
|
|
return GetTrainEngineInfoString(e);
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
return GetRoadVehEngineInfoString(e);
|
|
|
|
|
|
|
|
case VEH_SHIP:
|
|
|
|
return GetShipEngineInfoString(e);
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
return GetAircraftEngineInfoString(e);
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2005-07-01 14:05:44 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 17:38:28 +00:00
|
|
|
/**
|
|
|
|
* Draw an engine.
|
2009-11-16 17:15:42 +00:00
|
|
|
* @param left Minimum horizontal position to use for drawing the engine
|
|
|
|
* @param right Maximum horizontal position to use for drawing the engine
|
|
|
|
* @param preferred_x Horizontal position to use for drawing the engine.
|
2009-08-30 17:38:28 +00:00
|
|
|
* @param y Vertical position to use for drawing the engine.
|
|
|
|
* @param engine Engine to draw.
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param pal Palette to use for drawing.
|
2009-08-30 17:38:28 +00:00
|
|
|
*/
|
2010-01-21 01:38:13 +00:00
|
|
|
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
|
2009-08-30 17:38:28 +00:00
|
|
|
{
|
|
|
|
const Engine *e = Engine::Get(engine);
|
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case VEH_TRAIN:
|
2009-11-16 17:15:42 +00:00
|
|
|
DrawTrainEngine(left, right, preferred_x, y, engine, pal);
|
2009-08-30 17:38:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
2009-11-16 17:15:42 +00:00
|
|
|
DrawRoadVehEngine(left, right, preferred_x, y, engine, pal);
|
2009-08-30 17:38:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VEH_SHIP:
|
2009-11-16 17:15:42 +00:00
|
|
|
DrawShipEngine(left, right, preferred_x, y, engine, pal);
|
2009-08-30 17:38:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT:
|
2009-11-16 17:15:42 +00:00
|
|
|
DrawAircraftEngine(left, right, preferred_x, y, engine, pal);
|
2009-08-30 17:38:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-13 17:47:07 +00:00
|
|
|
/** Sort all items using quick sort and given 'CompareItems' function
|
2008-05-27 12:24:23 +00:00
|
|
|
* @param el list to be sorted
|
|
|
|
* @param compare function for evaluation of the quicksort
|
|
|
|
*/
|
2008-05-28 17:29:27 +00:00
|
|
|
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
|
2008-05-27 12:24:23 +00:00
|
|
|
{
|
2008-05-28 17:29:27 +00:00
|
|
|
uint size = el->Length();
|
2008-05-27 12:24:23 +00:00
|
|
|
/* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems)
|
|
|
|
* generally, do not sort if there are less than 2 items */
|
|
|
|
if (size < 2) return;
|
2009-09-13 17:47:07 +00:00
|
|
|
QSortT(el->Begin(), size, compare);
|
2008-05-27 12:24:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sort selected range of items (on indices @ <begin, begin+num_items-1>)
|
|
|
|
* @param el list to be sorted
|
|
|
|
* @param compare function for evaluation of the quicksort
|
|
|
|
* @param begin start of sorting
|
|
|
|
* @param num_items count of items to be sorted
|
|
|
|
*/
|
2008-05-28 17:29:27 +00:00
|
|
|
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
|
2008-05-27 12:24:23 +00:00
|
|
|
{
|
2008-05-28 20:06:00 +00:00
|
|
|
if (num_items < 2) return;
|
2008-05-28 17:29:27 +00:00
|
|
|
assert(begin < el->Length());
|
|
|
|
assert(begin + num_items <= el->Length());
|
2009-09-13 17:47:07 +00:00
|
|
|
QSortT(el->Get(begin), num_items, compare);
|
2008-05-27 12:24:23 +00:00
|
|
|
}
|
|
|
|
|