industry_gui.c
changeset 1786 7cfd46c3fcc4
parent 1666 46dc094142b1
child 1891 862800791170
equal deleted inserted replaced
1785:d3f3496b5943 1786:7cfd46c3fcc4
    10 #include "command.h"
    10 #include "command.h"
    11 #include "viewport.h"
    11 #include "viewport.h"
    12 #include "industry.h"
    12 #include "industry.h"
    13 #include "town.h"
    13 #include "town.h"
    14 
    14 
    15 static const byte _build_industry_types[4][12] = {
    15 /* Present in table/build_industry.h" */
    16 	{ 1,  2, 4,  6, 8, 0, 3, 5,  9, 11, 18 },
    16 extern const byte _build_industry_types[4][12];
    17 	{ 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 },
       
    18 	{ 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 },
       
    19 	{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 },
       
    20 };
       
    21 
       
    22 extern const byte _industry_type_costs[37];
    17 extern const byte _industry_type_costs[37];
    23 
    18 
    24 static void UpdateIndustryProduction(Industry *i);
    19 static void UpdateIndustryProduction(Industry *i);
    25 extern void DrawArrowButtons(int x, int y, int state);
    20 extern void DrawArrowButtons(int x, int y, int state);
    26 
    21 
    28 {
    23 {
    29 	switch(e->event) {
    24 	switch(e->event) {
    30 	case WE_PAINT:
    25 	case WE_PAINT:
    31 		DrawWindowWidgets(w);
    26 		DrawWindowWidgets(w);
    32 		if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
    27 		if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
    33 			int ind_type = _build_industry_types[_opt.landscape][WP(w,def_d).data_1];
    28 			int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1];
    34 
    29 
    35 			SetDParam(0, (_price.build_industry >> 5) * _industry_type_costs[ind_type]);
    30 			SetDParam(0, (_price.build_industry >> 5) * _industry_type_costs[ind_type]);
    36 			DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
    31 			DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
    37 		}
    32 		}
    38 		break;
    33 		break;
    44 				WP(w,def_d).data_1 = wid - 3;
    39 				WP(w,def_d).data_1 = wid - 3;
    45 		}
    40 		}
    46 	} break;
    41 	} break;
    47 
    42 
    48 	case WE_PLACE_OBJ:
    43 	case WE_PLACE_OBJ:
    49 		if (DoCommandP(e->place.tile, _build_industry_types[_opt.landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
    44 		if (DoCommandP(e->place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
    50 			ResetObjectToPlace();
    45 			ResetObjectToPlace();
    51 		break;
    46 		break;
    52 
    47 
    53 	case WE_ABORT_PLACE_OBJ:
    48 	case WE_ABORT_PLACE_OBJ:
    54 		w->click_state = 0;
    49 		w->click_state = 0;
   265 	},
   260 	},
   266 };
   261 };
   267 
   262 
   268 void ShowBuildIndustryWindow(void)
   263 void ShowBuildIndustryWindow(void)
   269 {
   264 {
   270 	AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt.landscape],0);
   265 	AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
   271 }
   266 }
   272 
   267 
   273 #define NEED_ALTERB	((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES))
   268 #define NEED_ALTERB	((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES))
   274 static void IndustryViewWndProc(Window *w, WindowEvent *e)
   269 static void IndustryViewWndProc(Window *w, WindowEvent *e)
   275 {
   270 {