167 this->FindWindowPlacementAndResize(desc); |
167 this->FindWindowPlacementAndResize(desc); |
168 } |
168 } |
169 |
169 |
170 virtual void OnPaint() |
170 virtual void OnPaint() |
171 { |
171 { |
172 PlayerID player = (PlayerID)this->window_number; |
172 CompanyID company = (CompanyID)this->window_number; |
173 const Player *p = GetPlayer(player); |
173 const Company *c = GetCompany(company); |
174 |
174 |
175 /* Recheck the size of the window as it might need to be resized due to the local player changing */ |
175 /* Recheck the size of the window as it might need to be resized due to the local company changing */ |
176 int new_height = ((player != _local_player) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END); |
176 int new_height = ((company != _local_company) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END); |
177 if (this->height != new_height) { |
177 if (this->height != new_height) { |
178 /* Make window dirty before and after resizing */ |
178 /* Make window dirty before and after resizing */ |
179 this->SetDirty(); |
179 this->SetDirty(); |
180 this->height = new_height; |
180 this->height = new_height; |
181 this->SetDirty(); |
181 this->SetDirty(); |
182 |
182 |
183 this->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player); |
183 this->SetWidgetHiddenState(CFW_WIDGET_INCREASE_LOAN, company != _local_company); |
184 this->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN, player != _local_player); |
184 this->SetWidgetHiddenState(CFW_WIDGET_REPAY_LOAN, company != _local_company); |
185 } |
185 } |
186 |
186 |
187 /* Borrow button only shows when there is any more money to loan */ |
187 /* Borrow button only shows when there is any more money to loan */ |
188 this->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan); |
188 this->SetWidgetDisabledState(CFW_WIDGET_INCREASE_LOAN, c->current_loan == _economy.max_loan); |
189 |
189 |
190 /* Repay button only shows when there is any more money to repay */ |
190 /* Repay button only shows when there is any more money to repay */ |
191 this->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0); |
191 this->SetWidgetDisabledState(CFW_WIDGET_REPAY_LOAN, company != _local_company || c->current_loan == 0); |
192 |
192 |
193 SetDParam(0, p->index); |
193 SetDParam(0, c->index); |
194 SetDParam(1, p->index); |
194 SetDParam(1, c->index); |
195 SetDParam(2, LOAN_INTERVAL); |
195 SetDParam(2, LOAN_INTERVAL); |
196 this->DrawWidgets(); |
196 this->DrawWidgets(); |
197 |
197 |
198 DrawPlayerEconomyStats(p, this->small); |
198 DrawCompanyEconomyStats(c, this->small); |
199 } |
199 } |
200 |
200 |
201 virtual void OnClick(Point pt, int widget) |
201 virtual void OnClick(Point pt, int widget) |
202 { |
202 { |
203 switch (widget) { |
203 switch (widget) { |
204 case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */ |
204 case CFW_WIDGET_TOGGLE_SIZE: {/* toggle size */ |
205 bool new_mode = !this->small; |
205 bool new_mode = !this->small; |
206 bool stickied = !!(this->flags4 & WF_STICKY); |
206 bool stickied = !!(this->flags4 & WF_STICKY); |
207 int oldtop = this->top; ///< current top position of the window before closing it |
207 int oldtop = this->top; ///< current top position of the window before closing it |
208 int oldleft = this->left; ///< current left position of the window before closing it |
208 int oldleft = this->left; ///< current left position of the window before closing it |
209 PlayerID player = (PlayerID)this->window_number; |
209 CompanyID company = (CompanyID)this->window_number; |
210 |
210 |
211 delete this; |
211 delete this; |
212 /* Open up the (toggled size) Finance window at the same position as the previous */ |
212 /* Open up the (toggled size) Finance window at the same position as the previous */ |
213 DoShowPlayerFinances(player, new_mode, stickied, oldtop, oldleft); |
213 DoShowCompanyFinances(company, new_mode, stickied, oldtop, oldleft); |
214 } |
214 } |
215 break; |
215 break; |
216 |
216 |
217 case PFW_WIDGET_INCREASE_LOAN: /* increase loan */ |
217 case CFW_WIDGET_INCREASE_LOAN: /* increase loan */ |
218 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
218 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
219 break; |
219 break; |
220 |
220 |
221 case PFW_WIDGET_REPAY_LOAN: /* repay loan */ |
221 case CFW_WIDGET_REPAY_LOAN: /* repay loan */ |
222 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
222 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
223 break; |
223 break; |
224 } |
224 } |
225 } |
225 } |
226 }; |
226 }; |
227 |
227 |
228 static const WindowDesc _player_finances_desc = { |
228 static const WindowDesc _company_finances_desc = { |
229 WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END, |
229 WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END, |
230 WC_FINANCES, WC_NONE, |
230 WC_FINANCES, WC_NONE, |
231 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
231 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
232 _player_finances_widgets, |
232 _company_finances_widgets, |
233 }; |
233 }; |
234 |
234 |
235 static const WindowDesc _player_finances_small_desc = { |
235 static const WindowDesc _company_finances_small_desc = { |
236 WDP_AUTO, WDP_AUTO, 280, 60, 280, 60, |
236 WDP_AUTO, WDP_AUTO, 280, 60, 280, 60, |
237 WC_FINANCES, WC_NONE, |
237 WC_FINANCES, WC_NONE, |
238 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
238 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
239 _player_finances_small_widgets, |
239 _company_finances_small_widgets, |
240 }; |
240 }; |
241 |
241 |
242 /** |
242 /** |
243 * Open the small/large finance window of the player |
243 * Open the small/large finance window of the company |
244 * |
244 * |
245 * @param player the player who's finances are requested to be seen |
245 * @param company the company who's finances are requested to be seen |
246 * @param show_small show large or small version opf the window |
246 * @param show_small show large or small version opf the window |
247 * @param show_stickied previous "stickyness" of the window |
247 * @param show_stickied previous "stickyness" of the window |
248 * @param top previous top position of the window |
248 * @param top previous top position of the window |
249 * @param left previous left position of the window |
249 * @param left previous left position of the window |
250 * |
250 * |
251 * @pre is player a valid player |
251 * @pre is company a valid company |
252 */ |
252 */ |
253 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left) |
253 static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top, int left) |
254 { |
254 { |
255 if (!IsValidPlayerID(player)) return; |
255 if (!IsValidCompanyID(company)) return; |
256 |
256 |
257 if (BringWindowToFrontById(WC_FINANCES, player)) return; |
257 if (BringWindowToFrontById(WC_FINANCES, company)) return; |
258 new PlayerFinancesWindow(show_small ? &_player_finances_small_desc : &_player_finances_desc, player, show_small, show_stickied, top, left); |
258 new CompanyFinancesWindow(show_small ? &_company_finances_small_desc : &_company_finances_desc, company, show_small, show_stickied, top, left); |
259 } |
259 } |
260 |
260 |
261 void ShowPlayerFinances(PlayerID player) |
261 void ShowCompanyFinances(CompanyID company) |
262 { |
262 { |
263 DoShowPlayerFinances(player, false, false); |
263 DoShowCompanyFinances(company, false, false); |
264 } |
264 } |
265 |
265 |
266 /* List of colours for the livery window */ |
266 /* List of colours for the livery window */ |
267 static const StringID _colour_dropdown[] = { |
267 static const StringID _colour_dropdown[] = { |
268 STR_00D1_DARK_BLUE, |
268 STR_00D1_DARK_BLUE, |
539 { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 275, 399, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
539 { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 275, 399, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
540 { WWT_MATRIX, RESIZE_NONE, COLOUR_GREY, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
540 { WWT_MATRIX, RESIZE_NONE, COLOUR_GREY, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
541 { WIDGETS_END }, |
541 { WIDGETS_END }, |
542 }; |
542 }; |
543 |
543 |
544 static const WindowDesc _select_player_livery_desc = { |
544 static const WindowDesc _select_company_livery_desc = { |
545 WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14, |
545 WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14, |
546 WC_PLAYER_COLOR, WC_NONE, |
546 WC_COMPANY_COLOR, WC_NONE, |
547 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
547 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
548 _select_player_livery_widgets, |
548 _select_company_livery_widgets, |
549 }; |
549 }; |
550 |
550 |
551 /** |
551 /** |
552 * Draws the face of a player. |
552 * Draws the face of a company manager's face. |
553 * @param pf the player's face |
553 * @param cmf the company manager's face |
554 * @param color the (background) color of the gradient |
554 * @param color the (background) color of the gradient |
555 * @param x x-position to draw the face |
555 * @param x x-position to draw the face |
556 * @param y y-position to draw the face |
556 * @param y y-position to draw the face |
557 */ |
557 */ |
558 void DrawPlayerFace(PlayerFace pf, int color, int x, int y) |
558 void DrawCompanyManagerFace(CompanyManagerFace cmf, int color, int x, int y) |
559 { |
559 { |
560 GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM); |
560 GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM); |
561 |
561 |
562 bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0; |
562 bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0; |
563 bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0; |
563 bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0; |
564 bool has_glasses = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0; |
564 bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0; |
565 SpriteID pal; |
565 SpriteID pal; |
566 |
566 |
567 /* Modify eye colour palette only if 2 or more valid values exist */ |
567 /* Modify eye colour palette only if 2 or more valid values exist */ |
568 if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) { |
568 if (_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) { |
569 pal = PAL_NONE; |
569 pal = PAL_NONE; |
570 } else { |
570 } else { |
571 switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) { |
571 switch (GetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge)) { |
572 default: NOT_REACHED(); |
572 default: NOT_REACHED(); |
573 case 0: pal = PALETTE_TO_BROWN; break; |
573 case 0: pal = PALETTE_TO_BROWN; break; |
574 case 1: pal = PALETTE_TO_BLUE; break; |
574 case 1: pal = PALETTE_TO_BLUE; break; |
575 case 2: pal = PALETTE_TO_GREEN; break; |
575 case 2: pal = PALETTE_TO_GREEN; break; |
576 } |
576 } |
577 } |
577 } |
578 |
578 |
579 /* Draw the gradient (background) */ |
579 /* Draw the gradient (background) */ |
580 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y); |
580 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y); |
581 |
581 |
582 for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) { |
582 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) { |
583 switch (pfv) { |
583 switch (cmfv) { |
584 case PFV_MOUSTACHE: if (!has_moustache) continue; break; |
584 case CMFV_MOUSTACHE: if (!has_moustache) continue; break; |
585 case PFV_LIPS: /* FALL THROUGH */ |
585 case CMFV_LIPS: /* FALL THROUGH */ |
586 case PFV_NOSE: if (has_moustache) continue; break; |
586 case CMFV_NOSE: if (has_moustache) continue; break; |
587 case PFV_TIE_EARRING: if (!has_tie_earring) continue; break; |
587 case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break; |
588 case PFV_GLASSES: if (!has_glasses) continue; break; |
588 case CMFV_GLASSES: if (!has_glasses) continue; break; |
589 default: break; |
589 default: break; |
590 } |
590 } |
591 DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y); |
591 DrawSprite(GetCompanyManagerFaceSprite(cmf, cmfv, ge), (cmfv == CMFV_EYEBROWS) ? pal : PAL_NONE, x, y); |
592 } |
592 } |
593 } |
593 } |
594 |
594 |
595 /** Widget description for the normal/simple player face selection dialog */ |
595 /** Widget description for the normal/simple company manager face selection dialog */ |
596 static const Widget _select_player_face_widgets[] = { |
596 static const Widget _select_company_manager_face_widgets[] = { |
597 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX |
597 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX |
598 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION |
598 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION |
599 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL |
599 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL |
600 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 189, 14, 150, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE |
600 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 189, 14, 150, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE |
601 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL |
601 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL |
602 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT |
602 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT |
603 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE |
603 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE |
604 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE |
604 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE |
605 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE |
605 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE |
606 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
606 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
607 { WIDGETS_END}, |
607 { WIDGETS_END}, |
608 }; |
608 }; |
609 |
609 |
610 /** Widget description for the advanced player face selection dialog */ |
610 /** Widget description for the advanced company manager face selection dialog */ |
611 static const Widget _select_player_face_adv_widgets[] = { |
611 static const Widget _select_company_manager_face_adv_widgets[] = { |
612 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX |
612 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX |
613 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION |
613 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION |
614 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL |
614 { WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL |
615 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 219, 14, 207, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE |
615 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 219, 14, 207, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE |
616 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL |
616 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL |
617 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT |
617 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT |
618 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE |
618 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE |
619 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE |
619 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE |
620 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE |
620 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE |
621 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
621 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
622 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // PFW_WIDGET_LOAD |
622 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // SCMFW_WIDGET_LOAD |
623 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // PFW_WIDGET_FACECODE |
623 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // SCMFW_WIDGET_FACECODE |
624 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // PFW_WIDGET_SAVE |
624 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // SCMFW_WIDGET_SAVE |
625 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // PFW_WIDGET_ETHNICITY_EUR |
625 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // SCMFW_WIDGET_ETHNICITY_EUR |
626 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // PFW_WIDGET_ETHNICITY_AFR |
626 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // SCMFW_WIDGET_ETHNICITY_AFR |
627 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // PFW_WIDGET_HAS_MOUSTACHE_EARRING |
627 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // SCMFW_WIDGET_HAS_MOUSTACHE_EARRING |
628 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // PFW_WIDGET_HAS_GLASSES |
628 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // SCMFW_WIDGET_HAS_GLASSES |
629 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_L |
629 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_L |
630 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR |
630 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR |
631 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_R |
631 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_R |
632 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_L |
632 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_L |
633 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN |
633 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN |
634 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_R |
634 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_R |
635 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_L |
635 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_L |
636 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS |
636 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS |
637 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_R |
637 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_R |
638 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_L |
638 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_L |
639 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE |
639 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE |
640 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_R |
640 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_R |
641 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_L |
641 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_L |
642 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE |
642 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE |
643 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_R |
643 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_R |
644 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_L |
644 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_L |
645 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR |
645 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR |
646 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_R |
646 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_R |
647 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_L |
647 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_L |
648 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET |
648 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET |
649 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_R |
649 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_R |
650 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_L |
650 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_L |
651 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR |
651 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR |
652 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_R |
652 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_R |
653 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_L |
653 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_L |
654 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING |
654 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING |
655 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_R |
655 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_R |
656 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_L |
656 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_L |
657 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES |
657 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES |
658 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_R |
658 { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_R |
659 { WIDGETS_END}, |
659 { WIDGETS_END}, |
660 }; |
660 }; |
661 |
661 |
662 class SelectPlayerFaceWindow : public Window |
662 class SelectCompanyManagerFaceWindow : public Window |
663 { |
663 { |
664 PlayerFace face; // player face bits |
664 CompanyManagerFace face; ///< company manager face bits |
665 bool advanced; // advance player face selection window |
665 bool advanced; ///< advanced company manager face selection window |
666 |
666 |
667 GenderEthnicity ge; |
667 GenderEthnicity ge; |
668 bool is_female; |
668 bool is_female; |
669 bool is_moust_male; |
669 bool is_moust_male; |
670 |
670 |
671 /** |
671 /** |
672 * Names of the widgets. Keep them in the same order as in the widget array. |
672 * Names of the widgets. Keep them in the same order as in the widget array. |
673 * Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R, |
673 * Do not change the order of the widgets from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R, |
674 * this order is needed for the WE_CLICK event of DrawFaceStringLabel(). |
674 * this order is needed for the WE_CLICK event of DrawFaceStringLabel(). |
675 */ |
675 */ |
676 enum PlayerFaceWindowWidgets { |
676 enum SelectCompanyManagerFaceWidgets { |
677 PFW_WIDGET_CLOSEBOX = 0, |
677 SCMFW_WIDGET_CLOSEBOX = 0, |
678 PFW_WIDGET_CAPTION, |
678 SCMFW_WIDGET_CAPTION, |
679 PFW_WIDGET_TOGGLE_LARGE_SMALL, |
679 SCMFW_WIDGET_TOGGLE_LARGE_SMALL, |
680 PFW_WIDGET_SELECT_FACE, |
680 SCMFW_WIDGET_SELECT_FACE, |
681 PFW_WIDGET_CANCEL, |
681 SCMFW_WIDGET_CANCEL, |
682 PFW_WIDGET_ACCEPT, |
682 SCMFW_WIDGET_ACCEPT, |
683 PFW_WIDGET_MALE, |
683 SCMFW_WIDGET_MALE, |
684 PFW_WIDGET_FEMALE, |
684 SCMFW_WIDGET_FEMALE, |
685 PFW_WIDGET_RANDOM_NEW_FACE, |
685 SCMFW_WIDGET_RANDOM_NEW_FACE, |
686 PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON, |
686 SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON, |
687 /* from here is the advanced player face selection window */ |
687 /* from here is the advanced company manager face selection window */ |
688 PFW_WIDGET_LOAD, |
688 SCMFW_WIDGET_LOAD, |
689 PFW_WIDGET_FACECODE, |
689 SCMFW_WIDGET_FACECODE, |
690 PFW_WIDGET_SAVE, |
690 SCMFW_WIDGET_SAVE, |
691 PFW_WIDGET_ETHNICITY_EUR, |
691 SCMFW_WIDGET_ETHNICITY_EUR, |
692 PFW_WIDGET_ETHNICITY_AFR, |
692 SCMFW_WIDGET_ETHNICITY_AFR, |
693 PFW_WIDGET_HAS_MOUSTACHE_EARRING, |
693 SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, |
694 PFW_WIDGET_HAS_GLASSES, |
694 SCMFW_WIDGET_HAS_GLASSES, |
695 PFW_WIDGET_EYECOLOUR_L, |
695 SCMFW_WIDGET_EYECOLOUR_L, |
696 PFW_WIDGET_EYECOLOUR, |
696 SCMFW_WIDGET_EYECOLOUR, |
697 PFW_WIDGET_EYECOLOUR_R, |
697 SCMFW_WIDGET_EYECOLOUR_R, |
698 PFW_WIDGET_CHIN_L, |
698 SCMFW_WIDGET_CHIN_L, |
699 PFW_WIDGET_CHIN, |
699 SCMFW_WIDGET_CHIN, |
700 PFW_WIDGET_CHIN_R, |
700 SCMFW_WIDGET_CHIN_R, |
701 PFW_WIDGET_EYEBROWS_L, |
701 SCMFW_WIDGET_EYEBROWS_L, |
702 PFW_WIDGET_EYEBROWS, |
702 SCMFW_WIDGET_EYEBROWS, |
703 PFW_WIDGET_EYEBROWS_R, |
703 SCMFW_WIDGET_EYEBROWS_R, |
704 PFW_WIDGET_LIPS_MOUSTACHE_L, |
704 SCMFW_WIDGET_LIPS_MOUSTACHE_L, |
705 PFW_WIDGET_LIPS_MOUSTACHE, |
705 SCMFW_WIDGET_LIPS_MOUSTACHE, |
706 PFW_WIDGET_LIPS_MOUSTACHE_R, |
706 SCMFW_WIDGET_LIPS_MOUSTACHE_R, |
707 PFW_WIDGET_NOSE_L, |
707 SCMFW_WIDGET_NOSE_L, |
708 PFW_WIDGET_NOSE, |
708 SCMFW_WIDGET_NOSE, |
709 PFW_WIDGET_NOSE_R, |
709 SCMFW_WIDGET_NOSE_R, |
710 PFW_WIDGET_HAIR_L, |
710 SCMFW_WIDGET_HAIR_L, |
711 PFW_WIDGET_HAIR, |
711 SCMFW_WIDGET_HAIR, |
712 PFW_WIDGET_HAIR_R, |
712 SCMFW_WIDGET_HAIR_R, |
713 PFW_WIDGET_JACKET_L, |
713 SCMFW_WIDGET_JACKET_L, |
714 PFW_WIDGET_JACKET, |
714 SCMFW_WIDGET_JACKET, |
715 PFW_WIDGET_JACKET_R, |
715 SCMFW_WIDGET_JACKET_R, |
716 PFW_WIDGET_COLLAR_L, |
716 SCMFW_WIDGET_COLLAR_L, |
717 PFW_WIDGET_COLLAR, |
717 SCMFW_WIDGET_COLLAR, |
718 PFW_WIDGET_COLLAR_R, |
718 SCMFW_WIDGET_COLLAR_R, |
719 PFW_WIDGET_TIE_EARRING_L, |
719 SCMFW_WIDGET_TIE_EARRING_L, |
720 PFW_WIDGET_TIE_EARRING, |
720 SCMFW_WIDGET_TIE_EARRING, |
721 PFW_WIDGET_TIE_EARRING_R, |
721 SCMFW_WIDGET_TIE_EARRING_R, |
722 PFW_WIDGET_GLASSES_L, |
722 SCMFW_WIDGET_GLASSES_L, |
723 PFW_WIDGET_GLASSES, |
723 SCMFW_WIDGET_GLASSES, |
724 PFW_WIDGET_GLASSES_R, |
724 SCMFW_WIDGET_GLASSES_R, |
725 }; |
725 }; |
726 /** |
726 /** |
727 * Draw dynamic a label to the left of the button and a value in the button |
727 * Draw dynamic a label to the left of the button and a value in the button |
728 * |
728 * |
729 * @param widget_index index of this widget in the window |
729 * @param widget_index index of this widget in the window |
779 } |
779 } |
780 |
780 |
781 virtual void OnPaint() |
781 virtual void OnPaint() |
782 { |
782 { |
783 /* lower the non-selected gender button */ |
783 /* lower the non-selected gender button */ |
784 this->SetWidgetLoweredState(PFW_WIDGET_MALE, !this->is_female); |
784 this->SetWidgetLoweredState(SCMFW_WIDGET_MALE, !this->is_female); |
785 this->SetWidgetLoweredState(PFW_WIDGET_FEMALE, this->is_female); |
785 this->SetWidgetLoweredState(SCMFW_WIDGET_FEMALE, this->is_female); |
786 |
786 |
787 /* advanced player face selection window */ |
787 /* advanced company manager face selection window */ |
788 if (this->advanced) { |
788 if (this->advanced) { |
789 /* lower the non-selected ethnicity button */ |
789 /* lower the non-selected ethnicity button */ |
790 this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK)); |
790 this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK)); |
791 this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK)); |
791 this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK)); |
792 |
792 |
793 |
793 |
794 /* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options |
794 /* Disable dynamically the widgets which CompanyManagerFaceVariable has less than 2 options |
795 * (or in other words you haven't any choice). |
795 * (or in other words you haven't any choice). |
796 * If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */ |
796 * If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */ |
797 |
797 |
798 /* Eye colour buttons */ |
798 /* Eye colour buttons */ |
799 this->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[this->ge] < 2, |
799 this->SetWidgetsDisabledState(_cmf_info[CMFV_EYE_COLOUR].valid_values[this->ge] < 2, |
800 PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END); |
800 SCMFW_WIDGET_EYECOLOUR, SCMFW_WIDGET_EYECOLOUR_L, SCMFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END); |
801 |
801 |
802 /* Chin buttons */ |
802 /* Chin buttons */ |
803 this->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[this->ge] < 2, |
803 this->SetWidgetsDisabledState(_cmf_info[CMFV_CHIN].valid_values[this->ge] < 2, |
804 PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END); |
804 SCMFW_WIDGET_CHIN, SCMFW_WIDGET_CHIN_L, SCMFW_WIDGET_CHIN_R, WIDGET_LIST_END); |
805 |
805 |
806 /* Eyebrows buttons */ |
806 /* Eyebrows buttons */ |
807 this->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[this->ge] < 2, |
807 this->SetWidgetsDisabledState(_cmf_info[CMFV_EYEBROWS].valid_values[this->ge] < 2, |
808 PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END); |
808 SCMFW_WIDGET_EYEBROWS, SCMFW_WIDGET_EYEBROWS_L, SCMFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END); |
809 |
809 |
810 /* Lips or (if it a male face with a moustache) moustache buttons */ |
810 /* Lips or (if it a male face with a moustache) moustache buttons */ |
811 this->SetWidgetsDisabledState(_pf_info[this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[this->ge] < 2, |
811 this->SetWidgetsDisabledState(_cmf_info[this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS].valid_values[this->ge] < 2, |
812 PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END); |
812 SCMFW_WIDGET_LIPS_MOUSTACHE, SCMFW_WIDGET_LIPS_MOUSTACHE_L, SCMFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END); |
813 |
813 |
814 /* Nose buttons | male faces with moustache haven't any nose options */ |
814 /* Nose buttons | male faces with moustache haven't any nose options */ |
815 this->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male, |
815 this->SetWidgetsDisabledState(_cmf_info[CMFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male, |
816 PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END); |
816 SCMFW_WIDGET_NOSE, SCMFW_WIDGET_NOSE_L, SCMFW_WIDGET_NOSE_R, WIDGET_LIST_END); |
817 |
817 |
818 /* Hair buttons */ |
818 /* Hair buttons */ |
819 this->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[this->ge] < 2, |
819 this->SetWidgetsDisabledState(_cmf_info[CMFV_HAIR].valid_values[this->ge] < 2, |
820 PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END); |
820 SCMFW_WIDGET_HAIR, SCMFW_WIDGET_HAIR_L, SCMFW_WIDGET_HAIR_R, WIDGET_LIST_END); |
821 |
821 |
822 /* Jacket buttons */ |
822 /* Jacket buttons */ |
823 this->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[this->ge] < 2, |
823 this->SetWidgetsDisabledState(_cmf_info[CMFV_JACKET].valid_values[this->ge] < 2, |
824 PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END); |
824 SCMFW_WIDGET_JACKET, SCMFW_WIDGET_JACKET_L, SCMFW_WIDGET_JACKET_R, WIDGET_LIST_END); |
825 |
825 |
826 /* Collar buttons */ |
826 /* Collar buttons */ |
827 this->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[this->ge] < 2, |
827 this->SetWidgetsDisabledState(_cmf_info[CMFV_COLLAR].valid_values[this->ge] < 2, |
828 PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END); |
828 SCMFW_WIDGET_COLLAR, SCMFW_WIDGET_COLLAR_L, SCMFW_WIDGET_COLLAR_R, WIDGET_LIST_END); |
829 |
829 |
830 /* Tie/earring buttons | female faces without earring haven't any earring options */ |
830 /* Tie/earring buttons | female faces without earring haven't any earring options */ |
831 this->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[this->ge] < 2 || |
831 this->SetWidgetsDisabledState(_cmf_info[CMFV_TIE_EARRING].valid_values[this->ge] < 2 || |
832 (this->is_female && GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge) == 0), |
832 (this->is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge) == 0), |
833 PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END); |
833 SCMFW_WIDGET_TIE_EARRING, SCMFW_WIDGET_TIE_EARRING_L, SCMFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END); |
834 |
834 |
835 /* Glasses buttons | faces without glasses haven't any glasses options */ |
835 /* Glasses buttons | faces without glasses haven't any glasses options */ |
836 this->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[this->ge] < 2 || GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge) == 0, |
836 this->SetWidgetsDisabledState(_cmf_info[CMFV_GLASSES].valid_values[this->ge] < 2 || GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge) == 0, |
837 PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END); |
837 SCMFW_WIDGET_GLASSES, SCMFW_WIDGET_GLASSES_L, SCMFW_WIDGET_GLASSES_R, WIDGET_LIST_END); |
838 } |
838 } |
839 |
839 |
840 this->DrawWidgets(); |
840 this->DrawWidgets(); |
841 |
841 |
842 /* Draw dynamic button value and labels for the advanced player face selection window */ |
842 /* Draw dynamic button value and labels for the advanced company manager face selection window */ |
843 if (this->advanced) { |
843 if (this->advanced) { |
844 if (this->is_female) { |
844 if (this->is_female) { |
845 /* Only for female faces */ |
845 /* Only for female faces */ |
846 this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge), true ); |
846 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true ); |
847 this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false); |
847 this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false); |
848 } else { |
848 } else { |
849 /* Only for male faces */ |
849 /* Only for male faces */ |
850 this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge), true ); |
850 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge), true ); |
851 this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false); |
851 this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false); |
852 } |
852 } |
853 if (this->is_moust_male) { |
853 if (this->is_moust_male) { |
854 /* Only for male faces with moustache */ |
854 /* Only for male faces with moustache */ |
855 this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_MOUSTACHE, this->ge), false); |
855 this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_MOUSTACHE, this->ge), false); |
856 } else { |
856 } else { |
857 /* Only for female faces or male faces without moustache */ |
857 /* Only for female faces or male faces without moustache */ |
858 this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetPlayerFaceBits(this->face, PFV_LIPS, this->ge), false); |
858 this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetCompanyManagerFaceBits(this->face, CMFV_LIPS, this->ge), false); |
859 } |
859 } |
860 /* For all faces */ |
860 /* For all faces */ |
861 this->DrawFaceStringLabel(PFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge), true ); |
861 this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge), true ); |
862 this->DrawFaceStringLabel(PFW_WIDGET_HAIR, STR_FACE_HAIR, GetPlayerFaceBits(this->face, PFV_HAIR, this->ge), false); |
862 this->DrawFaceStringLabel(SCMFW_WIDGET_HAIR, STR_FACE_HAIR, GetCompanyManagerFaceBits(this->face, CMFV_HAIR, this->ge), false); |
863 this->DrawFaceStringLabel(PFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetPlayerFaceBits(this->face, PFV_EYEBROWS, this->ge), false); |
863 this->DrawFaceStringLabel(SCMFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetCompanyManagerFaceBits(this->face, CMFV_EYEBROWS, this->ge), false); |
864 this->DrawFaceStringLabel(PFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetPlayerFaceBits(this->face, PFV_EYE_COLOUR, this->ge), false); |
864 this->DrawFaceStringLabel(SCMFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetCompanyManagerFaceBits(this->face, CMFV_EYE_COLOUR, this->ge), false); |
865 this->DrawFaceStringLabel(PFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_GLASSES, this->ge), false); |
865 this->DrawFaceStringLabel(SCMFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_GLASSES, this->ge), false); |
866 this->DrawFaceStringLabel(PFW_WIDGET_NOSE, STR_FACE_NOSE, GetPlayerFaceBits(this->face, PFV_NOSE, this->ge), false); |
866 this->DrawFaceStringLabel(SCMFW_WIDGET_NOSE, STR_FACE_NOSE, GetCompanyManagerFaceBits(this->face, CMFV_NOSE, this->ge), false); |
867 this->DrawFaceStringLabel(PFW_WIDGET_CHIN, STR_FACE_CHIN, GetPlayerFaceBits(this->face, PFV_CHIN, this->ge), false); |
867 this->DrawFaceStringLabel(SCMFW_WIDGET_CHIN, STR_FACE_CHIN, GetCompanyManagerFaceBits(this->face, CMFV_CHIN, this->ge), false); |
868 this->DrawFaceStringLabel(PFW_WIDGET_JACKET, STR_FACE_JACKET, GetPlayerFaceBits(this->face, PFV_JACKET, this->ge), false); |
868 this->DrawFaceStringLabel(SCMFW_WIDGET_JACKET, STR_FACE_JACKET, GetCompanyManagerFaceBits(this->face, CMFV_JACKET, this->ge), false); |
869 this->DrawFaceStringLabel(PFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetPlayerFaceBits(this->face, PFV_COLLAR, this->ge), false); |
869 this->DrawFaceStringLabel(SCMFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetCompanyManagerFaceBits(this->face, CMFV_COLLAR, this->ge), false); |
870 } |
870 } |
871 |
871 |
872 /* Draw the player face picture */ |
872 /* Draw the company manager face picture */ |
873 DrawPlayerFace(this->face, GetPlayer((PlayerID)this->window_number)->player_color, 2, 16); |
873 DrawCompanyManagerFace(this->face, GetCompany((CompanyID)this->window_number)->colour, 2, 16); |
874 } |
874 } |
875 |
875 |
876 virtual void OnClick(Point pt, int widget) |
876 virtual void OnClick(Point pt, int widget) |
877 { |
877 { |
878 switch (widget) { |
878 switch (widget) { |
879 /* Toggle size, advanced/simple face selection */ |
879 /* Toggle size, advanced/simple face selection */ |
880 case PFW_WIDGET_TOGGLE_LARGE_SMALL: |
880 case SCMFW_WIDGET_TOGGLE_LARGE_SMALL: |
881 case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: { |
881 case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: { |
882 DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE); |
882 DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE); |
883 |
883 |
884 /* Backup some data before deletion */ |
884 /* Backup some data before deletion */ |
885 int oldtop = this->top; ///< current top position of the window before closing it |
885 int oldtop = this->top; ///< current top position of the window before closing it |
886 int oldleft = this->left; ///< current top position of the window before closing it |
886 int oldleft = this->left; ///< current top position of the window before closing it |
887 bool adv = !this->advanced; |
887 bool adv = !this->advanced; |
888 Window *parent = this->parent; |
888 Window *parent = this->parent; |
889 |
889 |
890 delete this; |
890 delete this; |
891 |
891 |
892 /* Open up the (toggled size) Face selection window at the same position as the previous */ |
892 /* Open up the (toggled size) Face selection window at the same position as the previous */ |
893 DoSelectPlayerFace(parent, adv, oldtop, oldleft); |
893 DoSelectCompanyManagerFace(parent, adv, oldtop, oldleft); |
894 } break; |
894 } break; |
895 |
895 |
896 |
896 |
897 /* OK button */ |
897 /* OK button */ |
898 case PFW_WIDGET_ACCEPT: |
898 case SCMFW_WIDGET_ACCEPT: |
899 DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE); |
899 DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE); |
900 /* Fall-Through */ |
900 /* Fall-Through */ |
901 |
901 |
902 /* Cancel button */ |
902 /* Cancel button */ |
903 case PFW_WIDGET_CANCEL: |
903 case SCMFW_WIDGET_CANCEL: |
904 delete this; |
904 delete this; |
905 break; |
905 break; |
906 |
906 |
907 /* Load button */ |
907 /* Load button */ |
908 case PFW_WIDGET_LOAD: |
908 case SCMFW_WIDGET_LOAD: |
909 this->face = _player_face; |
909 this->face = _company_manager_face; |
910 ScaleAllPlayerFaceBits(this->face); |
910 ScaleAllCompanyManagerFaceBits(this->face); |
911 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0); |
911 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0); |
912 this->UpdateData(); |
912 this->UpdateData(); |
913 this->SetDirty(); |
913 this->SetDirty(); |
914 break; |
914 break; |
915 |
915 |
916 /* 'Player face number' button, view and/or set player face number */ |
916 /* 'Company manager face number' button, view and/or set company manager face number */ |
917 case PFW_WIDGET_FACECODE: |
917 case SCMFW_WIDGET_FACECODE: |
918 SetDParam(0, this->face); |
918 SetDParam(0, this->face); |
919 ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE); |
919 ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE); |
920 break; |
920 break; |
921 |
921 |
922 /* Save button */ |
922 /* Save button */ |
923 case PFW_WIDGET_SAVE: |
923 case SCMFW_WIDGET_SAVE: |
924 _player_face = this->face; |
924 _company_manager_face = this->face; |
925 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0); |
925 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0); |
926 break; |
926 break; |
927 |
927 |
928 /* Toggle gender (male/female) button */ |
928 /* Toggle gender (male/female) button */ |
929 case PFW_WIDGET_MALE: |
929 case SCMFW_WIDGET_MALE: |
930 case PFW_WIDGET_FEMALE: |
930 case SCMFW_WIDGET_FEMALE: |
931 SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE); |
931 SetCompanyManagerFaceBits(this->face, CMFV_GENDER, this->ge, widget - SCMFW_WIDGET_MALE); |
932 ScaleAllPlayerFaceBits(this->face); |
932 ScaleAllCompanyManagerFaceBits(this->face); |
933 this->UpdateData(); |
933 this->UpdateData(); |
934 this->SetDirty(); |
934 this->SetDirty(); |
935 break; |
935 break; |
936 |
936 |
937 /* Randomize face button */ |
937 /* Randomize face button */ |
938 case PFW_WIDGET_RANDOM_NEW_FACE: |
938 case SCMFW_WIDGET_RANDOM_NEW_FACE: |
939 RandomPlayerFaceBits(this->face, this->ge, this->advanced); |
939 RandomCompanyManagerFaceBits(this->face, this->ge, this->advanced); |
940 this->UpdateData(); |
940 this->UpdateData(); |
941 this->SetDirty(); |
941 this->SetDirty(); |
942 break; |
942 break; |
943 |
943 |
944 /* Toggle ethnicity (european/african) button */ |
944 /* Toggle ethnicity (european/african) button */ |
945 case PFW_WIDGET_ETHNICITY_EUR: |
945 case SCMFW_WIDGET_ETHNICITY_EUR: |
946 case PFW_WIDGET_ETHNICITY_AFR: |
946 case SCMFW_WIDGET_ETHNICITY_AFR: |
947 SetPlayerFaceBits(this->face, PFV_ETHNICITY, this->ge, widget - PFW_WIDGET_ETHNICITY_EUR); |
947 SetCompanyManagerFaceBits(this->face, CMFV_ETHNICITY, this->ge, widget - SCMFW_WIDGET_ETHNICITY_EUR); |
948 ScaleAllPlayerFaceBits(this->face); |
948 ScaleAllCompanyManagerFaceBits(this->face); |
949 this->UpdateData(); |
949 this->UpdateData(); |
950 this->SetDirty(); |
950 this->SetDirty(); |
951 break; |
951 break; |
952 |
952 |
953 default: |
953 default: |
954 /* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function. |
954 /* For all buttons from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R is the same function. |
955 * Therefor is this combined function. |
955 * Therefor is this combined function. |
956 * First it checks which PlayerFaceVariable will be change and then |
956 * First it checks which CompanyManagerFaceVariable will be change and then |
957 * a: invert the value for boolean variables |
957 * a: invert the value for boolean variables |
958 * or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */ |
958 * or b: it checks inside of IncreaseCompanyManagerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */ |
959 if (this->advanced && widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= PFW_WIDGET_GLASSES_R) { |
959 if (this->advanced && widget >= SCMFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= SCMFW_WIDGET_GLASSES_R) { |
960 PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited |
960 CompanyManagerFaceVariable cmfv; // which CompanyManagerFaceVariable shall be edited |
961 |
961 |
962 if (widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons |
962 if (widget < SCMFW_WIDGET_EYECOLOUR_L) { // Bool buttons |
963 switch (widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) { |
963 switch (widget - SCMFW_WIDGET_HAS_MOUSTACHE_EARRING) { |
964 default: NOT_REACHED(); |
964 default: NOT_REACHED(); |
965 case 0: pfv = this->is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button |
965 case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE; break; // Has earring/moustache button |
966 case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button |
966 case 1: cmfv = CMFV_HAS_GLASSES; break; // Has glasses button |
967 } |
967 } |
968 SetPlayerFaceBits(this->face, pfv, this->ge, !GetPlayerFaceBits(this->face, pfv, this->ge)); |
968 SetCompanyManagerFaceBits(this->face, cmfv, this->ge, !GetCompanyManagerFaceBits(this->face, cmfv, this->ge)); |
969 ScaleAllPlayerFaceBits(this->face); |
969 ScaleAllCompanyManagerFaceBits(this->face); |
970 } else { // Value buttons |
970 } else { // Value buttons |
971 switch ((widget - PFW_WIDGET_EYECOLOUR_L) / 3) { |
971 switch ((widget - SCMFW_WIDGET_EYECOLOUR_L) / 3) { |
972 default: NOT_REACHED(); |
972 default: NOT_REACHED(); |
973 case 0: pfv = PFV_EYE_COLOUR; break; // Eye colour buttons |
973 case 0: cmfv = CMFV_EYE_COLOUR; break; // Eye colour buttons |
974 case 1: pfv = PFV_CHIN; break; // Chin buttons |
974 case 1: cmfv = CMFV_CHIN; break; // Chin buttons |
975 case 2: pfv = PFV_EYEBROWS; break; // Eyebrows buttons |
975 case 2: cmfv = CMFV_EYEBROWS; break; // Eyebrows buttons |
976 case 3: pfv = this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons |
976 case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS; break; // Moustache or lips buttons |
977 case 4: pfv = PFV_NOSE; break; // Nose buttons |
977 case 4: cmfv = CMFV_NOSE; break; // Nose buttons |
978 case 5: pfv = PFV_HAIR; break; // Hair buttons |
978 case 5: cmfv = CMFV_HAIR; break; // Hair buttons |
979 case 6: pfv = PFV_JACKET; break; // Jacket buttons |
979 case 6: cmfv = CMFV_JACKET; break; // Jacket buttons |
980 case 7: pfv = PFV_COLLAR; break; // Collar buttons |
980 case 7: cmfv = CMFV_COLLAR; break; // Collar buttons |
981 case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons |
981 case 8: cmfv = CMFV_TIE_EARRING; break; // Tie/earring buttons |
982 case 9: pfv = PFV_GLASSES; break; // Glasses buttons |
982 case 9: cmfv = CMFV_GLASSES; break; // Glasses buttons |
983 } |
983 } |
984 /* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */ |
984 /* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */ |
985 IncreasePlayerFaceBits(this->face, pfv, this->ge, (((widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1); |
985 IncreaseCompanyManagerFaceBits(this->face, cmfv, this->ge, (((widget - SCMFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1); |
986 } |
986 } |
987 this->UpdateData(); |
987 this->UpdateData(); |
988 this->SetDirty(); |
988 this->SetDirty(); |
989 } |
989 } |
990 break; |
990 break; |
992 } |
992 } |
993 |
993 |
994 virtual void OnQueryTextFinished(char *str) |
994 virtual void OnQueryTextFinished(char *str) |
995 { |
995 { |
996 if (str == NULL) return; |
996 if (str == NULL) return; |
997 /* Set a new player face number */ |
997 /* Set a new company manager face number */ |
998 if (!StrEmpty(str)) { |
998 if (!StrEmpty(str)) { |
999 this->face = strtoul(str, NULL, 10); |
999 this->face = strtoul(str, NULL, 10); |
1000 ScaleAllPlayerFaceBits(this->face); |
1000 ScaleAllCompanyManagerFaceBits(this->face); |
1001 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0); |
1001 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0); |
1002 this->UpdateData(); |
1002 this->UpdateData(); |
1003 this->SetDirty(); |
1003 this->SetDirty(); |
1004 } else { |
1004 } else { |
1005 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0); |
1005 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0); |
1006 } |
1006 } |
1007 } |
1007 } |
1008 }; |
1008 }; |
1009 |
1009 |
1010 /** normal/simple player face selection window description */ |
1010 /** normal/simple company manager face selection window description */ |
1011 static const WindowDesc _select_player_face_desc = { |
1011 static const WindowDesc _select_company_manager_face_desc = { |
1012 WDP_AUTO, WDP_AUTO, 190, 163, 190, 163, |
1012 WDP_AUTO, WDP_AUTO, 190, 163, 190, 163, |
1013 WC_PLAYER_FACE, WC_NONE, |
1013 WC_COMPANY_MANAGER_FACE, WC_NONE, |
1014 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1014 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1015 _select_player_face_widgets, |
1015 _select_company_manager_face_widgets, |
1016 }; |
1016 }; |
1017 |
1017 |
1018 /** advanced player face selection window description */ |
1018 /** advanced company manager face selection window description */ |
1019 static const WindowDesc _select_player_face_adv_desc = { |
1019 static const WindowDesc _select_company_manager_face_adv_desc = { |
1020 WDP_AUTO, WDP_AUTO, 220, 220, 220, 220, |
1020 WDP_AUTO, WDP_AUTO, 220, 220, 220, 220, |
1021 WC_PLAYER_FACE, WC_NONE, |
1021 WC_COMPANY_MANAGER_FACE, WC_NONE, |
1022 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1022 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1023 _select_player_face_adv_widgets, |
1023 _select_company_manager_face_adv_widgets, |
1024 }; |
1024 }; |
1025 |
1025 |
1026 /** |
1026 /** |
1027 * Open the simple/advanced player face selection window |
1027 * Open the simple/advanced company manager face selection window |
1028 * |
1028 * |
1029 * @param player the player which face shall be edited |
1029 * @param parent the parent company window |
1030 * @param adv simple or advanced player face selection window |
1030 * @param adv simple or advanced face selection window |
1031 * @param top previous top position of the window |
1031 * @param top previous top position of the window |
1032 * @param left previous left position of the window |
1032 * @param left previous left position of the window |
1033 * |
|
1034 * @pre is player a valid player |
|
1035 */ |
1033 */ |
1036 static void DoSelectPlayerFace(Window *parent, bool adv, int top, int left) |
1034 static void DoSelectCompanyManagerFace(Window *parent, bool adv, int top, int left) |
1037 { |
1035 { |
1038 if (!IsValidPlayerID((PlayerID)parent->window_number)) return; |
1036 if (!IsValidCompanyID((CompanyID)parent->window_number)) return; |
1039 |
1037 |
1040 if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return; |
1038 if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return; |
1041 new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window |
1039 new SelectCompanyManagerFaceWindow(adv ? &_select_company_manager_face_adv_desc : &_select_company_manager_face_desc, parent, adv, top, left); // simple or advanced window |
1042 } |
1040 } |
1043 |
1041 |
1044 |
1042 |
1045 /* Names of the widgets. Keep them in the same order as in the widget array */ |
1043 /* Names of the widgets. Keep them in the same order as in the widget array */ |
1046 enum PlayerCompanyWindowWidgets { |
1044 enum CompanyWindowWidgets { |
1047 PCW_WIDGET_CLOSEBOX = 0, |
1045 CW_WIDGET_CLOSEBOX = 0, |
1048 PCW_WIDGET_CAPTION, |
1046 CW_WIDGET_CAPTION, |
1049 PCW_WIDGET_FACE, |
1047 CW_WIDGET_FACE, |
1050 PCW_WIDGET_NEW_FACE, |
1048 CW_WIDGET_NEW_FACE, |
1051 PCW_WIDGET_COLOR_SCHEME, |
1049 CW_WIDGET_COLOR_SCHEME, |
1052 PCW_WIDGET_PRESIDENT_NAME, |
1050 CW_WIDGET_PRESIDENT_NAME, |
1053 PCW_WIDGET_COMPANY_NAME, |
1051 CW_WIDGET_COMPANY_NAME, |
1054 PCW_WIDGET_BUILD_VIEW_HQ, |
1052 CW_WIDGET_BUILD_VIEW_HQ, |
1055 PCW_WIDGET_RELOCATE_HQ, |
1053 CW_WIDGET_RELOCATE_HQ, |
1056 PCW_WIDGET_BUY_SHARE, |
1054 CW_WIDGET_BUY_SHARE, |
1057 PCW_WIDGET_SELL_SHARE, |
1055 CW_WIDGET_SELL_SHARE, |
1058 PCW_WIDGET_COMPANY_PASSWORD, |
1056 CW_WIDGET_COMPANY_PASSWORD, |
1059 }; |
1057 }; |
1060 |
1058 |
1061 static const Widget _player_company_widgets[] = { |
1059 static const Widget _company_widgets[] = { |
1062 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1060 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1063 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1061 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1064 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 359, 14, 157, 0x0, STR_NULL}, |
1062 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 359, 14, 157, 0x0, STR_NULL}, |
1065 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
1063 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
1066 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
1064 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
1129 DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING); |
1127 DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING); |
1130 } |
1128 } |
1131 } |
1129 } |
1132 } |
1130 } |
1133 |
1131 |
1134 int GetAmountOwnedBy(const Player *p, PlayerID owner) |
1132 int GetAmountOwnedBy(const Company *c, Owner owner) |
1135 { |
1133 { |
1136 return (p->share_owners[0] == owner) + |
1134 return (c->share_owners[0] == owner) + |
1137 (p->share_owners[1] == owner) + |
1135 (c->share_owners[1] == owner) + |
1138 (p->share_owners[2] == owner) + |
1136 (c->share_owners[2] == owner) + |
1139 (p->share_owners[3] == owner); |
1137 (c->share_owners[3] == owner); |
1140 } |
1138 } |
1141 |
1139 |
1142 /** |
1140 /** |
1143 * Draws list of all companies with shares |
1141 * Draws list of all companies with shares |
1144 * @param p pointer to the Player structure |
1142 * @param c pointer to the Company structure |
1145 */ |
1143 */ |
1146 static void DrawCompanyOwnerText(const Player *p) |
1144 static void DrawCompanyOwnerText(const Company *c) |
1147 { |
1145 { |
1148 const Player *p2; |
1146 const Company *c2; |
1149 uint num = 0; |
1147 uint num = 0; |
1150 const byte height = GetCharacterHeight(FS_NORMAL); |
1148 const byte height = GetCharacterHeight(FS_NORMAL); |
1151 |
1149 |
1152 FOR_ALL_PLAYERS(p2) { |
1150 FOR_ALL_COMPANIES(c2) { |
1153 uint amt = GetAmountOwnedBy(p, p2->index); |
1151 uint amt = GetAmountOwnedBy(c, c2->index); |
1154 if (amt != 0) { |
1152 if (amt != 0) { |
1155 SetDParam(0, amt * 25); |
1153 SetDParam(0, amt * 25); |
1156 SetDParam(1, p2->index); |
1154 SetDParam(1, c2->index); |
1157 |
1155 |
1158 DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING); |
1156 DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING); |
1159 } |
1157 } |
1160 } |
1158 } |
1161 } |
1159 } |
1162 |
1160 |
1163 /** |
1161 /** |
1164 * Player company window event definition |
1162 * Window with general information about a company |
1165 * |
|
1166 * @param w window pointer |
|
1167 * @param e event been triggered |
|
1168 */ |
1163 */ |
1169 struct PlayerCompanyWindow : Window |
1164 struct CompanyWindow : Window |
1170 { |
1165 { |
1171 PlayerCompanyWindowWidgets query_widget; |
1166 CompanyWindowWidgets query_widget; |
1172 |
1167 |
1173 PlayerCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
1168 CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
1174 { |
1169 { |
1175 this->caption_color = this->window_number; |
1170 this->caption_color = this->window_number; |
1176 this->FindWindowPlacementAndResize(desc); |
1171 this->FindWindowPlacementAndResize(desc); |
1177 } |
1172 } |
1178 |
1173 |
1179 virtual void OnPaint() |
1174 virtual void OnPaint() |
1180 { |
1175 { |
1181 const Player *p = GetPlayer((PlayerID)this->window_number); |
1176 const Company *c = GetCompany((CompanyID)this->window_number); |
1182 bool local = this->window_number == _local_player; |
1177 bool local = this->window_number == _local_company; |
1183 |
1178 |
1184 this->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE, !local); |
1179 this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE, !local); |
1185 this->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME, !local); |
1180 this->SetWidgetHiddenState(CW_WIDGET_COLOR_SCHEME, !local); |
1186 this->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local); |
1181 this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local); |
1187 this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME, !local); |
1182 this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME, !local); |
1188 this->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ; |
1183 this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ; |
1189 if (local && p->location_of_HQ != 0) this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built. |
1184 if (local && c->location_of_HQ != 0) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built. |
1190 this->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_HQ == 0); |
1185 this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == 0); |
1191 this->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_HQ == 0); |
1186 this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ, !local || c->location_of_HQ == 0); |
1192 this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE, local); |
1187 this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE, local); |
1193 this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE, local); |
1188 this->SetWidgetHiddenState(CW_WIDGET_SELL_SHARE, local); |
1194 this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking); |
1189 this->SetWidgetHiddenState(CW_WIDGET_COMPANY_PASSWORD, !local || !_networking); |
1195 |
1190 |
1196 if (!local) { |
1191 if (!local) { |
1197 if (_settings_game.economy.allow_shares) { // Shares are allowed |
1192 if (_settings_game.economy.allow_shares) { // Shares are allowed |
1198 /* If all shares are owned by someone (none by nobody), disable buy button */ |
1193 /* If all shares are owned by someone (none by nobody), disable buy button */ |
1199 this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 || |
1194 this->SetWidgetDisabledState(CW_WIDGET_BUY_SHARE, GetAmountOwnedBy(c, INVALID_OWNER) == 0 || |
1200 /* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */ |
1195 /* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */ |
1201 (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) || |
1196 (GetAmountOwnedBy(c, INVALID_OWNER) == 1 && !c->is_ai) || |
1202 /* Spectators cannot do anything of course */ |
1197 /* Spectators cannot do anything of course */ |
1203 _local_player == PLAYER_SPECTATOR); |
1198 _local_company == COMPANY_SPECTATOR); |
1204 |
1199 |
1205 /* If the player doesn't own any shares, disable sell button */ |
1200 /* If the company doesn't own any shares, disable sell button */ |
1206 this->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) || |
1201 this->SetWidgetDisabledState(CW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(c, _local_company) == 0) || |
1207 /* Spectators cannot do anything of course */ |
1202 /* Spectators cannot do anything of course */ |
1208 _local_player == PLAYER_SPECTATOR); |
1203 _local_company == COMPANY_SPECTATOR); |
1209 } else { // Shares are not allowed, disable buy/sell buttons |
1204 } else { // Shares are not allowed, disable buy/sell buttons |
1210 this->DisableWidget(PCW_WIDGET_BUY_SHARE); |
1205 this->DisableWidget(CW_WIDGET_BUY_SHARE); |
1211 this->DisableWidget(PCW_WIDGET_SELL_SHARE); |
1206 this->DisableWidget(CW_WIDGET_SELL_SHARE); |
1212 } |
1207 } |
1213 } |
1208 } |
1214 |
1209 |
1215 SetDParam(0, p->index); |
1210 SetDParam(0, c->index); |
1216 SetDParam(1, p->index); |
1211 SetDParam(1, c->index); |
1217 |
1212 |
1218 this->DrawWidgets(); |
1213 this->DrawWidgets(); |
1219 |
1214 |
1220 /* Player face */ |
1215 /* Company manager's face */ |
1221 DrawPlayerFace(p->face, p->player_color, 2, 16); |
1216 DrawCompanyManagerFace(c->face, c->colour, 2, 16); |
1222 |
1217 |
1223 /* "xxx (Manager)" */ |
1218 /* "xxx (Manager)" */ |
1224 SetDParam(0, p->index); |
1219 SetDParam(0, c->index); |
1225 DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, MAX_LENGTH_PRESIDENT_NAME_PIXELS); |
1220 DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, MAX_LENGTH_PRESIDENT_NAME_PIXELS); |
1226 |
1221 |
1227 /* "Inaugurated:" */ |
1222 /* "Inaugurated:" */ |
1228 SetDParam(0, p->inaugurated_year); |
1223 SetDParam(0, c->inaugurated_year); |
1229 DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING); |
1224 DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING); |
1230 |
1225 |
1231 /* "Colour scheme:" */ |
1226 /* "Colour scheme:" */ |
1232 DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING); |
1227 DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING); |
1233 /* Draw company-colour bus */ |
1228 /* Draw company-colour bus */ |
1234 DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44); |
1229 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOR(c->index), 215, 44); |
1235 |
1230 |
1236 /* "Vehicles:" */ |
1231 /* "Vehicles:" */ |
1237 DrawPlayerVehiclesAmount((PlayerID)this->window_number); |
1232 DrawCompanyVehiclesAmount((CompanyID)this->window_number); |
1238 |
1233 |
1239 /* "Company value:" */ |
1234 /* "Company value:" */ |
1240 SetDParam(0, CalculateCompanyValue(p)); |
1235 SetDParam(0, CalculateCompanyValue(c)); |
1241 DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING); |
1236 DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING); |
1242 |
1237 |
1243 /* Shares list */ |
1238 /* Shares list */ |
1244 DrawCompanyOwnerText(p); |
1239 DrawCompanyOwnerText(c); |
1245 } |
1240 } |
1246 |
1241 |
1247 virtual void OnClick(Point pt, int widget) |
1242 virtual void OnClick(Point pt, int widget) |
1248 { |
1243 { |
1249 switch (widget) { |
1244 switch (widget) { |
1250 case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace(this, false); break; |
1245 case CW_WIDGET_NEW_FACE: DoSelectCompanyManagerFace(this, false); break; |
1251 |
1246 |
1252 case PCW_WIDGET_COLOR_SCHEME: |
1247 case CW_WIDGET_COLOR_SCHEME: |
1253 if (BringWindowToFrontById(WC_PLAYER_COLOR, this->window_number)) break; |
1248 if (BringWindowToFrontById(WC_COMPANY_COLOR, this->window_number)) break; |
1254 new SelectPlayerLiveryWindow(&_select_player_livery_desc, (PlayerID)this->window_number); |
1249 new SelectCompanyLiveryWindow(&_select_company_livery_desc, (CompanyID)this->window_number); |
1255 break; |
1250 break; |
1256 |
1251 |
1257 case PCW_WIDGET_PRESIDENT_NAME: |
1252 case CW_WIDGET_PRESIDENT_NAME: |
1258 this->query_widget = PCW_WIDGET_PRESIDENT_NAME; |
1253 this->query_widget = CW_WIDGET_PRESIDENT_NAME; |
1259 SetDParam(0, this->window_number); |
1254 SetDParam(0, this->window_number); |
1260 ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
1255 ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
1261 break; |
1256 break; |
1262 |
1257 |
1263 case PCW_WIDGET_COMPANY_NAME: |
1258 case CW_WIDGET_COMPANY_NAME: |
1264 this->query_widget = PCW_WIDGET_COMPANY_NAME; |
1259 this->query_widget = CW_WIDGET_COMPANY_NAME; |
1265 SetDParam(0, this->window_number); |
1260 SetDParam(0, this->window_number); |
1266 ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
1261 ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
1267 break; |
1262 break; |
1268 |
1263 |
1269 case PCW_WIDGET_BUILD_VIEW_HQ: { |
1264 case CW_WIDGET_BUILD_VIEW_HQ: { |
1270 TileIndex tile = GetPlayer((PlayerID)this->window_number)->location_of_HQ; |
1265 TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ; |
1271 if (tile == 0) { |
1266 if (tile == 0) { |
1272 if ((byte)this->window_number != _local_player) return; |
1267 if ((byte)this->window_number != _local_company) return; |
1273 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
1268 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
1274 SetTileSelectSize(2, 2); |
1269 SetTileSelectSize(2, 2); |
1275 this->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
1270 this->LowerWidget(CW_WIDGET_BUILD_VIEW_HQ); |
1276 this->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
1271 this->InvalidateWidget(CW_WIDGET_BUILD_VIEW_HQ); |
1277 } else { |
1272 } else { |
1278 if (_ctrl_pressed) { |
1273 if (_ctrl_pressed) { |
1279 ShowExtraViewPortWindow(tile); |
1274 ShowExtraViewPortWindow(tile); |
1280 } else { |
1275 } else { |
1281 ScrollMainWindowToTile(tile); |
1276 ScrollMainWindowToTile(tile); |
1282 } |
1277 } |
1283 } |
1278 } |
1284 break; |
1279 break; |
1285 } |
1280 } |
1286 |
1281 |
1287 case PCW_WIDGET_RELOCATE_HQ: |
1282 case CW_WIDGET_RELOCATE_HQ: |
1288 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
1283 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
1289 SetTileSelectSize(2, 2); |
1284 SetTileSelectSize(2, 2); |
1290 this->LowerWidget(PCW_WIDGET_RELOCATE_HQ); |
1285 this->LowerWidget(CW_WIDGET_RELOCATE_HQ); |
1291 this->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ); |
1286 this->InvalidateWidget(CW_WIDGET_RELOCATE_HQ); |
1292 break; |
1287 break; |
1293 |
1288 |
1294 case PCW_WIDGET_BUY_SHARE: |
1289 case CW_WIDGET_BUY_SHARE: |
1295 DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
1290 DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
1296 break; |
1291 break; |
1297 |
1292 |
1298 case PCW_WIDGET_SELL_SHARE: |
1293 case CW_WIDGET_SELL_SHARE: |
1299 DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); |
1294 DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); |
1300 break; |
1295 break; |
1301 |
1296 |
1302 #ifdef ENABLE_NETWORK |
1297 #ifdef ENABLE_NETWORK |
1303 case PCW_WIDGET_COMPANY_PASSWORD: |
1298 case CW_WIDGET_COMPANY_PASSWORD: |
1304 if (this->window_number == _local_player) ShowNetworkCompanyPasswordWindow(this); |
1299 if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this); |
1305 break; |
1300 break; |
1306 #endif /* ENABLE_NETWORK */ |
1301 #endif /* ENABLE_NETWORK */ |
1307 } |
1302 } |
1308 } |
1303 } |
1309 |
1304 |