src/graph_gui.cpp
branchNewGRF_ports
changeset 6870 ca3fd1fbe311
parent 6743 cabfaa4a0295
child 6871 5a9dc001e1ad
child 9722 ebf0ece7d8f6
equal deleted inserted replaced
6869:76282d3b748d 6870:ca3fd1fbe311
  1004 				/* Draw the score */
  1004 				/* Draw the score */
  1005 				SetDParam(0, score);
  1005 				SetDParam(0, score);
  1006 				DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
  1006 				DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
  1007 
  1007 
  1008 				/* Calculate the %-bar */
  1008 				/* Calculate the %-bar */
  1009 				if (val > needed) {
  1009 				x = clamp(val, 0, needed) * 50 / needed;
  1010 					x = 50;
       
  1011 				} else if (val == 0) {
       
  1012 					x = 0;
       
  1013 				} else {
       
  1014 					x = val * 50 / needed;
       
  1015 				}
       
  1016 
  1010 
  1017 				/* SCORE_LOAN is inversed */
  1011 				/* SCORE_LOAN is inversed */
  1018 				if (val < 0 && i == SCORE_LOAN) x = 0;
  1012 				if (val < 0 && i == SCORE_LOAN) x = 0;
  1019 
  1013 
  1020 				/* Draw the bar */
  1014 				/* Draw the bar */
  1021 				if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
  1015 				if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
  1022 				if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
  1016 				if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
  1023 
  1017 
  1024 				/* Calculate the % */
  1018 				/* Calculate the % */
  1025 				x = (val <= needed) ? val * 100 / needed : 100;
  1019 				x = clamp(val, 0, needed) * 100 / needed;
  1026 
  1020 
  1027 				/* SCORE_LOAN is inversed */
  1021 				/* SCORE_LOAN is inversed */
  1028 				if (val < 0 && i == SCORE_LOAN) x = 0;
  1022 				if (val < 0 && i == SCORE_LOAN) x = 0;
  1029 
  1023 
  1030 				/* Draw it */
  1024 				/* Draw it */