@@ -41,16 +41,16 @@ void GetBuildingSize(
4141 int16_t type,
4242 int16_t subtype,
4343 int16_t custom,
44- int16_t &x_min ,
45- int16_t &y_min ,
46- int16_t &x_max ,
47- int16_t &y_max
44+ int16_t &rad_x_low ,
45+ int16_t &rad_y_low ,
46+ int16_t &rad_x_high ,
47+ int16_t &rad_y_high
4848)
4949{
50- x_min = 0 ;
51- y_min = 0 ;
52- x_max = 0 ;
53- y_max = 0 ;
50+ rad_x_low = 0 ;
51+ rad_y_low = 0 ;
52+ rad_x_high = 0 ;
53+ rad_y_high = 0 ;
5454 df::building_def* customBuilding = 0 ;
5555 switch (type)
5656 {
@@ -65,30 +65,32 @@ void GetBuildingSize(
6565 case building_type::AxleHorizontal:
6666 case building_type::WaterWheel:
6767 case building_type::Rollers:
68+ {
6869 bool widthOdd = world->building_width % 2 ;
69- x_min = world->building_width / 2 ;
70+ rad_x_low = world->building_width / 2 ;
7071 if (widthOdd)
71- x_max = world->building_width / 2 ;
72+ rad_x_high = world->building_width / 2 ;
7273 else
73- x_max = (world->building_width / 2 ) - 1 ;
74+ rad_x_high = (world->building_width / 2 ) - 1 ;
7475 bool heightOdd = world->building_width % 2 ;
75- y_min = world->building_height / 2 ;
76+ rad_y_low = world->building_height / 2 ;
7677 if (widthOdd)
77- y_max = world->building_height / 2 ;
78+ rad_y_high = world->building_height / 2 ;
7879 else
79- y_max = (world->building_height / 2 ) - 1 ;
80+ rad_y_high = (world->building_height / 2 ) - 1 ;
81+ }
8082 return ;
8183 case building_type::Furnace:
8284 if (subtype != furnace_type::Custom)
8385 {
84- x_min = y_min = x_max = y_max = 1 ;
86+ rad_x_low = rad_y_low = rad_x_high = rad_y_high = 1 ;
8587 return ;
8688 }
87- customBuilding = binsearch_in_vector ( world->raws .buildings .furnaces , custom) ;
89+ customBuilding = world->raws .buildings .furnaces [ custom] ;
8890 break ;
8991 case building_type::TradeDepot:
9092 case building_type::Shop:
91- x_min = y_min = x_max = y_max = 2 ;
93+ rad_x_low = rad_y_low = rad_x_high = rad_y_high = 2 ;
9294 return ;
9395 case building_type::Workshop:
9496 switch (subtype)
@@ -112,14 +114,14 @@ void GetBuildingSize(
112114 case workshop_type::Kitchen:
113115 case workshop_type::Ashery:
114116 case workshop_type::Dyers:
115- x_min = y_min = x_max = y_max = 1 ;
117+ rad_x_low = rad_y_low = rad_x_high = rad_y_high = 1 ;
116118 return ;
117119 case workshop_type::Siege:
118120 case workshop_type::Kennels:
119- x_min = y_min = x_max = y_max = 2 ;
121+ rad_x_low = rad_y_low = rad_x_high = rad_y_high = 2 ;
120122 return ;
121123 case workshop_type::Custom:
122- customBuilding = binsearch_in_vector ( world->raws .buildings .workshops , custom) ;
124+ customBuilding = world->raws .buildings .workshops [ custom] ;
123125 break ;
124126 default :
125127 return ;
@@ -128,17 +130,17 @@ void GetBuildingSize(
128130 case building_type::SiegeEngine:
129131 case building_type::Wagon:
130132 case building_type::Windmill:
131- x_min = y_min = x_max = y_max = 1 ;
133+ rad_x_low = rad_y_low = rad_x_high = rad_y_high = 1 ;
132134 return ;
133135 default :
134136 return ;
135137 }
136138 if (customBuilding)
137139 {
138- x_min = customBuilding->workloc_x ;
139- y_min = customBuilding->workloc_y ;
140- x_max = customBuilding->dim_x - x_min - 1 ;
141- y_max = customBuilding->dim_y - y_min - 1 ;
140+ rad_x_low = customBuilding->workloc_x ;
141+ rad_y_low = customBuilding->workloc_y ;
142+ rad_x_high = customBuilding->dim_x - rad_x_low - 1 ;
143+ rad_y_high = customBuilding->dim_y - rad_y_low - 1 ;
142144 return ;
143145 }
144146}
@@ -276,6 +278,19 @@ void CopyBuildMenu(DwarfControl::SidebarState * out)
276278 send_choice->set_num_candidates (choice->getNumCandidates ());
277279 send_choice->set_used_count (choice->getUsedCount ());
278280 }
281+ int16_t x_low, y_low, x_high, y_high;
282+ GetBuildingSize (build_selector->building_type , build_selector->building_subtype , build_selector->custom_type , x_low, y_low, x_high, y_high);
283+ send_selector->set_radius_x_low (x_low);
284+ send_selector->set_radius_y_low (y_low);
285+ send_selector->set_radius_x_high (x_high);
286+ send_selector->set_radius_y_high (y_high);
287+ if (build_selector->stage >= 1 )
288+ {
289+ auto send_cursor = send_selector->mutable_cursor ();
290+ send_cursor->set_x (cursor->x );
291+ send_cursor->set_y (cursor->y );
292+ send_cursor->set_z (cursor->z );
293+ }
279294 }
280295}
281296
@@ -428,12 +443,28 @@ command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::Si
428443 case ui_sidebar_mode::Build:
429444 if (in->has_action ())
430445 {
446+ int index = 0 ;
431447 if (in->has_menu_index ())
432- df::global::ui_sidebar_menus->building .cursor = in->menu_index ();
433- else
434- df::global::ui_sidebar_menus->building .cursor = 0 ;
435- break ;
448+ index = in->menu_index ();
449+ if (ui_build_selector->building_type == -1 )
450+ df::global::ui_sidebar_menus->building .cursor = index;
451+ if (ui_build_selector->stage == 2 )
452+ {
453+ ui_build_selector->sel_index = index;
454+ }
455+ }
456+ if (ui_build_selector->stage == 1 )
457+ {
458+ if (in->has_selection_coord ())
459+ {
460+ df::global::cursor->x = in->selection_coord ().x ();
461+ df::global::cursor->y = in->selection_coord ().y ();
462+ df::global::cursor->z = in->selection_coord ().z ();
463+ getCurViewscreen ()->feed_key (interface_key::CURSOR_LEFT );
464+ getCurViewscreen ()->feed_key (interface_key::CURSOR_RIGHT );
465+ }
436466 }
467+ break ;
437468 default :
438469 break ;
439470 }
0 commit comments