Changeset - r9274:76c4320046fb
[Not reviewed]
master
0 15 1
rubidium - 17 years ago 2008-05-17 13:01:30
rubidium@openttd.org
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
16 files changed with 61 insertions and 30 deletions:
0 comments (0 inline, 0 general)
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -1405,12 +1405,16 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\slope_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sortlist_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound_func.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound_type.h"
 
				>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -1402,12 +1402,16 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\slope_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sortlist_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound_func.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound_type.h"
 
				>
source.list
Show inline comments
 
@@ -274,12 +274,13 @@ signal_func.h
 
signal_type.h
 
signs_base.h
 
signs_func.h
 
signs_type.h
 
slope_func.h
 
slope_type.h
 
sortlist_type.h
 
sound_func.h
 
sound_type.h
 
sprite.h
 
spritecache.h
 
station_base.h
 
station_func.h
src/aircraft_gui.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
#include "vehicle_gui.h"
 
#include "newgrf_engine.h"
 
#include "strings_func.h"
 
#include "vehicle_func.h"
 
#include "gfx_func.h"
 
#include "order_func.h"
 
#include "window_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
/**
 
* Draw the details for the given vehicle at the position (x,y)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -18,12 +18,13 @@
 
#include "autoreplace_func.h"
 
#include "gfx_func.h"
 
#include "player_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "engine_func.h"
 
#include "engine_base.h"
 
#include "window_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group);
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -25,12 +25,13 @@
 
#include "date_func.h"
 
#include "vehicle_func.h"
 
#include "settings_type.h"
 
#include "gfx_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "string_func.h"
 
#include "window_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
enum BuildVehicleWidgets {
 
	BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
src/depot_gui.cpp
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "window_func.h"
 
#include "vehicle_func.h"
 
#include "player_func.h"
 
#include "order_func.h"
 
#include "depot_base.h"
 
#include "tilehighlight_func.h"
 
#include "window_gui.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
/*
 
 * Since all depot window sizes aren't the same, we need to modify sizes a little.
src/economy.cpp
Show inline comments
 
@@ -43,12 +43,13 @@
 
#include "road_func.h"
 
#include "rail_map.h"
 
#include "signal_func.h"
 
#include "gfx_func.h"
 
#include "autoreplace_func.h"
 
#include "player_gui.h"
 
#include "window_gui.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
/**
 
 * Multiply two integer values and shift the results to right.
src/network/network_gui.cpp
Show inline comments
 
@@ -27,12 +27,13 @@
 
#include "../string_func.h"
 
#include "../gfx_func.h"
 
#include "../player_func.h"
 
#include "../settings_type.h"
 
#include "../widgets/dropdown_func.h"
 
#include "../querystring_gui.h"
 
#include "../sortlist_type.h"
 

	
 
#include "table/strings.h"
 
#include "../table/sprites.h"
 

	
 
#define BGC 5
 
#define BTC 15
src/sortlist_type.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file sortlist_type.h Base types for having sorted lists in GUIs. */
 

	
 
#ifndef SORTLIST_TYPE_H
 
#define SORTLIST_TYPE_H
 

	
 
enum SortListFlags {
 
	VL_NONE    = 0,      ///< no sort
 
	VL_DESC    = 1 << 0, ///< sort descending or ascending
 
	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
 
	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
 
	VL_END     = 1 << 3,
 
};
 
DECLARE_ENUM_AS_BIT_SET(SortListFlags);
 

	
 
struct Listing {
 
	bool order;    ///< Ascending/descending
 
	byte criteria; ///< Sorting criteria
 
};
 

	
 
template <typename T>
 
struct GUIList {
 
	T* sort_list;        ///< The items to sort.
 
	SortListFlags flags; ///< used to control sorting/resorting/etc.
 
	uint16 list_length;  ///< length of the list being sorted
 
	uint16 resort_timer; ///< resort list after a given amount of ticks if set
 
	byte sort_type;      ///< what criteria to sort on
 
};
 

	
 
#endif /* SORTLIST_TYPE_H */
src/train_cmd.cpp
Show inline comments
 
@@ -1347,13 +1347,13 @@ CommandCost CmdSellRailWagon(TileIndex t
 
	}
 

	
 
	if (IsRearDualheaded(v)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v == first && IsFrontEngine(first)) {
 
			delete FindWindowById(WC_VEHICLE_VIEW, first->index);
 
			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 
		}
 
		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 
		RebuildVehicleLists();
 
	}
 

	
 
	CommandCost cost(EXPENSES_NEW_VEHICLES);
src/vehicle.cpp
Show inline comments
 
@@ -587,17 +587,14 @@ void Vehicle::PreDestructor()
 
	 *  destroy vehicle, which on his turn can remove any
 
	 *  other artic parts. */
 
	if ((this->type == VEH_TRAIN && EngineHasArticPart(this)) || (this->type == VEH_ROAD && RoadVehHasArticPart(this))) {
 
		delete this->Next();
 
	}
 

	
 
	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
	if (w != NULL && w->viewport->follow_vehicle == this->index) {
 
		ScrollMainWindowTo(this->x_pos, this->y_pos, true); // lock the main view on the vehicle's last position
 
		w->viewport->follow_vehicle = INVALID_VEHICLE;
 
	}
 
	extern void StopGlobalFollowVehicle(const Vehicle *v);
 
	StopGlobalFollowVehicle(this);
 
}
 

	
 
Vehicle::~Vehicle()
 
{
 
	free(this->name);
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -2168,6 +2168,15 @@ void DrawVehicleImage(const Vehicle *v, 
 
		case VEH_ROAD:     DrawRoadVehImage(v, x, y, selection, count);     break;
 
		case VEH_SHIP:     DrawShipImage(v, x, y, selection);               break;
 
		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);           break;
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
void StopGlobalFollowVehicle(const Vehicle *v)
 
{
 
	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
	if (w != NULL && w->viewport->follow_vehicle == v->index) {
 
		ScrollMainWindowTo(v->x_pos, v->y_pos, true); // lock the main view on the vehicle's last position
 
		w->viewport->follow_vehicle = INVALID_VEHICLE;
 
	}
 
}
src/vehicle_gui.h
Show inline comments
 
@@ -2,13 +2,14 @@
 

	
 
/** @file vehicle_gui.h Functions related to the vehicle's GUIs. */
 

	
 
#ifndef VEHICLE_GUI_H
 
#define VEHICLE_GUI_H
 

	
 
#include "window_gui.h"
 
#include "sortlist_type.h"
 
#include "window_type.h"
 
#include "vehicle_type.h"
 
#include "order_type.h"
 
#include "station_type.h"
 
#include "engine_type.h"
 
#include "vehicle_base.h"
 

	
src/viewport.cpp
Show inline comments
 
@@ -44,12 +44,13 @@
 
#include "settings_type.h"
 
#include "station_func.h"
 
#include "core/alloc_type.hpp"
 
#include "misc/smallvec.h"
 
#include "window_func.h"
 
#include "tilehighlight_func.h"
 
#include "window_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
PlaceProc *_place_proc;
 
Point _tile_fract_coords;
src/window_gui.h
Show inline comments
 
@@ -511,35 +511,12 @@ class PickerWindowBase : public Window {
 
public:
 
	PickerWindowBase(const WindowDesc *desc) : Window(desc) {}; // nothing special yet, just propagation
 

	
 
	virtual ~PickerWindowBase();
 
};
 

	
 
enum SortListFlags {
 
	VL_NONE    = 0,      ///< no sort
 
	VL_DESC    = 1 << 0, ///< sort descending or ascending
 
	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
 
	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
 
	VL_END     = 1 << 3,
 
};
 
DECLARE_ENUM_AS_BIT_SET(SortListFlags);
 

	
 
struct Listing {
 
	bool order;    ///< Ascending/descending
 
	byte criteria; ///< Sorting criteria
 
};
 

	
 
template <typename T>
 
struct GUIList {
 
	T* sort_list;        ///< The items to sort.
 
	SortListFlags flags; ///< used to control sorting/resorting/etc.
 
	uint16 list_length;  ///< length of the list being sorted
 
	uint16 resort_timer; ///< resort list after a given amount of ticks if set
 
	byte sort_type;      ///< what criteria to sort on
 
};
 

	
 
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
 
enum WindowWidgetBehaviours {
 
	WWB_PUSHBUTTON  = 1 << 5,
 

	
 
	WWB_MASK        = 0xE0,
 
};
0 comments (0 inline, 0 general)