Merge branches 'tracerestrict-sx' and 'template_train_replacement-sx' into jgrpp

This commit is contained in:
Jonathan G Rennison
2016-03-08 19:33:00 +00:00
4 changed files with 25 additions and 6 deletions

View File

@@ -679,7 +679,7 @@ public:
}
/* Draw the template */
DrawTemplate(v, left + ScaleGUITrad(50), right, y);
DrawTemplate(v, left + ScaleGUITrad(36), right - ScaleGUITrad(24), y);
/* Draw a notification string for chains that are not runnable */
if (v->IsFreeWagonChain()) {

View File

@@ -119,16 +119,26 @@ void DrawTemplate(const TemplateVehicle *tv, int left, int right, int y)
{
if (!tv) return;
DrawPixelInfo tmp_dpi, *old_dpi;
int max_width = right - left + 1;
int height = ScaleGUITrad(14);
if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
const TemplateVehicle *t = tv;
int offset = left;
int offset = 0;
while (t) {
PaletteID pal = GetEnginePalette(t->engine_type, _current_company);
DrawSprite(t->cur_image, pal, offset, y + ScaleGUITrad(11));
DrawSprite(t->cur_image, pal, offset + t->image_width / 2, ScaleGUITrad(11));
offset += t->image_width;
t = t->Next();
}
_cur_dpi = old_dpi;
}
// copy important stuff from the virtual vehicle to the template

View File

@@ -658,8 +658,9 @@ void TraceRestrictCreateProgramMapping(TraceRestrictRefId ref, TraceRestrictProg
/**
* Remove a program mapping
* @return true if a mapping was actually removed
*/
void TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref)
bool TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref)
{
TraceRestrictMapping::iterator iter = _tracerestrictprogram_mapping.find(ref);
if (iter != _tracerestrictprogram_mapping.end()) {
@@ -689,6 +690,9 @@ void TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref)
}
}
}
return true;
} else {
return false;
}
}
@@ -728,8 +732,9 @@ TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool creat
void TraceRestrictNotifySignalRemoval(TileIndex tile, Track track)
{
TraceRestrictRefId ref = MakeTraceRestrictRefId(tile, track);
TraceRestrictRemoveProgramMapping(ref);
bool removed = TraceRestrictRemoveProgramMapping(ref);
DeleteWindowById(WC_TRACE_RESTRICT, ref);
if (removed) InvalidateWindowClassesData(WC_TRACE_RESTRICT);
}
/**
@@ -1014,6 +1019,10 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
}
}
if (type != TRDCT_PROG_RESET && !TraceRestrictProgram::CanAllocateItem()) {
return CMD_ERROR;
}
if (!(flags & DC_EXEC)) {
return CommandCost();
}

View File

@@ -520,7 +520,7 @@ static inline Track GetTraceRestrictRefIdTrack(TraceRestrictRefId ref)
void TraceRestrictSetIsSignalRestrictedBit(TileIndex t);
void TraceRestrictCreateProgramMapping(TraceRestrictRefId ref, TraceRestrictProgram *prog);
void TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref);
bool TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref);
TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool create_new);