11use std:: ffi:: { CStr , CString } ;
22
3+ use log:: warn;
34use p3_api:: {
45 data:: { ddraw_set_constant_color, ui_render_text_at} ,
56 game_world:: GAME_WORLD_PTR ,
67 missions:: alderman_missions:: { AldermanMissionDataPtr , FoundTownPtr } ,
8+ operations:: OPERATIONS_PTR ,
79 scheduled_tasks:: { scheduled_task:: ScheduledTaskData , SCHEDULED_TASKS_PTR } ,
810 ui:: {
911 font:: { self , get_normal_font} ,
@@ -16,13 +18,18 @@ static TASK_RESCHEDULING_IN: &CStr = c"Rescheduling in";
1618static TASK_RESCHEDULES_REMAINING : & CStr = c"Reschedule Counter" ;
1719static TOWN : & CStr = c"Town" ;
1820static EFFECTIVE_PRODUCTION : & CStr = c"Effective Production" ;
21+ static INEFFECTIVE_PRODUCTION : & CStr = c"Ineffective Production" ;
1922
2023pub ( crate ) unsafe fn draw_page ( window : UITownHallWindowPtr ) {
2124 let next_mission_index = window. get_next_mission_index ( ) ;
2225 if next_mission_index == 0 {
2326 return ;
2427 }
2528
29+ if SCHEDULED_TASKS_PTR . get_merchant_alderman_mission_task_index ( OPERATIONS_PTR . get_player_merchant_index ( ) ) != -1 {
30+ return ;
31+ }
32+
2633 let selected_mission_index = window. get_selected_alderman_mission_index ( ) ;
2734 if selected_mission_index == 0xff {
2835 return ;
@@ -72,6 +79,7 @@ pub(crate) unsafe fn draw_page(window: UITownHallWindowPtr) {
7279
7380unsafe fn render_aldermans_office_modifications_found_town ( window : UITownHallWindowPtr , data : & FoundTownPtr ) {
7481 let town = data. get_town ( ) ;
82+ let effective_raw = data. get_production_effective_raw ( ) ;
7583 let effective = data. get_production_effective ( ) ;
7684 let x = window. get_x ( ) ;
7785 let mut y = window. get_y ( ) + 100 ;
@@ -88,10 +96,48 @@ unsafe fn render_aldermans_office_modifications_found_town(window: UITownHallWin
8896 font:: ddraw_set_text_mode ( font:: TextMode :: AlignRight ) ;
8997 let mut effective_string = String :: new ( ) ;
9098 for facility in effective {
91- effective_string. push_str ( & format ! ( "{facility:?}, " ) ) ;
99+ match facility {
100+ p3_api:: data:: enums:: FacilityId :: Militia => warn ! ( "Unexpected facility {facility:?}" ) ,
101+ p3_api:: data:: enums:: FacilityId :: Shipyard => warn ! ( "Unexpected facility {facility:?}" ) ,
102+ p3_api:: data:: enums:: FacilityId :: Construction => warn ! ( "Unexpected facility {facility:?}" ) ,
103+ p3_api:: data:: enums:: FacilityId :: Weaponsmith => warn ! ( "Unexpected facility {facility:?}" ) ,
104+ p3_api:: data:: enums:: FacilityId :: HuntingLodge => effective_string. push_str ( "Skins, " ) ,
105+ p3_api:: data:: enums:: FacilityId :: FishermansHouse => {
106+ if effective_raw & 0x20000 != 0 {
107+ effective_string. push_str ( "Whale Oil, " )
108+ } else {
109+ effective_string. push_str ( "Fish, " )
110+ }
111+ }
112+ p3_api:: data:: enums:: FacilityId :: Brewery => effective_string. push_str ( "Beer, " ) ,
113+ p3_api:: data:: enums:: FacilityId :: Workshop => effective_string. push_str ( "Iron Goods, " ) ,
114+ p3_api:: data:: enums:: FacilityId :: Apiary => effective_string. push_str ( "Honey, " ) ,
115+ p3_api:: data:: enums:: FacilityId :: GrainFarm => effective_string. push_str ( "Grain, " ) ,
116+ p3_api:: data:: enums:: FacilityId :: CattleFarm => effective_string. push_str ( "Meat, Leather, " ) ,
117+ p3_api:: data:: enums:: FacilityId :: Sawmill => effective_string. push_str ( "Timber, " ) ,
118+ p3_api:: data:: enums:: FacilityId :: WeavingMill => effective_string. push_str ( "Cloth, " ) ,
119+ p3_api:: data:: enums:: FacilityId :: Saltery => effective_string. push_str ( "Salt, " ) ,
120+ p3_api:: data:: enums:: FacilityId :: Ironsmelter => effective_string. push_str ( "Pig Iron, " ) ,
121+ p3_api:: data:: enums:: FacilityId :: SheepFarm => effective_string. push_str ( "Wool, " ) ,
122+ p3_api:: data:: enums:: FacilityId :: Vineyard => effective_string. push_str ( "Wine, " ) ,
123+ p3_api:: data:: enums:: FacilityId :: Pottery => effective_string. push_str ( "Pottery, " ) ,
124+ p3_api:: data:: enums:: FacilityId :: Brickworks => effective_string. push_str ( "Bricks, " ) ,
125+ p3_api:: data:: enums:: FacilityId :: Pitchmaker => effective_string. push_str ( "Pitch, " ) ,
126+ p3_api:: data:: enums:: FacilityId :: HempFarm => effective_string. push_str ( "Hemp, " ) ,
127+ }
92128 }
93129 effective_string. pop ( ) ;
94130 effective_string. pop ( ) ;
95131 let effective_cstring = CString :: new ( effective_string) . unwrap ( ) ;
96132 ui_render_text_at ( x + COL_OFFSETS [ 1 ] , y, effective_cstring. to_bytes ( ) ) ;
133+ y += 20 ;
134+
135+ font:: ddraw_set_text_mode ( font:: TextMode :: AlignLeft ) ;
136+ ui_render_text_at ( x + COL_OFFSETS [ 0 ] , y, INEFFECTIVE_PRODUCTION . to_bytes ( ) ) ;
137+
138+ font:: ddraw_set_text_mode ( font:: TextMode :: AlignRight ) ;
139+ let mut ineffective_string = String :: new ( ) ;
140+ if effective_raw & 0x20000 != 0 {
141+ ineffective_string. push_str ( "Fish" )
142+ }
97143}
0 commit comments