Allow changing the colour of plans
This commit is contained in:
@@ -103,6 +103,34 @@ CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the colour of a plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 plan id
|
||||
* @param p2 colour
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdChangePlanColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Plan *p = Plan::GetIfValid(p1);
|
||||
if (p == nullptr) return CMD_ERROR;
|
||||
if (p2 >= COLOUR_END) return CMD_ERROR;
|
||||
CommandCost ret = CheckOwnership(p->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
if (flags & DC_EXEC) {
|
||||
p->colour = (Colours)p2;
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(INVALID_PLAN, false);
|
||||
for (const PlanLine *line : p->lines) {
|
||||
if (line->visible) line->MarkDirty();
|
||||
}
|
||||
if (p->temp_line) p->temp_line->MarkDirty();
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a plan.
|
||||
* @param tile unused
|
||||
|
Reference in New Issue
Block a user