Changeset - r12785:d5ef8ab3ffd9
[Not reviewed]
master
0 2 0
smatz - 15 years ago 2009-08-25 10:44:19
smatz@openttd.org
(svn r17281) -Feature(tte): open the 'Rename group' dialog after creating new group
2 files changed with 48 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/callback_table.cpp
Show inline comments
 
@@ -58,12 +58,15 @@ CommandCallback CcBuildRoadVeh;
 
CommandCallback CcBuildShip;
 

	
 
/* train_gui.cpp */
 
CommandCallback CcBuildWagon;
 
CommandCallback CcBuildLoco;
 

	
 
/* group_gui.cpp */
 
CommandCallback CcCreateGroup;
 

	
 
/* ai/ai_core.cpp */
 
CommandCallback CcAI;
 

	
 
CommandCallback *_callback_table[] = {
 
	/* 0x00 */ NULL,
 
	/* 0x01 */ CcBuildAircraft,
 
@@ -86,9 +89,10 @@ CommandCallback *_callback_table[] = {
 
	/* 0x12 */ CcPlaySound1E,
 
	/* 0x13 */ CcStation,
 
	/* 0x14 */ CcTerraform,
 
	/* 0x15 */ CcAI,
 
	/* 0x16 */ CcCloneVehicle,
 
	/* 0x17 */ CcGiveMoney,
 
	/* 0x18 */ CcCreateGroup,
 
};
 

	
 
const int _callback_table_count = lengthof(_callback_table);
src/group_gui.cpp
Show inline comments
 
@@ -498,34 +498,29 @@ public:
 
				_cursor.vehchain = true;
 

	
 
				this->SetDirty();
 
				break;
 
			}
 

	
 
			case GRP_WIDGET_CREATE_GROUP: // Create a new group
 
				DoCommandP(0, this->vehicle_type, 0, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE));
 
			case GRP_WIDGET_CREATE_GROUP: { // Create a new group
 
				extern void CcCreateGroup(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
				DoCommandP(0, this->vehicle_type, 0, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
 
				break;
 
			}
 

	
 
			case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group
 
				GroupID group = this->group_sel;
 
				this->group_sel = ALL_GROUP;
 

	
 
				DoCommandP(0, group, 0, CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE));
 
				break;
 
			}
 

	
 
			case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
 
				assert(Group::IsValidID(this->group_sel));
 

	
 
				const Group *g = Group::Get(this->group_sel);
 
				this->group_rename = this->group_sel;
 

	
 
				SetDParam(0, g->index);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
			} break;
 

	
 
			case GRP_WIDGET_RENAME_GROUP: // Rename the selected roup
 
				this->ShowRenameGroupWindow(this->group_sel);
 
				break;
 

	
 
			case GRP_WIDGET_AVAILABLE_VEHICLES:
 
				ShowBuildVehicleWindow(INVALID_TILE, this->vehicle_type);
 
				break;
 

	
 
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
 
@@ -681,12 +676,20 @@ public:
 
	{
 
		/* abort drag & drop */
 
		this->vehicle_sel = INVALID_VEHICLE;
 
		this->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
 
	}
 

	
 
	void ShowRenameGroupWindow(GroupID group)
 
	{
 
		assert(Group::IsValidID(group));
 
		this->group_rename = group;
 
		SetDParam(0, group);
 
		ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
	}
 

	
 
	/**
 
	 * Tests whether a given vehicle is selected in the window, and unselects it if necessary.
 
	 * Called when the vehicle is deleted.
 
	 * @param vehicle Vehicle that is going to be deleted
 
	 */
 
	void UnselectVehicle(VehicleID vehicle)
 
@@ -710,23 +713,47 @@ void ShowCompanyGroup(CompanyID company,
 
	_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
 
	WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | company;
 
	AllocateWindowDescFront<VehicleGroupWindow>(&_group_desc, num);
 
}
 

	
 
/**
 
 * Finds a group list window determined by vehicle type and owner
 
 * @param vt vehicle type
 
 * @param owner owner of groups
 
 * @return pointer to VehicleGroupWindow, NULL if not found
 
 */
 
static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner owner)
 
{
 
	return (VehicleGroupWindow *)FindWindowById(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | owner);
 
}
 

	
 
/**
 
 * Opens a 'Rename group' window for newly created group
 
 * @param success did command succeed?
 
 * @param tile unused
 
 * @param p1 vehicle type
 
 * @param p2 unused
 
 * @see CmdCreateGroup
 
 */
 
void CcCreateGroup(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (!success) return;
 
	assert(p1 <= VEH_AIRCRAFT);
 

	
 
	VehicleGroupWindow *w = FindVehicleGroupWindow((VehicleType)p1, _current_company);
 
	if (w != NULL) w->ShowRenameGroupWindow(_new_group_id);
 
}
 

	
 
/**
 
 * Removes the highlight of a vehicle in a group window
 
 * @param *v Vehicle to remove all highlights from
 
 */
 
void DeleteGroupHighlightOfVehicle(const Vehicle *v)
 
{
 
	VehicleGroupWindow *w;
 

	
 
	/* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any group windows either
 
	 * If that is the case, we can skip looping though the windows and save time
 
	 */
 
	if (_special_mouse_mode != WSM_DRAGDROP) return;
 

	
 
	VehicleType vehicle_type = v->type;
 
	w = dynamic_cast<VehicleGroupWindow *>(FindWindowById(GetWindowClassForVehicleType(vehicle_type), (vehicle_type << 11) | VLW_GROUP_LIST | v->owner));
 
	VehicleGroupWindow *w = FindVehicleGroupWindow(v->type, v->owner);
 
	if (w != NULL) w->UnselectVehicle(v->index);
 
}
 

	
0 comments (0 inline, 0 general)