1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 12:39:11 +00:00

(svn r26461) [1.4] -Backport from trunk:

- Fix: Avoid division by 0 when scaling flow values [FS#5970] (r26448)
- Feature: Draw links to match _settings_game.vehicle.road_side [FS#5961] (r26445)
- Change: Use pkg-config for libpng as well (r26435, r26433, r26432)
- Feature: Load button for heightmap list [FS#5953] (r26428)
This commit is contained in:
frosch
2014-04-13 10:52:19 +00:00
parent 42c7cb38fa
commit f8b956bc2c
7 changed files with 72 additions and 129 deletions

View File

@@ -133,9 +133,11 @@ static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = {
SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0),
SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
@@ -521,16 +523,21 @@ public:
break;
case WID_SL_LOAD_BUTTON:
if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
if (this->selected != NULL && !_load_check_data.HasErrors()) {
const char *name = FiosBrowseTo(this->selected);
SetFiosType(this->selected->type);
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
strecpy(_file_to_saveload.title, this->selected->title, lastof(_file_to_saveload.title));
ClearErrorMessages();
delete this;
if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
delete this;
ShowHeightmapLoad();
} else if (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
ClearErrorMessages();
delete this;
}
}
break;
@@ -679,6 +686,9 @@ public:
case 1:
/* Selection changes */
if (!gui_scope) break;
if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == NULL || _load_check_data.HasErrors());
}
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON,
this->selected == NULL || _load_check_data.HasErrors() || !(_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()));

View File

@@ -2668,6 +2668,7 @@ STR_SAVELOAD_SAVE_BUTTON :{BLACK}Save
STR_SAVELOAD_SAVE_TOOLTIP :{BLACK}Save the current game, using the selected name
STR_SAVELOAD_LOAD_BUTTON :{BLACK}Load
STR_SAVELOAD_LOAD_TOOLTIP :{BLACK}Load the selected game
STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP :{BLACK}Load the selected heightmap
STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Game Details
STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}No information available
STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING1}

View File

@@ -49,8 +49,10 @@ void FlowMapper::Run(LinkGraphJob &job) const
FlowStatMap &flows = node.Flows();
flows.FinalizeLocalConsumption(node.Station());
if (this->scale) {
/* Scale by time the graph has been running without being compressed. */
uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression();
/* Scale by time the graph has been running without being compressed. Add 1 to avoid
* division by 0 if spawn date == last compression date. This matches
* LinkGraph::Monthly(). */
uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression() + 1;
for (FlowStatMap::iterator i = flows.begin(); i != flows.end(); ++i) {
i->second.ScaleToMonthly(runtime);
}

View File

@@ -220,11 +220,12 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c
/* Move line a bit 90° against its dominant direction to prevent it from
* being hidden below the grey line. */
int side = _settings_game.vehicle.road_side ? 1 : -1;
if (abs(pta.x - ptb.x) < abs(pta.y - ptb.y)) {
int offset_x = (pta.y > ptb.y ? 1 : -1) * this->scale;
int offset_x = (pta.y > ptb.y ? 1 : -1) * side * this->scale;
GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, this->scale, dash);
} else {
int offset_y = (pta.x < ptb.x ? 1 : -1) * this->scale;
int offset_y = (pta.x < ptb.x ? 1 : -1) * side * this->scale;
GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, this->scale, dash);
}

View File

@@ -4314,9 +4314,11 @@ void FlowStat::ReleaseShare(StationID st)
/**
* Scale all shares from link graph's runtime to monthly values.
* @param runtime Time the link graph has been running without compression.
* @pre runtime must be greater than 0 as we don't want infinite flow values.
*/
void FlowStat::ScaleToMonthly(uint runtime)
{
assert(runtime > 0);
SharesMap new_shares;
uint share = 0;
for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {

View File

@@ -23,4 +23,4 @@ enum StoryBookWidgets {
WID_SB_NEXT_PAGE, ///< Next button.
};
#endif /* WIDGETS_STORY_WIDGET_H */
#endif /* WIDGETS_STORY_WIDGET_H */