tron@2186: /* $Id$ */ tron@2186: belugas@6527: /** @file industry_gui.cpp */ belugas@6527: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@1299: #include "debug.h" tron@2163: #include "functions.h" tron@1309: #include "strings.h" tron@507: #include "table/strings.h" Darkvater@1914: #include "table/sprites.h" tron@679: #include "map.h" tron@1386: #include "gui.h" truelight@0: #include "window.h" truelight@0: #include "gfx.h" truelight@0: #include "command.h" truelight@0: #include "viewport.h" truelight@0: #include "industry.h" truelight@0: #include "town.h" tron@2159: #include "variables.h" rubidium@5838: #include "helpers.hpp" peter1138@6417: #include "cargotype.h" truelight@0: belugas@6527: /* industries per climate, according to the different construction windows */ belugas@4995: const byte _build_industry_types[4][12] = { belugas@4995: { 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 }, belugas@4995: { 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 }, belugas@4995: { 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 }, belugas@4995: { 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 }, belugas@4995: }; truelight@0: miham@1004: static void UpdateIndustryProduction(Industry *i); miham@1004: truelight@0: static void BuildIndustryWndProc(Window *w, WindowEvent *e) truelight@0: { tron@2951: switch (e->event) { truelight@0: case WE_PAINT: truelight@0: DrawWindowWidgets(w); truelight@0: if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { celestar@9910: int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1]; truelight@0: celestar@9912: SetDParam(0, (_eco->GetPrice(CEconomy::BUILD_INDUSTRY) >> 8) * GetIndustrySpec(ind_type)->cost_multiplier); truelight@0: DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); truelight@0: } truelight@0: break; truelight@0: truelight@0: case WE_CLICK: { belugas@4634: int wid = e->we.click.widget; truelight@0: if (wid >= 3) { Darkvater@1914: if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) celestar@9910: WP(w, def_d).data_1 = wid - 3; truelight@0: } truelight@0: } break; truelight@0: truelight@0: case WE_PLACE_OBJ: celestar@9910: if (DoCommandP(e->we.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))) truelight@0: ResetObjectToPlace(); truelight@0: break; truelight@193: truelight@0: case WE_ABORT_PLACE_OBJ: belugas@4719: RaiseWindowButtons(w); truelight@0: break; truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _build_industry_land0_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land1_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land2_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land3_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land0_widgets_extra[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP}, truelight@0: darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land1_widgets_extra[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 174, 0x0, STR_NULL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024F_GOLD_MINE, STR_CONSTRUCT_GOLD_MINE_TIP}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land2_widgets_extra[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 200, 0x0, STR_NULL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0252_RUBBER_PLANTATION, STR_CONSTRUCT_RUBBER_PLANTATION_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 162, 173, STR_0253_WATER_SUPPLY, STR_CONSTRUCT_WATER_SUPPLY_TIP}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _build_industry_land3_widgets_extra[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 71, 82, STR_0257_COTTON_CANDY_FOREST, STR_CONSTRUCT_COTTON_CANDY_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_025D_PLASTIC_FOUNTAINS, STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0261_SUGAR_MINE, STR_CONSTRUCT_SUGAR_MINE_TIP}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: truelight@0: static const WindowDesc _build_industry_land0_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 116, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land0_widgets, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land1_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 116, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land1_widgets, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land2_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 116, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land2_widgets, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land3_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 116, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land3_widgets, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land0_desc_extra = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 188, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land0_widgets_extra, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land1_desc_extra = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 175, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land1_widgets_extra, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land2_desc_extra = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 201, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land2_widgets_extra, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc _build_industry_land3_desc_extra = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 170, 188, rubidium@6144: WC_BUILD_INDUSTRY, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _build_industry_land3_widgets_extra, truelight@0: BuildIndustryWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc * const _industry_window_desc[2][4] = { truelight@0: { truelight@0: &_build_industry_land0_desc, truelight@0: &_build_industry_land1_desc, truelight@0: &_build_industry_land2_desc, truelight@0: &_build_industry_land3_desc, truelight@0: }, truelight@0: { truelight@0: &_build_industry_land0_desc_extra, truelight@0: &_build_industry_land1_desc_extra, truelight@0: &_build_industry_land2_desc_extra, truelight@0: &_build_industry_land3_desc_extra, truelight@0: }, truelight@0: }; truelight@0: celestar@9895: void ShowBuildIndustryWindow() truelight@193: { Darkvater@5005: if (!IsValidPlayer(_current_player)) return; celestar@9910: AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape], 0); truelight@0: } truelight@0: miham@4211: static inline bool isProductionMinimum(const Industry *i, int pt) { miham@4211: return i->production_rate[pt] == 1; miham@4211: } miham@4211: miham@4211: static inline bool isProductionMaximum(const Industry *i, int pt) { miham@4211: return i->production_rate[pt] == 255; miham@4211: } miham@4211: Darkvater@4194: static inline bool IsProductionAlterable(const Industry *i) Darkvater@4194: { celestar@9911: const IndustrySpec *ind = GetIndustrySpec(i->type); Darkvater@4194: return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && celestar@9911: (ind->accepts_cargo[0] == CT_INVALID || ind->accepts_cargo[0] == CT_VALUABLES)); Darkvater@4194: } Darkvater@4194: truelight@0: static void IndustryViewWndProc(Window *w, WindowEvent *e) truelight@0: { belugas@6527: /* WP(w,vp2_d).data_1 is for the editbox line belugas@6527: * WP(w,vp2_d).data_2 is for the clickline belugas@6527: * WP(w,vp2_d).data_3 is for the click pos (left or right) */ truelight@0: tron@2951: switch (e->event) { miham@1004: case WE_PAINT: { belugas@4171: const Industry *i = GetIndustry(w->window_number); celestar@9911: const IndustrySpec *ind = GetIndustrySpec(i->type); tron@2557: ludde@2070: SetDParam(0, w->window_number); truelight@0: DrawWindowWidgets(w); truelight@0: celestar@9911: if (ind->accepts_cargo[0] != CT_INVALID) { tron@2989: StringID str; tron@2989: celestar@9911: SetDParam(0, GetCargo(ind->accepts_cargo[0])->name); truelight@0: str = STR_4827_REQUIRES; celestar@9911: if (ind->accepts_cargo[1] != CT_INVALID) { celestar@9911: SetDParam(1, GetCargo(ind->accepts_cargo[1])->name); tron@2989: str = STR_4828_REQUIRES; celestar@9911: if (ind->accepts_cargo[2] != CT_INVALID) { celestar@9911: SetDParam(2, GetCargo(ind->accepts_cargo[2])->name); tron@2989: str = STR_4829_REQUIRES; truelight@0: } truelight@0: } truelight@0: DrawString(2, 107, str, 0); truelight@0: } truelight@193: celestar@9911: if (ind->produced_cargo[0] != CT_INVALID) { truelight@0: DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); truelight@0: celestar@9911: SetDParam(0, ind->produced_cargo[0]); celestar@9912: SetDParam(1, i->last_month_production[0]); ludde@2063: celestar@9912: SetDParam(2, i->last_month_pct_transported[0] * 100 >> 8); Darkvater@4194: DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); belugas@6527: /* Let's put out those buttons.. */ miham@4211: if (IsProductionAlterable(i)) { celestar@9910: DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0, miham@4211: !isProductionMinimum(i, 0), !isProductionMaximum(i, 0)); miham@4211: } truelight@0: celestar@9911: if (ind->produced_cargo[1] != CT_INVALID) { celestar@9911: SetDParam(0, ind->produced_cargo[1]); celestar@9912: SetDParam(1, i->last_month_production[1]); celestar@9912: SetDParam(2, i->last_month_pct_transported[1] * 100 >> 8); Darkvater@4194: DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); belugas@6527: /* Let's put out those buttons.. */ miham@4211: if (IsProductionAlterable(i)) { celestar@9910: DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0, miham@4211: !isProductionMinimum(i, 1), !isProductionMaximum(i, 1)); miham@4211: } truelight@0: } truelight@0: } truelight@0: truelight@0: DrawWindowViewport(w); miham@1004: } truelight@0: break; truelight@0: miham@1004: case WE_CLICK: { miham@1004: Industry *i; miham@1004: belugas@4634: switch (e->we.click.widget) { miham@1004: case 5: { Darkvater@4193: int line, x; miham@1004: miham@1004: i = GetIndustry(w->window_number); miham@1004: belugas@6527: /* We should work if needed.. */ Darkvater@4194: if (!IsProductionAlterable(i)) return; miham@1004: belugas@4634: x = e->we.click.pt.x; belugas@4634: line = (e->we.click.pt.y - 127) / 10; celestar@9911: if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && celestar@9911: GetIndustrySpec(i->type)->produced_cargo[line] != CT_INVALID) { tron@1019: if (IS_INT_INSIDE(x, 5, 25) ) { Darkvater@4193: /* Clicked buttons, decrease or increase production */ tron@1019: if (x < 15) { miham@4211: if (isProductionMinimum(i, line)) return; celestar@5852: i->production_rate[line] = max(i->production_rate[line] / 2, 1); miham@1004: } else { miham@4211: if (isProductionMaximum(i, line)) return; Darkvater@4193: i->production_rate[line] = minu(i->production_rate[line] * 2, 255); miham@1004: } Darkvater@4193: miham@1004: UpdateIndustryProduction(i); miham@1004: SetWindowDirty(w); miham@1004: w->flags4 |= 5 << WF_TIMEOUT_SHL; celestar@9910: WP(w, vp2_d).data_2 = line + 1; celestar@9910: WP(w, vp2_d).data_3 = (x < 15 ? 1 : 2); miham@1004: } else if (IS_INT_INSIDE(x, 34, 160)) { belugas@6527: /* clicked the text */ celestar@9910: WP(w, vp2_d).data_1 = line; miham@1004: SetDParam(0, i->production_rate[line] * 8); Darkvater@5682: ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL); miham@1004: } tron@1019: } Darkvater@4193: } break; darkvater@758: case 6: truelight@919: i = GetIndustry(w->window_number); tron@1981: ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1)); celestar@9910: } break; Darkvater@4193: miham@1004: } truelight@0: break; miham@1004: case WE_TIMEOUT: celestar@9910: WP(w, vp2_d).data_2 = 0; celestar@9910: WP(w, vp2_d).data_3 = 0; miham@1004: SetWindowDirty(w); miham@1004: break; miham@1004: miham@1004: case WE_ON_EDIT_TEXT: belugas@4634: if (e->we.edittext.str[0] != '\0') { tron@3017: Industry* i = GetIndustry(w->window_number); celestar@9910: int line = WP(w, vp2_d).data_1; miham@1004: belugas@4634: i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255); miham@1004: UpdateIndustryProduction(i); miham@1004: SetWindowDirty(w); miham@1004: } truelight@0: } truelight@0: } truelight@0: miham@1004: static void UpdateIndustryProduction(Industry *i) miham@1004: { celestar@9911: const IndustrySpec *ind = GetIndustrySpec(i->type); miham@1004: celestar@9911: for (byte j = 0; j < lengthof(ind->produced_cargo); j++) { celestar@9911: if (ind->produced_cargo[j] != CT_INVALID) { celestar@9912: i->last_month_production[j] = 8 * i->production_rate[j]; celestar@9911: } celestar@9911: } miham@1004: } miham@1004: truelight@0: static const Widget _industry_view_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_STICKYBOX, RESIZE_NONE, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, Darkvater@4938: { WWT_PANEL, RESIZE_NONE, 9, 0, 259, 14, 105, 0x0, STR_NULL}, Darkvater@4939: { WWT_INSET, RESIZE_NONE, 9, 2, 257, 16, 103, 0x0, STR_NULL}, Darkvater@4938: { WWT_PANEL, RESIZE_NONE, 9, 0, 259, 106, 147, 0x0, STR_NULL}, rubidium@4344: { WWT_PUSHTXTBTN, RESIZE_NONE, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, Darkvater@4938: { WWT_PANEL, RESIZE_NONE, 9, 130, 259, 148, 159, 0x0, STR_NULL}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _industry_view_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 260, 160, rubidium@6144: WC_INDUSTRY_VIEW, WC_NONE, darkvater@758: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, truelight@0: _industry_view_widgets, truelight@0: IndustryViewWndProc truelight@0: }; truelight@0: truelight@0: void ShowIndustryViewWindow(int industry) truelight@0: { belugas@4171: Window *w = AllocateWindowDescFront(&_industry_view_desc, industry); truelight@0: tron@2989: if (w != NULL) { truelight@0: w->flags4 |= WF_DISABLE_VP_SCROLL; celestar@9910: WP(w, vp2_d).data_1 = 0; celestar@9910: WP(w, vp2_d).data_2 = 0; celestar@9910: WP(w, vp2_d).data_3 = 0; celestar@9911: AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY); truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _industry_directory_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_STICKYBOX, RESIZE_NONE, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON}, rubidium@4344: { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, rubidium@4344: { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP}, rubidium@4344: { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP}, rubidium@4344: { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 13, 401, 495, 14, 25, 0x0, STR_NULL}, Darkvater@4938: { WWT_PANEL, RESIZE_BOTTOM, 13, 0, 495, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, rubidium@4344: { WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 496, 507, 14, 177, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, rubidium@4344: { WWT_RESIZEBOX, RESIZE_TB, 13, 496, 507, 178, 189, 0x0, STR_RESIZE_BUTTON}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static uint _num_industry_sort; truelight@0: truelight@0: static char _bufcache[96]; tron@4277: static const Industry* _last_industry; truelight@0: truelight@0: static byte _industry_sort_order; truelight@0: darkvater@164: static int CDECL GeneralIndustrySorter(const void *a, const void *b) truelight@0: { tron@4277: const Industry* i = *(const Industry**)a; tron@4277: const Industry* j = *(const Industry**)b; celestar@9911: const IndustrySpec *ind_i = GetIndustrySpec(i->type); celestar@9911: const IndustrySpec *ind_j = GetIndustrySpec(j->type); tron@4282: int r; truelight@0: truelight@0: switch (_industry_sort_order >> 1) { tron@4282: default: NOT_REACHED(); tron@4282: case 0: /* Sort by Name (handled later) */ truelight@0: r = 0; tron@4282: break; tron@4282: tron@4282: case 1: /* Sort by Type */ tron@4282: r = i->type - j->type; tron@4282: break; tron@4282: tron@4282: case 2: /* Sort by Production */ celestar@9911: if (ind_i->produced_cargo[0] == CT_INVALID) { celestar@9911: r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1); tron@4282: } else { celestar@9911: if (ind_j->produced_cargo[0] == CT_INVALID) { tron@4282: r = 1; tron@4282: } else { tron@4282: r = celestar@9912: (i->last_month_production[0] + i->last_month_production[1]) - celestar@9912: (j->last_month_production[0] + j->last_month_production[1]); tron@4282: } tron@4282: } tron@4282: break; tron@4282: tron@4282: case 3: /* Sort by transported fraction */ celestar@9911: if (ind_i->produced_cargo[0] == CT_INVALID) { celestar@9911: r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1); tron@4282: } else { celestar@9911: if (ind_j->produced_cargo[0] == CT_INVALID) { tron@4282: r = 1; tron@4282: } else { tron@4282: int pi; tron@4282: int pj; tron@4282: celestar@9912: pi = i->last_month_pct_transported[0] * 100 >> 8; celestar@9911: if (ind_i->produced_cargo[1] != CT_INVALID) { celestar@9912: int p = i->last_month_pct_transported[1] * 100 >> 8; tron@4282: if (p < pi) pi = p; tron@4282: } tron@4282: celestar@9912: pj = j->last_month_pct_transported[0] * 100 >> 8; celestar@9911: if (ind_j->produced_cargo[1] != CT_INVALID) { celestar@9912: int p = j->last_month_pct_transported[1] * 100 >> 8; tron@4282: if (p < pj) pj = p; tron@4282: } tron@4282: tron@4282: r = pi - pj; tron@4282: } tron@4282: } tron@4282: break; truelight@0: } truelight@0: belugas@6527: /* default to string sorting if they are otherwise equal */ truelight@0: if (r == 0) { tron@4282: char buf1[96]; tron@4282: ludde@2070: SetDParam(0, i->town->index); Darkvater@4912: GetString(buf1, STR_TOWN, lastof(buf1)); truelight@0: tron@4277: if (j != _last_industry) { tron@4277: _last_industry = j; ludde@2070: SetDParam(0, j->town->index); Darkvater@4912: GetString(_bufcache, STR_TOWN, lastof(_bufcache)); truelight@0: } truelight@0: r = strcmp(buf1, _bufcache); truelight@0: } truelight@193: truelight@193: if (_industry_sort_order & 1) r = -r; truelight@0: return r; truelight@0: } truelight@0: rubidium@6526: /** rubidium@6526: * Makes a sorted industry list. rubidium@6526: * When there are no industries, the list has to be made. This so when one rubidium@6526: * starts a new game without industries after playing a game with industries rubidium@6526: * the list is not populated with invalid industries from the previous game. rubidium@6526: */ celestar@9895: static void MakeSortedIndustryList() truelight@0: { tron@4277: const Industry* i; truelight@919: int n = 0; truelight@919: truelight@919: /* Create array for sorting */ KUDr@5860: _industry_sort = ReallocT(_industry_sort, GetMaxIndustryIndex() + 1); Darkvater@5568: if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list"); truelight@0: rubidium@6526: /* Don't attempt a sort if there are no industries */ rubidium@6526: if (GetNumIndustries() != 0) { rubidium@6526: FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i; rubidium@6526: qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter); rubidium@6526: } truelight@4346: truelight@0: _num_industry_sort = n; tron@4277: _last_industry = NULL; // used for "cache" truelight@0: Darkvater@5568: DEBUG(misc, 3, "Resorting industries list"); truelight@0: } truelight@0: truelight@0: truelight@0: static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) truelight@0: { tron@2951: switch (e->event) { truelight@0: case WE_PAINT: { truelight@0: int n; truelight@0: uint p; truelight@0: static const uint16 _indicator_positions[4] = {88, 187, 284, 387}; truelight@0: truelight@0: if (_industry_sort_dirty) { truelight@0: _industry_sort_dirty = false; truelight@0: MakeSortedIndustryList(); truelight@0: } truelight@0: bjarni@1666: SetVScrollCount(w, _num_industry_sort); truelight@0: truelight@0: DrawWindowWidgets(w); celestar@9910: DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order >> 1], 15, 0x10); truelight@0: truelight@0: p = w->vscroll.pos; truelight@0: n = 0; truelight@0: truelight@0: while (p < _num_industry_sort) { tron@4277: const Industry* i = _industry_sort[p]; celestar@9911: const IndustrySpec *ind = GetIndustrySpec(i->type); tron@2989: ludde@2070: SetDParam(0, i->index); celestar@9911: if (ind->produced_cargo[0] != CT_INVALID) { celestar@9911: SetDParam(1, ind->produced_cargo[0]); celestar@9912: SetDParam(2, i->last_month_production[0]); truelight@193: celestar@9911: if (ind->produced_cargo[1] != CT_INVALID) { celestar@9911: SetDParam(3, ind->produced_cargo[1]); celestar@9912: SetDParam(4, i->last_month_production[1]); celestar@9912: SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8); celestar@9912: SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8); celestar@9910: DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0); truelight@0: } else { celestar@9912: SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8); celestar@9910: DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0); truelight@0: } truelight@0: } else { celestar@9910: DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); truelight@0: } truelight@0: p++; tron@2951: if (++n == w->vscroll.cap) break; truelight@0: } truelight@0: } break; truelight@0: truelight@0: case WE_CLICK: belugas@4634: switch (e->we.click.widget) { darkvater@758: case 3: { celestar@9910: _industry_sort_order = _industry_sort_order == 0 ? 1 : 0; truelight@0: _industry_sort_dirty = true; truelight@0: SetWindowDirty(w); truelight@0: } break; truelight@0: darkvater@758: case 4: { celestar@9910: _industry_sort_order = _industry_sort_order == 2 ? 3 : 2; truelight@0: _industry_sort_dirty = true; truelight@0: SetWindowDirty(w); truelight@0: } break; truelight@0: darkvater@758: case 5: { celestar@9910: _industry_sort_order = _industry_sort_order == 4 ? 5 : 4; truelight@0: _industry_sort_dirty = true; truelight@0: SetWindowDirty(w); truelight@0: } break; truelight@0: darkvater@758: case 6: { celestar@9910: _industry_sort_order = _industry_sort_order == 6 ? 7 : 6; truelight@0: _industry_sort_dirty = true; truelight@0: SetWindowDirty(w); truelight@0: } break; truelight@193: darkvater@758: case 8: { belugas@4634: int y = (e->we.click.pt.y - 28) / 10; truelight@821: uint16 p; truelight@0: tron@2989: if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) return; truelight@0: p = y + w->vscroll.pos; truelight@0: if (p < _num_industry_sort) { tron@4277: ScrollMainWindowToTile(_industry_sort[p]->xy); truelight@0: } truelight@0: } break; truelight@0: } truelight@0: break; truelight@0: truelight@0: case WE_4: truelight@0: SetWindowDirty(w); truelight@0: break; truelight@867: truelight@867: case WE_RESIZE: belugas@4634: w->vscroll.cap += e->we.sizing.diff.y / 10; truelight@867: break; truelight@193: } truelight@0: } truelight@0: truelight@0: truelight@0: /* Industry List */ truelight@0: static const WindowDesc _industry_directory_desc = { Darkvater@5070: WDP_AUTO, WDP_AUTO, 508, 190, rubidium@6144: WC_INDUSTRY_DIRECTORY, WC_NONE, truelight@867: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, truelight@0: _industry_directory_widgets, truelight@0: IndustryDirectoryWndProc truelight@0: }; truelight@0: truelight@0: celestar@9895: void ShowIndustryDirectory() truelight@0: { belugas@4171: Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0); truelight@0: tron@2989: if (w != NULL) { truelight@0: w->vscroll.cap = 16; truelight@867: w->resize.height = w->height - 6 * 10; // minimum 10 items truelight@867: w->resize.step_height = 10; truelight@0: SetWindowDirty(w); truelight@0: } truelight@0: }