2005-07-24 14:12:37 +00:00
/* $Id$ */
2008-09-30 20:39:50 +00:00
/** @file company_gui.cpp Company related GUIs. */
2007-03-21 17:42:43 +00:00
2004-08-09 17:04:08 +00:00
# include "stdafx.h"
# include "gui.h"
2007-12-19 20:45:46 +00:00
# include "window_gui.h"
# include "textbuf_gui.h"
2008-01-09 09:45:45 +00:00
# include "viewport_func.h"
# include "gfx_func.h"
2008-09-30 20:51:04 +00:00
# include "company_func.h"
2007-12-21 21:50:46 +00:00
# include "command_func.h"
2007-01-02 17:34:03 +00:00
# include "network/network.h"
2008-05-30 18:20:26 +00:00
# include "network/network_gui.h"
2009-01-23 22:18:06 +00:00
# include "network/network_func.h"
2007-06-11 14:00:16 +00:00
# include "roadveh.h"
2005-11-18 23:41:03 +00:00
# include "train.h"
2007-01-27 12:29:55 +00:00
# include "aircraft.h"
2006-10-05 15:07:34 +00:00
# include "newgrf.h"
2008-09-30 20:51:04 +00:00
# include "company_manager_face.h"
2007-12-21 19:49:27 +00:00
# include "strings_func.h"
2007-12-26 13:50:40 +00:00
# include "date_func.h"
2008-01-07 14:23:25 +00:00
# include "string_func.h"
2008-04-12 22:19:34 +00:00
# include "widgets/dropdown_type.h"
2008-05-07 13:10:15 +00:00
# include "tilehighlight_func.h"
2009-01-31 20:16:06 +00:00
# include "settings_type.h"
2004-08-09 17:04:08 +00:00
2008-01-13 01:21:35 +00:00
# include "table/strings.h"
2008-04-09 02:02:39 +00:00
enum {
FIRST_GUI_CALL = INT_MAX , ///< default value to specify thuis is the first call of the resizable gui
} ;
2008-09-30 20:39:50 +00:00
static void DoShowCompanyFinances ( CompanyID company , bool show_small , bool show_stickied , int top = FIRST_GUI_CALL , int left = FIRST_GUI_CALL ) ;
static void DoSelectCompanyManagerFace ( Window * parent , bool show_big , int top = FIRST_GUI_CALL , int left = FIRST_GUI_CALL ) ;
2004-08-09 17:04:08 +00:00
2009-01-31 21:27:36 +00:00
/** Standard unsorted list of expenses. */
static ExpensesType _expenses_list_1 [ ] = {
EXPENSES_CONSTRUCTION ,
EXPENSES_NEW_VEHICLES ,
EXPENSES_TRAIN_RUN ,
EXPENSES_ROADVEH_RUN ,
EXPENSES_AIRCRAFT_RUN ,
EXPENSES_SHIP_RUN ,
EXPENSES_PROPERTY ,
EXPENSES_TRAIN_INC ,
EXPENSES_ROADVEH_INC ,
EXPENSES_AIRCRAFT_INC ,
EXPENSES_SHIP_INC ,
EXPENSES_LOAN_INT ,
EXPENSES_OTHER ,
} ;
/** Grouped list of expenses. */
static ExpensesType _expenses_list_2 [ ] = {
EXPENSES_TRAIN_INC ,
EXPENSES_ROADVEH_INC ,
EXPENSES_AIRCRAFT_INC ,
EXPENSES_SHIP_INC ,
INVALID_EXPENSES ,
EXPENSES_TRAIN_RUN ,
EXPENSES_ROADVEH_RUN ,
EXPENSES_AIRCRAFT_RUN ,
EXPENSES_SHIP_RUN ,
EXPENSES_PROPERTY ,
EXPENSES_LOAN_INT ,
INVALID_EXPENSES ,
EXPENSES_CONSTRUCTION ,
EXPENSES_NEW_VEHICLES ,
EXPENSES_OTHER ,
INVALID_EXPENSES ,
} ;
/** Expense list container. */
struct ExpensesList {
const ExpensesType * et ; ///< Expenses items.
const int length ; ///< Number of items in list.
const int height ; ///< Height of list, 10 pixels per item, plus an additional 12 pixels per subtotal. */
} ;
static const ExpensesList _expenses_list_types [ ] = {
{ _expenses_list_1 , lengthof ( _expenses_list_1 ) , lengthof ( _expenses_list_1 ) * 10 } ,
{ _expenses_list_2 , lengthof ( _expenses_list_2 ) , lengthof ( _expenses_list_2 ) * 10 + 3 * 12 } ,
} ;
2009-03-28 04:14:02 +00:00
/** Widgets of the company finances windows. */
2009-03-27 01:55:25 +00:00
enum CompanyFinancesWindowWidgets {
CFW_CLOSEBOX = 0 , ///< Close the window
CFW_CAPTION , ///< Caption of the window
CFW_TOGGLE_SIZE , ///< Toggle windows size
CFW_STICKY , ///< Sticky button
CFW_EXPS_PANEL , ///< Panel for expenses
CFW_EXPS_CATEGORY , ///< Column for expenses category strings
CFW_EXPS_PRICE1 , ///< Column for year Y-2 expenses
CFW_EXPS_PRICE2 , ///< Column for year Y-1 expenses
CFW_EXPS_PRICE3 , ///< Column for year Y expenses
CFW_TOTAL_PANEL , ///< Panel for totals
CFW_TOTAL_LABELS , ///< Column for totals labels
CFW_TOTAL_VALUES , ///< Column for totals values
CFW_TOTAL_MAXLOAN , ///< Column for max loan string
CFW_INCREASE_LOAN , ///< Increase loan
CFW_REPAY_LOAN , ///< Decrease loan
} ;
static void DrawCompanyEconomyStats ( const Company * c , bool small , const Widget * widget )
2004-08-09 17:04:08 +00:00
{
2009-01-31 21:27:36 +00:00
int type = _settings_client . gui . expenses_layout ;
2009-03-27 01:55:25 +00:00
int y ;
2008-02-09 02:49:33 +00:00
const Money ( * tbl ) [ EXPENSES_END ] ;
2004-08-09 17:04:08 +00:00
StringID str ;
2008-05-16 07:34:48 +00:00
if ( ! small ) { // normal sized economics window
2009-03-27 01:55:25 +00:00
const Widget * w = & widget [ CFW_EXPS_CATEGORY ] ;
2004-08-09 17:04:08 +00:00
/* draw categories */
2009-03-27 01:55:25 +00:00
DrawString ( w - > left , w - > right , 15 , STR_700F_EXPENDITURE_INCOME , TC_FROMSTRING , SA_CENTER , true ) ;
2009-01-31 21:27:36 +00:00
y = 27 ;
2009-03-27 01:55:25 +00:00
for ( int i = 0 ; i < _expenses_list_types [ type ] . length ; i + + ) {
2009-01-31 21:27:36 +00:00
ExpensesType et = _expenses_list_types [ type ] . et [ i ] ;
if ( et = = INVALID_EXPENSES ) {
y + = 2 ;
2009-03-27 01:55:25 +00:00
DrawString ( w - > left + 2 , w - > right - 2 , y , STR_7020_TOTAL , TC_FROMSTRING , SA_RIGHT ) ;
2009-01-31 21:27:36 +00:00
y + = 20 ;
} else {
2009-03-27 01:55:25 +00:00
DrawString ( w - > left + 2 , w - > right - 2 , y , STR_7011_CONSTRUCTION + et , TC_FROMSTRING ) ;
2009-01-31 21:27:36 +00:00
y + = 10 ;
}
}
2009-03-27 01:55:25 +00:00
DrawString ( w - > left + 2 , w - > right - 2 , y + 2 , STR_7020_TOTAL , TC_FROMSTRING , SA_RIGHT ) ;
2004-09-11 09:40:19 +00:00
2004-08-09 17:04:08 +00:00
/* draw the price columns */
2009-03-27 01:55:25 +00:00
int year = _cur_year - 2 ;
int j = 3 ;
w + + ;
2008-09-30 20:39:50 +00:00
tbl = c - > yearly_expenses + 2 ;
2009-01-31 21:27:36 +00:00
2004-08-09 17:04:08 +00:00
do {
2008-09-30 20:39:50 +00:00
if ( year > = c - > inaugurated_year ) {
2006-08-16 11:39:55 +00:00
SetDParam ( 0 , year ) ;
2009-03-27 01:55:25 +00:00
DrawString ( w - > left , w - > right , 15 , STR_7010 , TC_FROMSTRING , SA_RIGHT , true ) ;
2009-01-31 21:27:36 +00:00
Money sum = 0 ;
Money subtotal = 0 ;
int y = 27 ;
for ( int i = 0 ; i < _expenses_list_types [ type ] . length ; i + + ) {
ExpensesType et = _expenses_list_types [ type ] . et [ i ] ;
Money cost ;
if ( et = = INVALID_EXPENSES ) {
2009-03-27 01:55:25 +00:00
GfxFillRect ( w - > left , y , w - > right , y , 215 ) ;
2009-01-31 21:27:36 +00:00
cost = subtotal ;
subtotal = 0 ;
y + = 2 ;
} else {
cost = ( * tbl ) [ et ] ;
subtotal + = cost ;
2004-08-09 17:04:08 +00:00
sum + = cost ;
2009-01-31 21:27:36 +00:00
}
2004-09-11 09:40:19 +00:00
2009-01-31 21:27:36 +00:00
if ( cost ! = 0 | | et = = INVALID_EXPENSES ) {
2004-08-09 17:04:08 +00:00
str = STR_701E ;
if ( cost < 0 ) { cost = - cost ; str + + ; }
2007-06-21 17:25:17 +00:00
SetDParam ( 0 , cost ) ;
2009-03-27 01:55:25 +00:00
DrawString ( w - > left , w - > right , y , str , TC_FROMSTRING , SA_RIGHT ) ;
2004-08-09 17:04:08 +00:00
}
2009-01-31 21:27:36 +00:00
y + = ( et = = INVALID_EXPENSES ) ? 20 : 10 ;
2004-08-09 17:04:08 +00:00
}
str = STR_701E ;
if ( sum < 0 ) { sum = - sum ; str + + ; }
2007-06-21 17:25:17 +00:00
SetDParam ( 0 , sum ) ;
2009-03-27 01:55:25 +00:00
DrawString ( w - > left , w - > right , y + 2 , str , TC_FROMSTRING , SA_RIGHT ) ;
2004-09-11 09:40:19 +00:00
2009-03-27 01:55:25 +00:00
GfxFillRect ( w - > left , y , w - > right , y , 215 ) ;
w + + ;
2004-08-09 17:04:08 +00:00
}
year + + ;
tbl - - ;
} while ( - - j ! = 0 ) ;
2009-01-31 21:27:36 +00:00
y + = 14 ;
2004-09-08 19:26:10 +00:00
2007-03-21 17:42:43 +00:00
/* draw max loan aligned to loan below (y += 10) */
2007-06-21 17:25:17 +00:00
SetDParam ( 0 , _economy . max_loan ) ;
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_MAXLOAN ] . left , widget [ CFW_TOTAL_MAXLOAN ] . right , y + 10 , STR_MAX_LOAN , TC_FROMSTRING ) ;
2006-06-27 21:25:53 +00:00
} else {
2004-08-09 17:04:08 +00:00
y = 15 ;
2006-06-27 21:25:53 +00:00
}
2004-08-09 17:04:08 +00:00
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_LABELS ] . left , widget [ CFW_TOTAL_LABELS ] . right , y , STR_7026_BANK_BALANCE , TC_FROMSTRING ) ;
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > money ) ;
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_VALUES ] . left , widget [ CFW_TOTAL_VALUES ] . right , y , STR_7028 , TC_FROMSTRING , SA_RIGHT ) ;
2004-08-09 17:04:08 +00:00
y + = 10 ;
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_LABELS ] . left , widget [ CFW_TOTAL_LABELS ] . right , y , STR_7027_LOAN , TC_FROMSTRING ) ;
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > current_loan ) ;
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_VALUES ] . left , widget [ CFW_TOTAL_VALUES ] . right , y , STR_7028 , TC_FROMSTRING , SA_RIGHT ) ;
2004-08-09 17:04:08 +00:00
y + = 12 ;
2009-03-27 01:55:25 +00:00
GfxFillRect ( widget [ CFW_TOTAL_VALUES ] . left , y - 2 , widget [ CFW_TOTAL_VALUES ] . right , y - 2 , 215 ) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > money - c - > current_loan ) ;
2009-03-27 01:55:25 +00:00
DrawString ( widget [ CFW_TOTAL_VALUES ] . left , widget [ CFW_TOTAL_VALUES ] . right , y , STR_7028 , TC_FROMSTRING , SA_RIGHT ) ;
2004-08-09 17:04:08 +00:00
}
2009-03-27 22:59:43 +00:00
static const NWidgetPart _nested_company_finances_widgets [ ] = {
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_CLOSEBOX , COLOUR_GREY , CFW_CLOSEBOX ) ,
NWidget ( WWT_CAPTION , COLOUR_GREY , CFW_CAPTION ) , SetMinimalSize ( 369 , 14 ) , SetDataTip ( STR_700E_FINANCES , STR_018C_WINDOW_TITLE_DRAG_THIS ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , CFW_TOGGLE_SIZE ) , SetMinimalSize ( 14 , 14 ) , SetDataTip ( SPR_LARGE_SMALL_WINDOW , STR_7075_TOGGLE_LARGE_SMALL_WINDOW ) ,
NWidget ( WWT_STICKYBOX , COLOUR_GREY , CFW_STICKY ) ,
EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , CFW_EXPS_PANEL ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_CATEGORY ) , SetMinimalSize ( 123 , 0 ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 7 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE1 ) , SetMinimalSize ( 86 , 0 ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 9 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE2 ) , SetMinimalSize ( 86 , 0 ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 9 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE3 ) , SetMinimalSize ( 86 , 0 ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 1 , 0 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , CFW_TOTAL_PANEL ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_LABELS ) , SetMinimalSize ( 95 , 34 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_VALUES ) , SetMinimalSize ( 86 , 34 ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 19 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_MAXLOAN ) , SetMinimalSize ( 205 , 34 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , CFW_INCREASE_LOAN ) , SetMinimalSize ( 203 , 12 ) , SetDataTip ( STR_7029_BORROW , STR_7035_INCREASE_SIZE_OF_LOAN ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , CFW_REPAY_LOAN ) , SetMinimalSize ( 204 , 12 ) , SetDataTip ( STR_702A_REPAY , STR_7036_REPAY_PART_OF_LOAN ) ,
EndContainer ( ) ,
} ;
2008-09-30 20:39:50 +00:00
static const Widget _company_finances_widgets [ ] = {
2009-03-26 02:02:11 +00:00
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } , // CFW_CLOSEBOX
2009-03-27 01:55:25 +00:00
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 380 , 0 , 13 , STR_700E_FINANCES , STR_018C_WINDOW_TITLE_DRAG_THIS } , // CFW_CAPTION
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 381 , 394 , 0 , 13 , SPR_LARGE_SMALL_WINDOW , STR_7075_TOGGLE_LARGE_SMALL_WINDOW } , // CFW_TOGGLE_SIZE
2009-03-26 02:02:11 +00:00
{ WWT_STICKYBOX , RESIZE_NONE , COLOUR_GREY , 395 , 406 , 0 , 13 , 0x0 , STR_STICKY_BUTTON } , // CFW_STICKY
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 406 , 14 , 14 , 0x0 , STR_NULL } , // CFW_EXPS_PANEL
2009-03-27 01:55:25 +00:00
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 122 , 14 , 14 , 0x0 , STR_NULL } , // CFW_EXPS_CATEGORY
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 130 , 215 , 14 , 14 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE1
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 225 , 310 , 14 , 14 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE2
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 320 , 405 , 14 , 14 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE3
2009-03-26 02:02:11 +00:00
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 406 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_PANEL
2009-03-27 01:55:25 +00:00
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 2 , 96 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_LABELS
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 97 , 182 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_VALUES
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 202 , 406 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_MAXLOAN
2009-03-26 02:02:11 +00:00
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 202 , 48 , 59 , STR_7029_BORROW , STR_7035_INCREASE_SIZE_OF_LOAN } , // CFW_INCREASE_LOAN
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 203 , 406 , 48 , 59 , STR_702A_REPAY , STR_7036_REPAY_PART_OF_LOAN } , // CFW_REPAY_LOAN
2004-09-07 21:48:09 +00:00
{ WIDGETS_END } ,
2004-08-09 17:04:08 +00:00
} ;
2009-03-27 22:59:43 +00:00
static const NWidgetPart _nested_company_finances_small_widgets [ ] = {
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_CLOSEBOX , COLOUR_GREY , CFW_CLOSEBOX ) ,
NWidget ( WWT_CAPTION , COLOUR_GREY , CFW_CAPTION ) , SetMinimalSize ( 243 , 14 ) , SetDataTip ( STR_700E_FINANCES , STR_018C_WINDOW_TITLE_DRAG_THIS ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , CFW_TOGGLE_SIZE ) , SetMinimalSize ( 14 , 14 ) , SetDataTip ( SPR_LARGE_SMALL_WINDOW , STR_7075_TOGGLE_LARGE_SMALL_WINDOW ) ,
NWidget ( WWT_STICKYBOX , COLOUR_GREY , CFW_STICKY ) ,
EndContainer ( ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PANEL ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_CATEGORY ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE1 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE2 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_EXPS_PRICE3 ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , CFW_TOTAL_PANEL ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_LABELS ) , SetMinimalSize ( 95 , 34 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_VALUES ) , SetMinimalSize ( 86 , 34 ) ,
NWidget ( WWT_EMPTY , COLOUR_GREY , CFW_TOTAL_MAXLOAN ) , SetMinimalSize ( 97 , 0 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , CFW_INCREASE_LOAN ) , SetMinimalSize ( 140 , 12 ) , SetDataTip ( STR_7029_BORROW , STR_7035_INCREASE_SIZE_OF_LOAN ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , CFW_REPAY_LOAN ) , SetMinimalSize ( 140 , 12 ) , SetDataTip ( STR_702A_REPAY , STR_7036_REPAY_PART_OF_LOAN ) ,
EndContainer ( ) ,
} ;
2008-09-30 20:39:50 +00:00
static const Widget _company_finances_small_widgets [ ] = {
2009-03-26 02:02:11 +00:00
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } , // CFW_CLOSEBOX
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 253 , 0 , 13 , STR_700E_FINANCES , STR_018C_WINDOW_TITLE_DRAG_THIS } , // CFW_CAPTION
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 254 , 267 , 0 , 13 , SPR_LARGE_SMALL_WINDOW , STR_7075_TOGGLE_LARGE_SMALL_WINDOW } , // CFW_TOGGLE_SIZE
{ WWT_STICKYBOX , RESIZE_NONE , COLOUR_GREY , 268 , 279 , 0 , 13 , 0x0 , STR_STICKY_BUTTON } , // CFW_STICKY
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_EXPS_PANEL
2009-03-27 01:55:25 +00:00
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_EXPS_CATEGORY
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE1
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE2
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_EXPS_PRICE3
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 279 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_PANEL
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 2 , 96 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_LABELS
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 97 , 182 , 14 , 47 , 0x0 , STR_NULL } , // CFW_TOTAL_VALUES
{ WWT_EMPTY , RESIZE_NONE , COLOUR_GREY , 0 , 0 , 0 , 0 , 0x0 , STR_NULL } , // CFW_TOTAL_MAXLOAN
2009-03-26 02:02:11 +00:00
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 139 , 48 , 59 , STR_7029_BORROW , STR_7035_INCREASE_SIZE_OF_LOAN } , // CFW_INCREASE_LOAN
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 140 , 279 , 48 , 59 , STR_702A_REPAY , STR_7036_REPAY_PART_OF_LOAN } , // CFW_REPAY_LOAN
2004-09-07 21:48:09 +00:00
{ WIDGETS_END } ,
2004-08-09 17:04:08 +00:00
} ;
2008-09-30 20:39:50 +00:00
struct CompanyFinancesWindow : Window {
2008-05-16 07:34:48 +00:00
bool small ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
CompanyFinancesWindow ( const WindowDesc * desc , CompanyID company , bool show_small ,
2008-05-16 07:34:48 +00:00
bool show_stickied , int top , int left ) :
2008-09-30 20:39:50 +00:00
Window ( desc , company ) ,
2008-05-16 07:34:48 +00:00
small ( show_small )
{
2009-02-09 02:33:10 +00:00
this - > owner = ( Owner ) this - > window_number ;
2007-08-31 23:02:16 +00:00
2008-05-16 07:34:48 +00:00
if ( show_stickied ) this - > flags4 | = WF_STICKY ;
2004-08-09 17:04:08 +00:00
2008-05-16 07:34:48 +00:00
/* Check if repositioning from default is required */
if ( top ! = FIRST_GUI_CALL & & left ! = FIRST_GUI_CALL ) {
this - > top = top ;
this - > left = left ;
}
2008-05-23 23:02:13 +00:00
this - > FindWindowPlacementAndResize ( desc ) ;
2008-05-16 07:34:48 +00:00
}
2004-08-09 17:04:08 +00:00
2008-05-16 07:34:48 +00:00
virtual void OnPaint ( )
{
2008-09-30 20:39:50 +00:00
CompanyID company = ( CompanyID ) this - > window_number ;
const Company * c = GetCompany ( company ) ;
2008-05-16 07:34:48 +00:00
2009-01-31 21:27:36 +00:00
if ( ! small ) {
int type = _settings_client . gui . expenses_layout ;
2009-03-27 22:59:43 +00:00
if ( this - > widget [ CFW_EXPS_PANEL ] . bottom < this - > widget [ CFW_EXPS_PANEL ] . top ) {
this - > widget [ CFW_EXPS_PANEL ] . bottom = this - > widget [ CFW_EXPS_PANEL ] . top ;
}
2009-03-26 02:02:11 +00:00
int height = this - > widget [ CFW_EXPS_PANEL ] . bottom - this - > widget [ CFW_EXPS_PANEL ] . top + 1 ;
2009-01-31 21:27:36 +00:00
if ( _expenses_list_types [ type ] . height + 26 ! = height ) {
this - > SetDirty ( ) ;
2009-03-26 02:02:11 +00:00
ResizeWindowForWidget ( this , CFW_EXPS_PANEL , 0 , _expenses_list_types [ type ] . height - height + 26 ) ;
2009-01-31 21:27:36 +00:00
this - > SetDirty ( ) ;
return ;
}
}
2008-09-30 20:39:50 +00:00
/* Recheck the size of the window as it might need to be resized due to the local company changing */
2009-03-26 02:02:11 +00:00
int new_height = this - > widget [ ( company = = _local_company ) ? CFW_INCREASE_LOAN : CFW_TOTAL_PANEL ] . bottom + 1 ;
2008-05-16 07:34:48 +00:00
if ( this - > height ! = new_height ) {
/* Make window dirty before and after resizing */
this - > SetDirty ( ) ;
this - > height = new_height ;
this - > SetDirty ( ) ;
2009-03-26 02:02:11 +00:00
this - > SetWidgetHiddenState ( CFW_INCREASE_LOAN , company ! = _local_company ) ;
this - > SetWidgetHiddenState ( CFW_REPAY_LOAN , company ! = _local_company ) ;
2008-05-16 07:34:48 +00:00
}
2008-04-09 02:02:39 +00:00
2008-05-16 07:34:48 +00:00
/* Borrow button only shows when there is any more money to loan */
2009-03-26 02:02:11 +00:00
this - > SetWidgetDisabledState ( CFW_INCREASE_LOAN , c - > current_loan = = _economy . max_loan ) ;
2004-08-09 17:04:08 +00:00
2008-05-16 07:34:48 +00:00
/* Repay button only shows when there is any more money to repay */
2009-03-26 02:02:11 +00:00
this - > SetWidgetDisabledState ( CFW_REPAY_LOAN , company ! = _local_company | | c - > current_loan = = 0 ) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > index ) ;
SetDParam ( 1 , c - > index ) ;
2008-05-16 07:34:48 +00:00
SetDParam ( 2 , LOAN_INTERVAL ) ;
2008-05-17 12:48:06 +00:00
this - > DrawWidgets ( ) ;
2008-04-09 02:16:04 +00:00
2009-03-27 01:55:25 +00:00
DrawCompanyEconomyStats ( c , this - > small , this - > widget ) ;
2008-05-16 07:34:48 +00:00
}
2008-04-09 02:16:04 +00:00
2008-05-16 07:34:48 +00:00
virtual void OnClick ( Point pt , int widget )
{
switch ( widget ) {
2009-03-26 02:02:11 +00:00
case CFW_TOGGLE_SIZE : { // toggle size
2008-05-16 07:34:48 +00:00
bool new_mode = ! this - > small ;
bool stickied = ! ! ( this - > flags4 & WF_STICKY ) ;
int oldtop = this - > top ; ///< current top position of the window before closing it
int oldleft = this - > left ; ///< current left position of the window before closing it
2008-09-30 20:39:50 +00:00
CompanyID company = ( CompanyID ) this - > window_number ;
2008-05-16 07:34:48 +00:00
delete this ;
/* Open up the (toggled size) Finance window at the same position as the previous */
2008-09-30 20:39:50 +00:00
DoShowCompanyFinances ( company , new_mode , stickied , oldtop , oldleft ) ;
2008-04-09 02:16:04 +00:00
}
2004-08-09 17:04:08 +00:00
break ;
2008-05-16 07:34:48 +00:00
2009-03-26 02:02:11 +00:00
case CFW_INCREASE_LOAN : // increase loan
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , _ctrl_pressed , CMD_INCREASE_LOAN | CMD_MSG ( STR_702C_CAN_T_BORROW_ANY_MORE_MONEY ) ) ;
2008-05-16 07:34:48 +00:00
break ;
2009-03-26 02:02:11 +00:00
case CFW_REPAY_LOAN : // repay loan
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , _ctrl_pressed , CMD_DECREASE_LOAN | CMD_MSG ( STR_702F_CAN_T_REPAY_LOAN ) ) ;
2008-05-16 07:34:48 +00:00
break ;
}
2004-08-09 17:04:08 +00:00
}
2008-05-16 07:34:48 +00:00
} ;
2004-08-09 17:04:08 +00:00
2009-03-15 15:12:06 +00:00
static const WindowDesc _company_finances_desc (
2009-03-26 02:02:11 +00:00
WDP_AUTO , WDP_AUTO , 407 , 60 , 407 , 60 ,
2007-02-01 15:49:12 +00:00
WC_FINANCES , WC_NONE ,
2005-07-15 15:09:52 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON ,
2009-03-27 22:59:43 +00:00
_company_finances_widgets , _nested_company_finances_widgets , lengthof ( _nested_company_finances_widgets )
2009-03-15 15:12:06 +00:00
) ;
2004-08-09 17:04:08 +00:00
2009-03-15 15:12:06 +00:00
static const WindowDesc _company_finances_small_desc (
2007-07-27 12:49:04 +00:00
WDP_AUTO , WDP_AUTO , 280 , 60 , 280 , 60 ,
2007-02-01 15:49:12 +00:00
WC_FINANCES , WC_NONE ,
2005-07-15 15:09:52 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON ,
2009-03-27 22:59:43 +00:00
_company_finances_small_widgets , _nested_company_finances_small_widgets , lengthof ( _nested_company_finances_small_widgets )
2009-03-15 15:12:06 +00:00
) ;
2004-08-09 17:04:08 +00:00
2008-04-09 02:02:39 +00:00
/**
2008-09-30 20:39:50 +00:00
* Open the small / large finance window of the company
2008-04-09 02:02:39 +00:00
*
2008-09-30 20:39:50 +00:00
* @ param company the company who ' s finances are requested to be seen
2008-04-09 02:02:39 +00:00
* @ param show_small show large or small version opf the window
* @ param show_stickied previous " stickyness " of the window
* @ param top previous top position of the window
* @ param left previous left position of the window
*
2008-09-30 20:39:50 +00:00
* @ pre is company a valid company
2008-04-09 02:02:39 +00:00
*/
2008-09-30 20:39:50 +00:00
static void DoShowCompanyFinances ( CompanyID company , bool show_small , bool show_stickied , int top , int left )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
if ( ! IsValidCompanyID ( company ) ) return ;
2006-10-31 21:15:56 +00:00
2008-09-30 20:39:50 +00:00
if ( BringWindowToFrontById ( WC_FINANCES , company ) ) return ;
new CompanyFinancesWindow ( show_small ? & _company_finances_small_desc : & _company_finances_desc , company , show_small , show_stickied , top , left ) ;
2004-08-09 17:04:08 +00:00
}
2008-09-30 20:39:50 +00:00
void ShowCompanyFinances ( CompanyID company )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
DoShowCompanyFinances ( company , false , false ) ;
2004-08-09 17:04:08 +00:00
}
2006-09-15 12:27:00 +00:00
/* List of colours for the livery window */
static const StringID _colour_dropdown [ ] = {
STR_00D1_DARK_BLUE ,
STR_00D2_PALE_GREEN ,
STR_00D3_PINK ,
STR_00D4_YELLOW ,
STR_00D5_RED ,
STR_00D6_LIGHT_BLUE ,
STR_00D7_GREEN ,
STR_00D8_DARK_GREEN ,
STR_00D9_BLUE ,
STR_00DA_CREAM ,
STR_00DB_MAUVE ,
STR_00DC_PURPLE ,
STR_00DD_ORANGE ,
STR_00DE_BROWN ,
STR_00DF_GREY ,
STR_00E0_WHITE ,
} ;
/* Association of liveries to livery classes */
2008-05-14 22:52:12 +00:00
static const LiveryClass _livery_class [ LS_END ] = {
2006-09-15 12:27:00 +00:00
LC_OTHER ,
2008-01-16 11:25:15 +00:00
LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL , LC_RAIL ,
2006-09-15 12:27:00 +00:00
LC_ROAD , LC_ROAD ,
LC_SHIP , LC_SHIP ,
LC_AIRCRAFT , LC_AIRCRAFT , LC_AIRCRAFT ,
2007-05-27 09:33:41 +00:00
LC_ROAD , LC_ROAD ,
2006-09-15 12:27:00 +00:00
} ;
2008-04-12 22:19:34 +00:00
class DropDownListColourItem : public DropDownListItem {
public :
DropDownListColourItem ( int result , bool masked ) : DropDownListItem ( result , masked ) { }
virtual ~ DropDownListColourItem ( ) { }
2008-08-06 07:10:40 +00:00
StringID String ( ) const
2008-04-12 22:19:34 +00:00
{
return _colour_dropdown [ this - > result ] ;
}
2008-08-06 07:10:40 +00:00
uint Height ( uint width ) const
2008-04-12 22:19:34 +00:00
{
return 14 ;
}
2008-08-08 15:49:16 +00:00
2008-08-06 07:10:40 +00:00
bool Selectable ( ) const
{
return true ;
}
2008-04-12 22:19:34 +00:00
2009-03-21 19:31:47 +00:00
void Draw ( int left , int right , int top , int bottom , bool sel , int bg_colour ) const
2008-04-12 22:19:34 +00:00
{
2009-03-21 19:31:47 +00:00
DrawSprite ( SPR_VEH_BUS_SIDE_VIEW , PALETTE_RECOLOUR_START + this - > result , left + 16 , top + 7 ) ;
DrawString ( left + 32 , right - 2 , top + 3 , this - > String ( ) , sel ? TC_WHITE : TC_BLACK ) ;
2008-04-12 22:19:34 +00:00
}
} ;
2009-03-28 04:14:02 +00:00
/** Widgets of the select company livery window. */
enum SelectCompanyLiveryWindowWidgets {
SCLW_WIDGET_CLOSE ,
SCLW_WIDGET_CAPTION ,
SCLW_WIDGET_CLASS_GENERAL ,
SCLW_WIDGET_CLASS_RAIL ,
SCLW_WIDGET_CLASS_ROAD ,
SCLW_WIDGET_CLASS_SHIP ,
SCLW_WIDGET_CLASS_AIRCRAFT ,
SCLW_WIDGET_SPACER_CLASS ,
SCLW_WIDGET_SPACER_DROPDOWN ,
SCLW_WIDGET_PRI_COL_DROPDOWN ,
SCLW_WIDGET_SEC_COL_DROPDOWN ,
SCLW_WIDGET_MATRIX ,
} ;
2008-09-30 20:39:50 +00:00
struct SelectCompanyLiveryWindow : public Window {
2008-05-14 22:52:12 +00:00
private :
uint32 sel ;
LiveryClass livery_class ;
void ShowColourDropDownMenu ( uint32 widget )
{
uint32 used_colours = 0 ;
const Livery * livery ;
LiveryScheme scheme ;
2008-09-30 20:39:50 +00:00
/* Disallow other company colours for the primary colour */
if ( HasBit ( this - > sel , LS_DEFAULT ) & & widget = = SCLW_WIDGET_PRI_COL_DROPDOWN ) {
const Company * c ;
FOR_ALL_COMPANIES ( c ) {
if ( c - > index ! = _local_company ) SetBit ( used_colours , c - > colour ) ;
2008-05-14 22:52:12 +00:00
}
2004-08-09 17:04:08 +00:00
}
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
/* Get the first selected livery to use as the default dropdown item */
for ( scheme = LS_BEGIN ; scheme < LS_END ; scheme + + ) {
if ( HasBit ( this - > sel , scheme ) ) break ;
}
if ( scheme = = LS_END ) scheme = LS_DEFAULT ;
2008-09-30 20:39:50 +00:00
livery = & GetCompany ( ( CompanyID ) this - > window_number ) - > livery [ scheme ] ;
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
DropDownList * list = new DropDownList ( ) ;
for ( uint i = 0 ; i < lengthof ( _colour_dropdown ) ; i + + ) {
list - > push_back ( new DropDownListColourItem ( i , HasBit ( used_colours , i ) ) ) ;
}
2008-04-12 22:19:34 +00:00
2008-09-30 20:39:50 +00:00
ShowDropDownList ( this , list , widget = = SCLW_WIDGET_PRI_COL_DROPDOWN ? livery - > colour1 : livery - > colour2 , widget ) ;
2008-05-14 22:52:12 +00:00
}
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
public :
2008-09-30 20:39:50 +00:00
SelectCompanyLiveryWindow ( const WindowDesc * desc , CompanyID company ) : Window ( desc , company )
2008-05-14 22:52:12 +00:00
{
2009-02-09 02:33:10 +00:00
this - > owner = company ;
2008-05-14 22:52:12 +00:00
this - > livery_class = LC_OTHER ;
this - > sel = 1 ;
2008-09-30 20:39:50 +00:00
this - > LowerWidget ( SCLW_WIDGET_CLASS_GENERAL ) ;
2008-05-14 23:02:05 +00:00
this - > OnInvalidateData ( _loaded_newgrf_features . has_2CC ) ;
2008-05-14 22:52:12 +00:00
this - > FindWindowPlacementAndResize ( desc ) ;
}
2006-10-03 20:16:20 +00:00
2008-05-14 22:52:12 +00:00
virtual void OnPaint ( )
{
2008-09-30 20:39:50 +00:00
const Company * c = GetCompany ( ( CompanyID ) this - > window_number ) ;
2008-05-14 22:52:12 +00:00
LiveryScheme scheme = LS_DEFAULT ;
int y = 51 ;
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
/* Disable dropdown controls if no scheme is selected */
2008-09-30 20:39:50 +00:00
this - > SetWidgetDisabledState ( SCLW_WIDGET_PRI_COL_DROPDOWN , this - > sel = = 0 ) ;
this - > SetWidgetDisabledState ( SCLW_WIDGET_SEC_COL_DROPDOWN , this - > sel = = 0 ) ;
2006-10-03 02:08:15 +00:00
2008-05-14 22:52:12 +00:00
if ( this - > sel ! = 0 ) {
for ( scheme = LS_BEGIN ; scheme < LS_END ; scheme + + ) {
if ( HasBit ( this - > sel , scheme ) ) break ;
2006-09-15 12:27:00 +00:00
}
2008-05-14 22:52:12 +00:00
if ( scheme = = LS_END ) scheme = LS_DEFAULT ;
}
2006-09-15 12:27:00 +00:00
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , STR_00D1_DARK_BLUE + c - > livery [ scheme ] . colour1 ) ;
SetDParam ( 1 , STR_00D1_DARK_BLUE + c - > livery [ scheme ] . colour2 ) ;
2006-09-15 12:27:00 +00:00
2008-05-17 12:48:06 +00:00
this - > DrawWidgets ( ) ;
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
for ( scheme = LS_DEFAULT ; scheme < LS_END ; scheme + + ) {
if ( _livery_class [ scheme ] = = this - > livery_class ) {
bool sel = HasBit ( this - > sel , scheme ) ! = 0 ;
2004-09-11 09:40:19 +00:00
2008-05-14 22:52:12 +00:00
if ( scheme ! = LS_DEFAULT ) {
2008-09-30 20:39:50 +00:00
DrawSprite ( c - > livery [ scheme ] . in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY , PAL_NONE , 2 , y ) ;
2008-05-14 22:52:12 +00:00
}
2004-08-09 17:04:08 +00:00
2009-03-22 12:01:21 +00:00
DrawString ( 15 , 165 , y , STR_LIVERY_DEFAULT + scheme , sel ? TC_WHITE : TC_BLACK ) ;
2006-10-05 15:07:34 +00:00
2009-02-09 02:57:15 +00:00
DrawSprite ( SPR_SQUARE , GENERAL_SPRITE_COLOUR ( c - > livery [ scheme ] . colour1 ) , 152 , y ) ;
2009-03-22 12:01:21 +00:00
DrawString ( 165 , 290 , y , STR_00D1_DARK_BLUE + c - > livery [ scheme ] . colour1 , sel ? TC_WHITE : TC_GOLD ) ;
2006-09-15 12:27:00 +00:00
2008-09-30 20:39:50 +00:00
if ( ! this - > IsWidgetHidden ( SCLW_WIDGET_SEC_COL_DROPDOWN ) ) {
2009-02-09 02:57:15 +00:00
DrawSprite ( SPR_SQUARE , GENERAL_SPRITE_COLOUR ( c - > livery [ scheme ] . colour2 ) , 277 , y ) ;
2009-03-22 12:01:21 +00:00
DrawString ( 290 , this - > width , y , STR_00D1_DARK_BLUE + c - > livery [ scheme ] . colour2 , sel ? TC_WHITE : TC_GOLD ) ;
2006-09-15 12:27:00 +00:00
}
2008-05-14 22:52:12 +00:00
y + = 14 ;
2004-08-09 17:04:08 +00:00
}
}
2008-05-14 22:52:12 +00:00
}
2004-09-11 09:40:19 +00:00
2008-05-14 22:52:12 +00:00
virtual void OnClick ( Point pt , int widget )
{
/* Number of liveries in each class, used to determine the height of the livery window */
static const byte livery_height [ ] = {
1 ,
13 ,
4 ,
2 ,
3 ,
} ;
switch ( widget ) {
/* Livery Class buttons */
2008-09-30 20:39:50 +00:00
case SCLW_WIDGET_CLASS_GENERAL :
case SCLW_WIDGET_CLASS_RAIL :
case SCLW_WIDGET_CLASS_ROAD :
case SCLW_WIDGET_CLASS_SHIP :
case SCLW_WIDGET_CLASS_AIRCRAFT : {
2008-05-14 22:52:12 +00:00
LiveryScheme scheme ;
2008-09-30 20:39:50 +00:00
this - > RaiseWidget ( this - > livery_class + SCLW_WIDGET_CLASS_GENERAL ) ;
this - > livery_class = ( LiveryClass ) ( widget - SCLW_WIDGET_CLASS_GENERAL ) ;
2008-05-14 22:52:12 +00:00
this - > sel = 0 ;
2008-09-30 20:39:50 +00:00
this - > LowerWidget ( this - > livery_class + SCLW_WIDGET_CLASS_GENERAL ) ;
2008-05-14 22:52:12 +00:00
/* Select the first item in the list */
for ( scheme = LS_DEFAULT ; scheme < LS_END ; scheme + + ) {
if ( _livery_class [ scheme ] = = this - > livery_class ) {
this - > sel = 1 < < scheme ;
break ;
2006-09-15 12:27:00 +00:00
}
}
2008-05-14 22:52:12 +00:00
this - > height = 49 + livery_height [ this - > livery_class ] * 14 ;
2008-09-30 20:39:50 +00:00
this - > widget [ SCLW_WIDGET_MATRIX ] . bottom = this - > height - 1 ;
this - > widget [ SCLW_WIDGET_MATRIX ] . data = livery_height [ this - > livery_class ] < < 8 | 1 ;
2008-05-14 22:52:12 +00:00
MarkWholeScreenDirty ( ) ;
break ;
}
2006-09-15 12:27:00 +00:00
2009-03-15 00:32:18 +00:00
case SCLW_WIDGET_PRI_COL_DROPDOWN : // First colour dropdown
2008-09-30 20:39:50 +00:00
ShowColourDropDownMenu ( SCLW_WIDGET_PRI_COL_DROPDOWN ) ;
2008-05-14 22:52:12 +00:00
break ;
2006-09-15 12:27:00 +00:00
2009-03-15 00:32:18 +00:00
case SCLW_WIDGET_SEC_COL_DROPDOWN : // Second colour dropdown
2008-09-30 20:39:50 +00:00
ShowColourDropDownMenu ( SCLW_WIDGET_SEC_COL_DROPDOWN ) ;
2008-05-14 22:52:12 +00:00
break ;
2006-09-15 12:27:00 +00:00
2008-09-30 20:39:50 +00:00
case SCLW_WIDGET_MATRIX : {
2008-05-14 22:52:12 +00:00
LiveryScheme scheme ;
LiveryScheme j = ( LiveryScheme ) ( ( pt . y - 48 ) / 14 ) ;
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
for ( scheme = LS_BEGIN ; scheme < = j ; scheme + + ) {
if ( _livery_class [ scheme ] ! = this - > livery_class ) j + + ;
if ( scheme > = LS_END ) return ;
}
if ( j > = LS_END ) return ;
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
/* If clicking on the left edge, toggle using the livery */
if ( pt . x < 10 ) {
2009-02-09 02:57:15 +00:00
DoCommandP ( 0 , j | ( 2 < < 8 ) , ! GetCompany ( ( CompanyID ) this - > window_number ) - > livery [ j ] . in_use , CMD_SET_COMPANY_COLOUR ) ;
2008-05-14 22:52:12 +00:00
}
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
if ( _ctrl_pressed ) {
ToggleBit ( this - > sel , j ) ;
} else {
this - > sel = 1 < < j ;
2004-08-09 17:04:08 +00:00
}
2008-05-14 22:52:12 +00:00
this - > SetDirty ( ) ;
break ;
2004-08-09 17:04:08 +00:00
}
2006-09-15 12:27:00 +00:00
}
2008-05-14 22:52:12 +00:00
}
2006-09-15 12:27:00 +00:00
2008-05-14 22:52:12 +00:00
virtual void OnDropdownSelect ( int widget , int index )
{
for ( LiveryScheme scheme = LS_DEFAULT ; scheme < LS_END ; scheme + + ) {
if ( HasBit ( this - > sel , scheme ) ) {
2009-02-09 02:57:15 +00:00
DoCommandP ( 0 , scheme | ( widget = = SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256 ) , index , CMD_SET_COMPANY_COLOUR ) ;
2006-09-15 12:27:00 +00:00
}
2004-08-09 17:04:08 +00:00
}
}
2008-05-14 23:02:05 +00:00
virtual void OnInvalidateData ( int data = 0 )
{
static bool has2cc = true ;
if ( has2cc = = ! ! data ) return ;
has2cc = ! ! data ;
2008-09-30 20:39:50 +00:00
int r = this - > widget [ has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN ] . right ;
this - > SetWidgetHiddenState ( SCLW_WIDGET_SEC_COL_DROPDOWN , ! has2cc ) ;
this - > widget [ SCLW_WIDGET_CAPTION ] . right = r ;
this - > widget [ SCLW_WIDGET_SPACER_CLASS ] . right = r ;
this - > widget [ SCLW_WIDGET_MATRIX ] . right = r ;
2008-05-14 23:02:05 +00:00
this - > width = r + 1 ;
}
2008-05-14 22:52:12 +00:00
} ;
2004-08-09 17:04:08 +00:00
2009-03-28 04:14:02 +00:00
static const NWidgetPart _nested_select_company_livery_widgets [ ] = {
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_CLOSEBOX , COLOUR_GREY , SCLW_WIDGET_CLOSE ) ,
NWidget ( WWT_CAPTION , COLOUR_GREY , SCLW_WIDGET_CAPTION ) , SetMinimalSize ( 389 , 14 ) , SetDataTip ( STR_7007_NEW_COLOUR_SCHEME , STR_018C_WINDOW_TITLE_DRAG_THIS ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCLW_WIDGET_CLASS_GENERAL ) , SetMinimalSize ( 22 , 22 ) , SetDataTip ( SPR_IMG_COMPANY_GENERAL , STR_LIVERY_GENERAL_TIP ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCLW_WIDGET_CLASS_RAIL ) , SetMinimalSize ( 22 , 22 ) , SetDataTip ( SPR_IMG_TRAINLIST , STR_LIVERY_TRAIN_TIP ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCLW_WIDGET_CLASS_ROAD ) , SetMinimalSize ( 22 , 22 ) , SetDataTip ( SPR_IMG_TRUCKLIST , STR_LIVERY_ROADVEH_TIP ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCLW_WIDGET_CLASS_SHIP ) , SetMinimalSize ( 22 , 22 ) , SetDataTip ( SPR_IMG_SHIPLIST , STR_LIVERY_SHIP_TIP ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCLW_WIDGET_CLASS_AIRCRAFT ) , SetMinimalSize ( 22 , 22 ) , SetDataTip ( SPR_IMG_AIRPLANESLIST , STR_LIVERY_AIRCRAFT_TIP ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , SCLW_WIDGET_SPACER_CLASS ) , SetMinimalSize ( 290 , 22 ) , EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , SCLW_WIDGET_SPACER_DROPDOWN ) , SetMinimalSize ( 150 , 12 ) , EndContainer ( ) ,
NWidget ( WWT_DROPDOWN , COLOUR_GREY , SCLW_WIDGET_PRI_COL_DROPDOWN ) , SetMinimalSize ( 125 , 12 ) , SetDataTip ( STR_02BD , STR_LIVERY_PRIMARY_TIP ) ,
NWidget ( WWT_DROPDOWN , COLOUR_GREY , SCLW_WIDGET_SEC_COL_DROPDOWN ) , SetMinimalSize ( 125 , 12 ) , SetDataTip ( STR_02E1 , STR_LIVERY_SECONDARY_TIP ) ,
EndContainer ( ) ,
NWidget ( WWT_MATRIX , COLOUR_GREY , SCLW_WIDGET_MATRIX ) , SetMinimalSize ( 400 , 15 ) , SetDataTip ( ( 1 < < 8 ) | 1 , STR_LIVERY_PANEL_TIP ) ,
} ;
2008-09-30 20:39:50 +00:00
static const Widget _select_company_livery_widgets [ ] = {
2009-02-09 03:07:03 +00:00
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } ,
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 399 , 0 , 13 , STR_7007_NEW_COLOUR_SCHEME , STR_018C_WINDOW_TITLE_DRAG_THIS } ,
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 0 , 21 , 14 , 35 , SPR_IMG_COMPANY_GENERAL , STR_LIVERY_GENERAL_TIP } ,
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 22 , 43 , 14 , 35 , SPR_IMG_TRAINLIST , STR_LIVERY_TRAIN_TIP } ,
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 44 , 65 , 14 , 35 , SPR_IMG_TRUCKLIST , STR_LIVERY_ROADVEH_TIP } ,
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 66 , 87 , 14 , 35 , SPR_IMG_SHIPLIST , STR_LIVERY_SHIP_TIP } ,
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 88 , 109 , 14 , 35 , SPR_IMG_AIRPLANESLIST , STR_LIVERY_AIRCRAFT_TIP } ,
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 110 , 399 , 14 , 35 , 0x0 , STR_NULL } ,
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 149 , 36 , 47 , 0x0 , STR_NULL } ,
{ WWT_DROPDOWN , RESIZE_NONE , COLOUR_GREY , 150 , 274 , 36 , 47 , STR_02BD , STR_LIVERY_PRIMARY_TIP } ,
{ WWT_DROPDOWN , RESIZE_NONE , COLOUR_GREY , 275 , 399 , 36 , 47 , STR_02E1 , STR_LIVERY_SECONDARY_TIP } ,
{ WWT_MATRIX , RESIZE_NONE , COLOUR_GREY , 0 , 399 , 48 , 48 + 1 * 14 , ( 1 < < 8 ) | 1 , STR_LIVERY_PANEL_TIP } ,
2006-09-15 12:27:00 +00:00
{ WIDGETS_END } ,
2004-08-09 17:04:08 +00:00
} ;
2009-03-15 15:12:06 +00:00
static const WindowDesc _select_company_livery_desc (
2008-05-14 23:02:05 +00:00
WDP_AUTO , WDP_AUTO , 400 , 49 + 1 * 14 , 400 , 49 + 1 * 14 ,
2009-02-09 02:57:15 +00:00
WC_COMPANY_COLOUR , WC_NONE ,
2006-10-05 15:07:34 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET ,
2009-03-28 04:14:02 +00:00
_select_company_livery_widgets , _nested_select_company_livery_widgets , lengthof ( _nested_select_company_livery_widgets )
2009-03-15 15:12:06 +00:00
) ;
2004-08-09 17:04:08 +00:00
2007-03-02 01:17:11 +00:00
/**
2008-09-30 20:39:50 +00:00
* Draws the face of a company manager ' s face .
* @ param cmf the company manager ' s face
2009-02-09 02:57:15 +00:00
* @ param colour the ( background ) colour of the gradient
2007-03-02 01:17:11 +00:00
* @ param x x - position to draw the face
* @ param y y - position to draw the face
*/
2009-02-09 02:57:15 +00:00
void DrawCompanyManagerFace ( CompanyManagerFace cmf , int colour , int x , int y )
2007-03-02 01:17:11 +00:00
{
2008-09-30 20:39:50 +00:00
GenderEthnicity ge = ( GenderEthnicity ) GetCompanyManagerFaceBits ( cmf , CMFV_GEN_ETHN , GE_WM ) ;
2007-03-02 01:17:11 +00:00
2008-09-30 20:39:50 +00:00
bool has_moustache = ! HasBit ( ge , GENDER_FEMALE ) & & GetCompanyManagerFaceBits ( cmf , CMFV_HAS_MOUSTACHE , ge ) ! = 0 ;
bool has_tie_earring = ! HasBit ( ge , GENDER_FEMALE ) | | GetCompanyManagerFaceBits ( cmf , CMFV_HAS_TIE_EARRING , ge ) ! = 0 ;
bool has_glasses = GetCompanyManagerFaceBits ( cmf , CMFV_HAS_GLASSES , ge ) ! = 0 ;
2007-03-02 01:17:11 +00:00
SpriteID pal ;
2007-10-15 19:59:27 +00:00
/* Modify eye colour palette only if 2 or more valid values exist */
2008-09-30 20:39:50 +00:00
if ( _cmf_info [ CMFV_EYE_COLOUR ] . valid_values [ ge ] < 2 ) {
2007-10-15 19:59:27 +00:00
pal = PAL_NONE ;
} else {
2008-09-30 20:39:50 +00:00
switch ( GetCompanyManagerFaceBits ( cmf , CMFV_EYE_COLOUR , ge ) ) {
2007-10-15 19:59:27 +00:00
default : NOT_REACHED ( ) ;
case 0 : pal = PALETTE_TO_BROWN ; break ;
case 1 : pal = PALETTE_TO_BLUE ; break ;
case 2 : pal = PALETTE_TO_GREEN ; break ;
}
2007-03-02 01:17:11 +00:00
}
/* Draw the gradient (background) */
2009-02-09 02:57:15 +00:00
DrawSprite ( SPR_GRADIENT , GENERAL_SPRITE_COLOUR ( colour ) , x , y ) ;
2007-03-02 01:17:11 +00:00
2008-09-30 20:39:50 +00:00
for ( CompanyManagerFaceVariable cmfv = CMFV_CHEEKS ; cmfv < CMFV_END ; cmfv + + ) {
switch ( cmfv ) {
case CMFV_MOUSTACHE : if ( ! has_moustache ) continue ; break ;
2009-03-15 00:32:18 +00:00
case CMFV_LIPS : // FALL THROUGH
2008-09-30 20:39:50 +00:00
case CMFV_NOSE : if ( has_moustache ) continue ; break ;
case CMFV_TIE_EARRING : if ( ! has_tie_earring ) continue ; break ;
case CMFV_GLASSES : if ( ! has_glasses ) continue ; break ;
2007-03-02 01:17:11 +00:00
default : break ;
}
2008-09-30 20:39:50 +00:00
DrawSprite ( GetCompanyManagerFaceSprite ( cmf , cmfv , ge ) , ( cmfv = = CMFV_EYEBROWS ) ? pal : PAL_NONE , x , y ) ;
2007-03-02 01:17:11 +00:00
}
}
2009-03-28 04:14:02 +00:00
/**
* Names of the widgets . Keep them in the same order as in the widget array .
* Do not change the order of the widgets from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R ,
* this order is needed for the WE_CLICK event of DrawFaceStringLabel ( ) .
*/
enum SelectCompanyManagerFaceWidgets {
SCMFW_WIDGET_CLOSEBOX = 0 ,
SCMFW_WIDGET_CAPTION ,
SCMFW_WIDGET_TOGGLE_LARGE_SMALL ,
SCMFW_WIDGET_SELECT_FACE ,
SCMFW_WIDGET_CANCEL ,
SCMFW_WIDGET_ACCEPT ,
SCMFW_WIDGET_MALE ,
SCMFW_WIDGET_FEMALE ,
SCMFW_WIDGET_RANDOM_NEW_FACE ,
SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON ,
/* from here is the advanced company manager face selection window */
SCMFW_WIDGET_LOAD ,
SCMFW_WIDGET_FACECODE ,
SCMFW_WIDGET_SAVE ,
SCMFW_WIDGET_ETHNICITY_EUR ,
SCMFW_WIDGET_ETHNICITY_AFR ,
SCMFW_WIDGET_HAS_MOUSTACHE_EARRING ,
SCMFW_WIDGET_HAS_GLASSES ,
SCMFW_WIDGET_EYECOLOUR_L ,
SCMFW_WIDGET_EYECOLOUR ,
SCMFW_WIDGET_EYECOLOUR_R ,
SCMFW_WIDGET_CHIN_L ,
SCMFW_WIDGET_CHIN ,
SCMFW_WIDGET_CHIN_R ,
SCMFW_WIDGET_EYEBROWS_L ,
SCMFW_WIDGET_EYEBROWS ,
SCMFW_WIDGET_EYEBROWS_R ,
SCMFW_WIDGET_LIPS_MOUSTACHE_L ,
SCMFW_WIDGET_LIPS_MOUSTACHE ,
SCMFW_WIDGET_LIPS_MOUSTACHE_R ,
SCMFW_WIDGET_NOSE_L ,
SCMFW_WIDGET_NOSE ,
SCMFW_WIDGET_NOSE_R ,
SCMFW_WIDGET_HAIR_L ,
SCMFW_WIDGET_HAIR ,
SCMFW_WIDGET_HAIR_R ,
SCMFW_WIDGET_JACKET_L ,
SCMFW_WIDGET_JACKET ,
SCMFW_WIDGET_JACKET_R ,
SCMFW_WIDGET_COLLAR_L ,
SCMFW_WIDGET_COLLAR ,
SCMFW_WIDGET_COLLAR_R ,
SCMFW_WIDGET_TIE_EARRING_L ,
SCMFW_WIDGET_TIE_EARRING ,
SCMFW_WIDGET_TIE_EARRING_R ,
SCMFW_WIDGET_GLASSES_L ,
SCMFW_WIDGET_GLASSES ,
SCMFW_WIDGET_GLASSES_R ,
} ;
static const NWidgetPart _nested_select_company_manager_face_widgets [ ] = {
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_CLOSEBOX , COLOUR_GREY , SCMFW_WIDGET_CLOSEBOX ) ,
NWidget ( WWT_CAPTION , COLOUR_GREY , SCMFW_WIDGET_CAPTION ) , SetMinimalSize ( 164 , 14 ) , SetDataTip ( STR_7043_FACE_SELECTION , STR_018C_WINDOW_TITLE_DRAG_THIS ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCMFW_WIDGET_TOGGLE_LARGE_SMALL ) , SetMinimalSize ( 15 , 14 ) , SetDataTip ( SPR_LARGE_SMALL_WINDOW , STR_FACE_ADVANCED_TIP ) ,
EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , SCMFW_WIDGET_SELECT_FACE ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 123 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_RANDOM_NEW_FACE ) , SetMinimalSize ( 92 , 12 ) , SetDataTip ( STR_7046_NEW_FACE , STR_704B_GENERATE_RANDOM_NEW_FACE ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 1 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON ) , SetMinimalSize ( 93 , 12 ) , SetDataTip ( STR_FACE_ADVANCED , STR_FACE_ADVANCED_TIP ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 47 ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_MALE ) , SetMinimalSize ( 93 , 12 ) , SetDataTip ( STR_7044_MALE , STR_7049_SELECT_MALE_FACES ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_FEMALE ) , SetMinimalSize ( 93 , 12 ) , SetDataTip ( STR_7045_FEMALE , STR_704A_SELECT_FEMALE_FACES ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 52 ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_CANCEL ) , SetMinimalSize ( 95 , 12 ) , SetDataTip ( STR_012E_CANCEL , STR_7047_CANCEL_NEW_FACE_SELECTION ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_ACCEPT ) , SetMinimalSize ( 95 , 12 ) , SetDataTip ( STR_012F_OK , STR_7048_ACCEPT_NEW_FACE_SELECTION ) ,
EndContainer ( ) ,
} ;
2008-09-30 20:39:50 +00:00
/** Widget description for the normal/simple company manager face selection dialog */
static const Widget _select_company_manager_face_widgets [ ] = {
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } , // SCMFW_WIDGET_CLOSEBOX
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 174 , 0 , 13 , STR_7043_FACE_SELECTION , STR_018C_WINDOW_TITLE_DRAG_THIS } , // SCMFW_WIDGET_CAPTION
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 189 , 0 , 13 , SPR_LARGE_SMALL_WINDOW , STR_FACE_ADVANCED_TIP } , // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 189 , 14 , 150 , 0x0 , STR_NULL } , // SCMFW_WIDGET_SELECT_FACE
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 94 , 151 , 162 , STR_012E_CANCEL , STR_7047_CANCEL_NEW_FACE_SELECTION } , // SCMFW_WIDGET_CANCEL
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 189 , 151 , 162 , STR_012F_OK , STR_7048_ACCEPT_NEW_FACE_SELECTION } , // SCMFW_WIDGET_ACCEPT
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 187 , 75 , 86 , STR_7044_MALE , STR_7049_SELECT_MALE_FACES } , // SCMFW_WIDGET_MALE
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 187 , 87 , 98 , STR_7045_FEMALE , STR_704A_SELECT_FEMALE_FACES } , // SCMFW_WIDGET_FEMALE
{ 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
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 187 , 16 , 27 , STR_FACE_ADVANCED , STR_FACE_ADVANCED_TIP } , // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
2007-10-15 19:59:27 +00:00
{ WIDGETS_END } ,
} ;
2009-03-28 04:14:02 +00:00
static const NWidgetPart _nested_select_company_manager_face_adv_widgets [ ] = {
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_CLOSEBOX , COLOUR_GREY , SCMFW_WIDGET_CLOSEBOX ) ,
NWidget ( WWT_CAPTION , COLOUR_GREY , SCMFW_WIDGET_CAPTION ) , SetMinimalSize ( 194 , 14 ) , SetDataTip ( STR_7043_FACE_SELECTION , STR_018C_WINDOW_TITLE_DRAG_THIS ) ,
NWidget ( WWT_IMGBTN , COLOUR_GREY , SCMFW_WIDGET_TOGGLE_LARGE_SMALL ) , SetMinimalSize ( 15 , 14 ) , SetDataTip ( SPR_LARGE_SMALL_WINDOW , STR_FACE_SIMPLE_TIP ) ,
EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , SCMFW_WIDGET_SELECT_FACE ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 123 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_RANDOM_NEW_FACE ) , SetMinimalSize ( 92 , 12 ) , SetDataTip ( STR_RANDOM , STR_704B_GENERATE_RANDOM_NEW_FACE ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 9 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_LOAD ) , SetMinimalSize ( 92 , 12 ) , SetDataTip ( STR_FACE_LOAD , STR_FACE_LOAD_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_FACECODE ) , SetMinimalSize ( 92 , 12 ) , SetDataTip ( STR_FACE_FACECODE , STR_FACE_FACECODE_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_SAVE ) , SetMinimalSize ( 92 , 12 ) , SetDataTip ( STR_FACE_SAVE , STR_FACE_SAVE_TIP ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 14 ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 1 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON ) , SetMinimalSize ( 123 , 12 ) , SetDataTip ( STR_FACE_SIMPLE , STR_FACE_SIMPLE_TIP ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 4 ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 1 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_MALE ) , SetMinimalSize ( 61 , 12 ) , SetDataTip ( STR_7044_MALE , STR_7049_SELECT_MALE_FACES ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_FEMALE ) , SetMinimalSize ( 61 , 12 ) , SetDataTip ( STR_7045_FEMALE , STR_704A_SELECT_FEMALE_FACES ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_ETHNICITY_EUR ) , SetMinimalSize ( 61 , 12 ) , SetDataTip ( STR_FACE_EUROPEAN , STR_FACE_SELECT_EUROPEAN ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , SCMFW_WIDGET_ETHNICITY_AFR ) , SetMinimalSize ( 61 , 12 ) , SetDataTip ( STR_FACE_AFRICAN , STR_FACE_SELECT_AFRICAN ) ,
EndContainer ( ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 80 , 0 ) ,
NWidget ( NWID_VERTICAL ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_HAS_MOUSTACHE_EARRING ) , SetMinimalSize ( 43 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_MOUSTACHE_EARRING_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_HAS_GLASSES ) , SetMinimalSize ( 43 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_GLASSES_TIP ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_HAIR_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_HAIR_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_HAIR ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_HAIR_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_HAIR_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_HAIR_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_EYEBROWS_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_EYEBROWS_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_EYEBROWS ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_EYEBROWS_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_EYEBROWS_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_EYEBROWS_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_EYECOLOUR_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_EYECOLOUR_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_EYECOLOUR ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_EYECOLOUR_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_EYECOLOUR_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_EYECOLOUR_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_GLASSES_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_GLASSES_TIP_2 ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_GLASSES ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_GLASSES_TIP_2 ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_GLASSES_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_GLASSES_TIP_2 ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_NOSE_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_NOSE_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_NOSE ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_NOSE_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_NOSE_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_NOSE_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_LIPS_MOUSTACHE_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_LIPS_MOUSTACHE_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_LIPS_MOUSTACHE ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_LIPS_MOUSTACHE_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_LIPS_MOUSTACHE_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_LIPS_MOUSTACHE_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_CHIN_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_CHIN_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_CHIN ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_CHIN_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_CHIN_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_CHIN_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_JACKET_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_JACKET_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_JACKET ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_JACKET_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_JACKET_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_JACKET_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_COLLAR_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_COLLAR_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_COLLAR ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_COLLAR_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_COLLAR_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_COLLAR_TIP ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_TIE_EARRING_L ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_LEFT , STR_FACE_TIE_EARRING_TIP ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_TIE_EARRING ) , SetMinimalSize ( 25 , 12 ) , SetDataTip ( STR_EMPTY , STR_FACE_TIE_EARRING_TIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , SCMFW_WIDGET_TIE_EARRING_R ) , SetMinimalSize ( 9 , 12 ) , SetDataTip ( SPR_ARROW_RIGHT , STR_FACE_TIE_EARRING_TIP ) ,
EndContainer ( ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 0 , 2 ) ,
EndContainer ( ) ,
NWidget ( NWID_SPACER ) , SetMinimalSize ( 2 , 0 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_CANCEL ) , SetMinimalSize ( 95 , 12 ) , SetDataTip ( STR_012E_CANCEL , STR_7047_CANCEL_NEW_FACE_SELECTION ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , SCMFW_WIDGET_ACCEPT ) , SetMinimalSize ( 125 , 12 ) , SetDataTip ( STR_012F_OK , STR_7048_ACCEPT_NEW_FACE_SELECTION ) ,
EndContainer ( ) ,
} ;
2008-09-30 20:39:50 +00:00
/** Widget description for the advanced company manager face selection dialog */
static const Widget _select_company_manager_face_adv_widgets [ ] = {
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } , // SCMFW_WIDGET_CLOSEBOX
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 204 , 0 , 13 , STR_7043_FACE_SELECTION , STR_018C_WINDOW_TITLE_DRAG_THIS } , // SCMFW_WIDGET_CAPTION
{ WWT_IMGBTN , RESIZE_NONE , COLOUR_GREY , 205 , 219 , 0 , 13 , SPR_LARGE_SMALL_WINDOW , STR_FACE_SIMPLE_TIP } , // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 219 , 14 , 207 , 0x0 , STR_NULL } , // SCMFW_WIDGET_SELECT_FACE
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 94 , 208 , 219 , STR_012E_CANCEL , STR_7047_CANCEL_NEW_FACE_SELECTION } , // SCMFW_WIDGET_CANCEL
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 219 , 208 , 219 , STR_012F_OK , STR_7048_ACCEPT_NEW_FACE_SELECTION } , // SCMFW_WIDGET_ACCEPT
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 96 , 156 , 32 , 43 , STR_7044_MALE , STR_7049_SELECT_MALE_FACES } , // SCMFW_WIDGET_MALE
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 157 , 217 , 32 , 43 , STR_7045_FEMALE , STR_704A_SELECT_FEMALE_FACES } , // SCMFW_WIDGET_FEMALE
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 2 , 93 , 137 , 148 , STR_RANDOM , STR_704B_GENERATE_RANDOM_NEW_FACE } , // SCMFW_WIDGET_RANDOM_NEW_FACE
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 95 , 217 , 16 , 27 , STR_FACE_SIMPLE , STR_FACE_SIMPLE_TIP } , // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 2 , 93 , 158 , 169 , STR_FACE_LOAD , STR_FACE_LOAD_TIP } , // SCMFW_WIDGET_LOAD
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 2 , 93 , 170 , 181 , STR_FACE_FACECODE , STR_FACE_FACECODE_TIP } , // SCMFW_WIDGET_FACECODE
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 2 , 93 , 182 , 193 , STR_FACE_SAVE , STR_FACE_SAVE_TIP } , // SCMFW_WIDGET_SAVE
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 96 , 156 , 46 , 57 , STR_FACE_EUROPEAN , STR_FACE_SELECT_EUROPEAN } , // SCMFW_WIDGET_ETHNICITY_EUR
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 157 , 217 , 46 , 57 , STR_FACE_AFRICAN , STR_FACE_SELECT_AFRICAN } , // SCMFW_WIDGET_ETHNICITY_AFR
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 175 , 217 , 60 , 71 , STR_EMPTY , STR_FACE_MOUSTACHE_EARRING_TIP } , // SCMFW_WIDGET_HAS_MOUSTACHE_EARRING
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 175 , 217 , 72 , 83 , STR_EMPTY , STR_FACE_GLASSES_TIP } , // SCMFW_WIDGET_HAS_GLASSES
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 110 , 121 , SPR_ARROW_LEFT , STR_FACE_EYECOLOUR_TIP } , // SCMFW_WIDGET_EYECOLOUR_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 110 , 121 , STR_EMPTY , STR_FACE_EYECOLOUR_TIP } , // SCMFW_WIDGET_EYECOLOUR
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 110 , 121 , SPR_ARROW_RIGHT , STR_FACE_EYECOLOUR_TIP } , // SCMFW_WIDGET_EYECOLOUR_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 158 , 169 , SPR_ARROW_LEFT , STR_FACE_CHIN_TIP } , // SCMFW_WIDGET_CHIN_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 158 , 169 , STR_EMPTY , STR_FACE_CHIN_TIP } , // SCMFW_WIDGET_CHIN
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 158 , 169 , SPR_ARROW_RIGHT , STR_FACE_CHIN_TIP } , // SCMFW_WIDGET_CHIN_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 98 , 109 , SPR_ARROW_LEFT , STR_FACE_EYEBROWS_TIP } , // SCMFW_WIDGET_EYEBROWS_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 98 , 109 , STR_EMPTY , STR_FACE_EYEBROWS_TIP } , // SCMFW_WIDGET_EYEBROWS
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 98 , 109 , SPR_ARROW_RIGHT , STR_FACE_EYEBROWS_TIP } , // SCMFW_WIDGET_EYEBROWS_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 146 , 157 , SPR_ARROW_LEFT , STR_FACE_LIPS_MOUSTACHE_TIP } , // SCMFW_WIDGET_LIPS_MOUSTACHE_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 146 , 157 , STR_EMPTY , STR_FACE_LIPS_MOUSTACHE_TIP } , // SCMFW_WIDGET_LIPS_MOUSTACHE
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 146 , 157 , SPR_ARROW_RIGHT , STR_FACE_LIPS_MOUSTACHE_TIP } , // SCMFW_WIDGET_LIPS_MOUSTACHE_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 134 , 145 , SPR_ARROW_LEFT , STR_FACE_NOSE_TIP } , // SCMFW_WIDGET_NOSE_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 134 , 145 , STR_EMPTY , STR_FACE_NOSE_TIP } , // SCMFW_WIDGET_NOSE
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 134 , 145 , SPR_ARROW_RIGHT , STR_FACE_NOSE_TIP } , // SCMFW_WIDGET_NOSE_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 86 , 97 , SPR_ARROW_LEFT , STR_FACE_HAIR_TIP } , // SCMFW_WIDGET_HAIR_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 86 , 97 , STR_EMPTY , STR_FACE_HAIR_TIP } , // SCMFW_WIDGET_HAIR
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 86 , 97 , SPR_ARROW_RIGHT , STR_FACE_HAIR_TIP } , // SCMFW_WIDGET_HAIR_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 170 , 181 , SPR_ARROW_LEFT , STR_FACE_JACKET_TIP } , // SCMFW_WIDGET_JACKET_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 170 , 181 , STR_EMPTY , STR_FACE_JACKET_TIP } , // SCMFW_WIDGET_JACKET
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 170 , 181 , SPR_ARROW_RIGHT , STR_FACE_JACKET_TIP } , // SCMFW_WIDGET_JACKET_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 182 , 193 , SPR_ARROW_LEFT , STR_FACE_COLLAR_TIP } , // SCMFW_WIDGET_COLLAR_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 182 , 193 , STR_EMPTY , STR_FACE_COLLAR_TIP } , // SCMFW_WIDGET_COLLAR
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 182 , 193 , SPR_ARROW_RIGHT , STR_FACE_COLLAR_TIP } , // SCMFW_WIDGET_COLLAR_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 194 , 205 , SPR_ARROW_LEFT , STR_FACE_TIE_EARRING_TIP } , // SCMFW_WIDGET_TIE_EARRING_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 194 , 205 , STR_EMPTY , STR_FACE_TIE_EARRING_TIP } , // SCMFW_WIDGET_TIE_EARRING
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 194 , 205 , SPR_ARROW_RIGHT , STR_FACE_TIE_EARRING_TIP } , // SCMFW_WIDGET_TIE_EARRING_R
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 175 , 183 , 122 , 133 , SPR_ARROW_LEFT , STR_FACE_GLASSES_TIP_2 } , // SCMFW_WIDGET_GLASSES_L
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 184 , 208 , 122 , 133 , STR_EMPTY , STR_FACE_GLASSES_TIP_2 } , // SCMFW_WIDGET_GLASSES
{ WWT_PUSHIMGBTN , RESIZE_NONE , COLOUR_GREY , 209 , 217 , 122 , 133 , SPR_ARROW_RIGHT , STR_FACE_GLASSES_TIP_2 } , // SCMFW_WIDGET_GLASSES_R
2007-10-15 19:59:27 +00:00
{ WIDGETS_END } ,
} ;
2008-09-30 20:39:50 +00:00
class SelectCompanyManagerFaceWindow : public Window
2007-10-15 19:59:27 +00:00
{
2008-09-30 20:39:50 +00:00
CompanyManagerFace face ; ///< company manager face bits
bool advanced ; ///< advanced company manager face selection window
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
GenderEthnicity ge ;
bool is_female ;
bool is_moust_male ;
/**
* Draw dynamic a label to the left of the button and a value in the button
*
* @ param widget_index index of this widget in the window
* @ param str the label which will be draw
* @ param val the value which will be draw
* @ param is_bool_widget is it a bool button
*/
void DrawFaceStringLabel ( byte widget_index , StringID str , uint8 val , bool is_bool_widget )
{
/* Write the label in gold (0x2) to the left of the button. */
2009-03-21 22:22:00 +00:00
DrawString ( 0 , this - > widget [ widget_index ] . left - ( is_bool_widget ? 5 : 14 ) , this - > widget [ widget_index ] . top + 1 , str , TC_GOLD , SA_RIGHT ) ;
2008-05-13 01:05:39 +00:00
if ( ! this - > IsWidgetDisabled ( widget_index ) ) {
if ( is_bool_widget ) {
/* if it a bool button write yes or no */
str = ( val ! = 0 ) ? STR_FACE_YES : STR_FACE_NO ;
} else {
/* else write the value + 1 */
SetDParam ( 0 , val + 1 ) ;
str = STR_JUST_INT ;
}
/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
2009-03-21 22:00:00 +00:00
DrawString ( this - > widget [ widget_index ] . left + this - > IsWidgetLowered ( widget_index ) , this - > widget [ widget_index ] . right - this - > IsWidgetLowered ( widget_index ) ,
this - > widget [ widget_index ] . top + 1 + this - > IsWidgetLowered ( widget_index ) , str , TC_WHITE , SA_CENTER ) ;
2007-10-15 19:59:27 +00:00
}
2008-05-13 01:05:39 +00:00
}
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
void UpdateData ( )
{
2008-09-30 20:39:50 +00:00
this - > ge = ( GenderEthnicity ) GB ( this - > face , _cmf_info [ CMFV_GEN_ETHN ] . offset , _cmf_info [ CMFV_GEN_ETHN ] . length ) ; // get the gender and ethnicity
2008-05-13 01:05:39 +00:00
this - > is_female = HasBit ( this - > ge , GENDER_FEMALE ) ; // get the gender: 0 == male and 1 == female
2008-09-30 20:39:50 +00:00
this - > is_moust_male = ! is_female & & GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_MOUSTACHE , this - > ge ) ! = 0 ; // is a male face with moustache
2007-10-15 19:59:27 +00:00
}
2008-05-13 01:05:39 +00:00
public :
2008-09-30 20:39:50 +00:00
SelectCompanyManagerFaceWindow ( const WindowDesc * desc , Window * parent , bool advanced , int top , int left ) : Window ( desc , parent - > window_number )
2008-05-13 01:05:39 +00:00
{
2008-05-15 19:24:15 +00:00
this - > parent = parent ;
2009-02-09 02:33:10 +00:00
this - > owner = ( Owner ) this - > window_number ;
2008-09-30 20:39:50 +00:00
this - > face = GetCompany ( ( CompanyID ) this - > window_number ) - > face ;
2008-05-13 14:43:33 +00:00
this - > advanced = advanced ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
this - > UpdateData ( ) ;
2004-08-09 17:04:08 +00:00
2008-05-13 01:05:39 +00:00
/* Check if repositioning from default is required */
if ( top ! = FIRST_GUI_CALL & & left ! = FIRST_GUI_CALL ) {
this - > top = top ;
this - > left = left ;
}
2008-05-23 23:02:13 +00:00
this - > FindWindowPlacementAndResize ( desc ) ;
2008-05-13 01:05:39 +00:00
}
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
virtual void OnPaint ( )
{
/* lower the non-selected gender button */
2008-09-30 20:39:50 +00:00
this - > SetWidgetLoweredState ( SCMFW_WIDGET_MALE , ! this - > is_female ) ;
this - > SetWidgetLoweredState ( SCMFW_WIDGET_FEMALE , this - > is_female ) ;
2007-10-15 19:59:27 +00:00
2008-09-30 20:39:50 +00:00
/* advanced company manager face selection window */
2008-05-13 01:05:39 +00:00
if ( this - > advanced ) {
/* lower the non-selected ethnicity button */
2008-09-30 20:39:50 +00:00
this - > SetWidgetLoweredState ( SCMFW_WIDGET_ETHNICITY_EUR , ! HasBit ( this - > ge , ETHNICITY_BLACK ) ) ;
this - > SetWidgetLoweredState ( SCMFW_WIDGET_ETHNICITY_AFR , HasBit ( this - > ge , ETHNICITY_BLACK ) ) ;
2007-10-15 19:59:27 +00:00
2008-04-09 02:02:39 +00:00
2008-09-30 20:39:50 +00:00
/* Disable dynamically the widgets which CompanyManagerFaceVariable has less than 2 options
2009-03-14 18:16:29 +00:00
* ( or in other words you haven ' t any choice ) .
* If the widgets depend on a HAS - variable and this is false the widgets will be disabled , too . */
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Eye colour buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_EYE_COLOUR ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_EYECOLOUR , SCMFW_WIDGET_EYECOLOUR_L , SCMFW_WIDGET_EYECOLOUR_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Chin buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_CHIN ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_CHIN , SCMFW_WIDGET_CHIN_L , SCMFW_WIDGET_CHIN_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Eyebrows buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_EYEBROWS ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_EYEBROWS , SCMFW_WIDGET_EYEBROWS_L , SCMFW_WIDGET_EYEBROWS_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Lips or (if it a male face with a moustache) moustache buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ this - > is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_LIPS_MOUSTACHE , SCMFW_WIDGET_LIPS_MOUSTACHE_L , SCMFW_WIDGET_LIPS_MOUSTACHE_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Nose buttons | male faces with moustache haven't any nose options */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_NOSE ] . valid_values [ this - > ge ] < 2 | | this - > is_moust_male ,
SCMFW_WIDGET_NOSE , SCMFW_WIDGET_NOSE_L , SCMFW_WIDGET_NOSE_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Hair buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_HAIR ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_HAIR , SCMFW_WIDGET_HAIR_L , SCMFW_WIDGET_HAIR_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Jacket buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_JACKET ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_JACKET , SCMFW_WIDGET_JACKET_L , SCMFW_WIDGET_JACKET_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Collar buttons */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_COLLAR ] . valid_values [ this - > ge ] < 2 ,
SCMFW_WIDGET_COLLAR , SCMFW_WIDGET_COLLAR_L , SCMFW_WIDGET_COLLAR_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Tie/earring buttons | female faces without earring haven't any earring options */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_TIE_EARRING ] . valid_values [ this - > ge ] < 2 | |
( this - > is_female & & GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_TIE_EARRING , this - > ge ) = = 0 ) ,
SCMFW_WIDGET_TIE_EARRING , SCMFW_WIDGET_TIE_EARRING_L , SCMFW_WIDGET_TIE_EARRING_R , WIDGET_LIST_END ) ;
2007-10-15 19:59:27 +00:00
2008-05-13 01:05:39 +00:00
/* Glasses buttons | faces without glasses haven't any glasses options */
2008-09-30 20:39:50 +00:00
this - > SetWidgetsDisabledState ( _cmf_info [ CMFV_GLASSES ] . valid_values [ this - > ge ] < 2 | | GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_GLASSES , this - > ge ) = = 0 ,
SCMFW_WIDGET_GLASSES , SCMFW_WIDGET_GLASSES_L , SCMFW_WIDGET_GLASSES_R , WIDGET_LIST_END ) ;
2008-05-13 01:05:39 +00:00
}
2007-10-15 19:59:27 +00:00
2008-05-17 12:48:06 +00:00
this - > DrawWidgets ( ) ;
2008-05-13 01:05:39 +00:00
2008-09-30 20:39:50 +00:00
/* Draw dynamic button value and labels for the advanced company manager face selection window */
2008-05-13 01:05:39 +00:00
if ( this - > advanced ) {
if ( this - > is_female ) {
/* Only for female faces */
2008-09-30 20:39:50 +00:00
this - > DrawFaceStringLabel ( SCMFW_WIDGET_HAS_MOUSTACHE_EARRING , STR_FACE_EARRING , GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_TIE_EARRING , this - > ge ) , true ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_TIE_EARRING , STR_FACE_EARRING , GetCompanyManagerFaceBits ( this - > face , CMFV_TIE_EARRING , this - > ge ) , false ) ;
2007-10-15 19:59:27 +00:00
} else {
2008-05-13 01:05:39 +00:00
/* Only for male faces */
2008-09-30 20:39:50 +00:00
this - > DrawFaceStringLabel ( SCMFW_WIDGET_HAS_MOUSTACHE_EARRING , STR_FACE_MOUSTACHE , GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_MOUSTACHE , this - > ge ) , true ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_TIE_EARRING , STR_FACE_TIE , GetCompanyManagerFaceBits ( this - > face , CMFV_TIE_EARRING , this - > ge ) , false ) ;
2007-10-15 19:59:27 +00:00
}
2008-05-13 01:05:39 +00:00
if ( this - > is_moust_male ) {
/* Only for male faces with moustache */
2008-09-30 20:39:50 +00:00
this - > DrawFaceStringLabel ( SCMFW_WIDGET_LIPS_MOUSTACHE , STR_FACE_MOUSTACHE , GetCompanyManagerFaceBits ( this - > face , CMFV_MOUSTACHE , this - > ge ) , false ) ;
2008-05-13 01:05:39 +00:00
} else {
/* Only for female faces or male faces without moustache */
2008-09-30 20:39:50 +00:00
this - > DrawFaceStringLabel ( SCMFW_WIDGET_LIPS_MOUSTACHE , STR_FACE_LIPS , GetCompanyManagerFaceBits ( this - > face , CMFV_LIPS , this - > ge ) , false ) ;
2008-05-13 01:05:39 +00:00
}
/* For all faces */
2008-09-30 20:39:50 +00:00
this - > DrawFaceStringLabel ( SCMFW_WIDGET_HAS_GLASSES , STR_FACE_GLASSES , GetCompanyManagerFaceBits ( this - > face , CMFV_HAS_GLASSES , this - > ge ) , true ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_HAIR , STR_FACE_HAIR , GetCompanyManagerFaceBits ( this - > face , CMFV_HAIR , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_EYEBROWS , STR_FACE_EYEBROWS , GetCompanyManagerFaceBits ( this - > face , CMFV_EYEBROWS , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_EYECOLOUR , STR_FACE_EYECOLOUR , GetCompanyManagerFaceBits ( this - > face , CMFV_EYE_COLOUR , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_GLASSES , STR_FACE_GLASSES , GetCompanyManagerFaceBits ( this - > face , CMFV_GLASSES , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_NOSE , STR_FACE_NOSE , GetCompanyManagerFaceBits ( this - > face , CMFV_NOSE , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_CHIN , STR_FACE_CHIN , GetCompanyManagerFaceBits ( this - > face , CMFV_CHIN , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_JACKET , STR_FACE_JACKET , GetCompanyManagerFaceBits ( this - > face , CMFV_JACKET , this - > ge ) , false ) ;
this - > DrawFaceStringLabel ( SCMFW_WIDGET_COLLAR , STR_FACE_COLLAR , GetCompanyManagerFaceBits ( this - > face , CMFV_COLLAR , this - > ge ) , false ) ;
2008-05-13 01:05:39 +00:00
}
2008-09-30 20:39:50 +00:00
/* Draw the company manager face picture */
DrawCompanyManagerFace ( this - > face , GetCompany ( ( CompanyID ) this - > window_number ) - > colour , 2 , 16 ) ;
2004-08-09 17:04:08 +00:00
}
2008-05-13 01:05:39 +00:00
virtual void OnClick ( Point pt , int widget )
{
switch ( widget ) {
/* Toggle size, advanced/simple face selection */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_TOGGLE_LARGE_SMALL :
case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON : {
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , this - > face , CMD_SET_COMPANY_MANAGER_FACE ) ;
2008-05-15 19:24:15 +00:00
/* Backup some data before deletion */
2008-05-13 01:05:39 +00:00
int oldtop = this - > top ; ///< current top position of the window before closing it
int oldleft = this - > left ; ///< current top position of the window before closing it
bool adv = ! this - > advanced ;
2008-05-15 19:24:15 +00:00
Window * parent = this - > parent ;
2008-05-13 01:05:39 +00:00
delete this ;
/* Open up the (toggled size) Face selection window at the same position as the previous */
2008-09-30 20:39:50 +00:00
DoSelectCompanyManagerFace ( parent , adv , oldtop , oldleft ) ;
2008-05-13 01:05:39 +00:00
} break ;
/* OK button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_ACCEPT :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , this - > face , CMD_SET_COMPANY_MANAGER_FACE ) ;
2008-05-13 01:05:39 +00:00
/* Fall-Through */
/* Cancel button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_CANCEL :
2008-05-13 01:05:39 +00:00
delete this ;
break ;
/* Load button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_LOAD :
this - > face = _company_manager_face ;
ScaleAllCompanyManagerFaceBits ( this - > face ) ;
2008-05-13 01:05:39 +00:00
ShowErrorMessage ( INVALID_STRING_ID , STR_FACE_LOAD_DONE , 0 , 0 ) ;
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
break ;
2008-09-30 20:39:50 +00:00
/* 'Company manager face number' button, view and/or set company manager face number */
case SCMFW_WIDGET_FACECODE :
2008-05-13 01:05:39 +00:00
SetDParam ( 0 , this - > face ) ;
2008-09-15 16:29:40 +00:00
ShowQueryString ( STR_JUST_INT , STR_FACE_FACECODE_CAPTION , 10 + 1 , 0 , this , CS_NUMERAL , QSF_NONE ) ;
2008-05-13 01:05:39 +00:00
break ;
/* Save button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_SAVE :
_company_manager_face = this - > face ;
2008-05-13 01:05:39 +00:00
ShowErrorMessage ( INVALID_STRING_ID , STR_FACE_SAVE_DONE , 0 , 0 ) ;
break ;
/* Toggle gender (male/female) button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_MALE :
case SCMFW_WIDGET_FEMALE :
SetCompanyManagerFaceBits ( this - > face , CMFV_GENDER , this - > ge , widget - SCMFW_WIDGET_MALE ) ;
ScaleAllCompanyManagerFaceBits ( this - > face ) ;
2008-05-13 01:05:39 +00:00
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
break ;
/* Randomize face button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_RANDOM_NEW_FACE :
RandomCompanyManagerFaceBits ( this - > face , this - > ge , this - > advanced ) ;
2008-05-13 01:05:39 +00:00
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
break ;
/* Toggle ethnicity (european/african) button */
2008-09-30 20:39:50 +00:00
case SCMFW_WIDGET_ETHNICITY_EUR :
case SCMFW_WIDGET_ETHNICITY_AFR :
SetCompanyManagerFaceBits ( this - > face , CMFV_ETHNICITY , this - > ge , widget - SCMFW_WIDGET_ETHNICITY_EUR ) ;
ScaleAllCompanyManagerFaceBits ( this - > face ) ;
2008-05-13 01:05:39 +00:00
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
break ;
default :
2008-09-30 20:39:50 +00:00
/* For all buttons from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R is the same function.
2009-03-14 18:16:29 +00:00
* Therefor is this combined function .
* First it checks which CompanyManagerFaceVariable will be change and then
* a : invert the value for boolean variables
* or b : it checks inside of IncreaseCompanyManagerFaceBits ( ) if a left ( _L ) butten is pressed and then decrease else increase the variable */
2008-09-30 20:39:50 +00:00
if ( this - > advanced & & widget > = SCMFW_WIDGET_HAS_MOUSTACHE_EARRING & & widget < = SCMFW_WIDGET_GLASSES_R ) {
CompanyManagerFaceVariable cmfv ; // which CompanyManagerFaceVariable shall be edited
2008-05-13 01:05:39 +00:00
2008-09-30 20:39:50 +00:00
if ( widget < SCMFW_WIDGET_EYECOLOUR_L ) { // Bool buttons
switch ( widget - SCMFW_WIDGET_HAS_MOUSTACHE_EARRING ) {
2008-05-13 01:05:39 +00:00
default : NOT_REACHED ( ) ;
2008-09-30 20:39:50 +00:00
case 0 : cmfv = this - > is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE ; break ; // Has earring/moustache button
case 1 : cmfv = CMFV_HAS_GLASSES ; break ; // Has glasses button
2008-05-13 01:05:39 +00:00
}
2008-09-30 20:39:50 +00:00
SetCompanyManagerFaceBits ( this - > face , cmfv , this - > ge , ! GetCompanyManagerFaceBits ( this - > face , cmfv , this - > ge ) ) ;
ScaleAllCompanyManagerFaceBits ( this - > face ) ;
2008-05-13 01:05:39 +00:00
} else { // Value buttons
2008-09-30 20:39:50 +00:00
switch ( ( widget - SCMFW_WIDGET_EYECOLOUR_L ) / 3 ) {
2008-05-13 01:05:39 +00:00
default : NOT_REACHED ( ) ;
2008-09-30 20:39:50 +00:00
case 0 : cmfv = CMFV_EYE_COLOUR ; break ; // Eye colour buttons
case 1 : cmfv = CMFV_CHIN ; break ; // Chin buttons
case 2 : cmfv = CMFV_EYEBROWS ; break ; // Eyebrows buttons
case 3 : cmfv = this - > is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS ; break ; // Moustache or lips buttons
case 4 : cmfv = CMFV_NOSE ; break ; // Nose buttons
case 5 : cmfv = CMFV_HAIR ; break ; // Hair buttons
case 6 : cmfv = CMFV_JACKET ; break ; // Jacket buttons
case 7 : cmfv = CMFV_COLLAR ; break ; // Collar buttons
case 8 : cmfv = CMFV_TIE_EARRING ; break ; // Tie/earring buttons
case 9 : cmfv = CMFV_GLASSES ; break ; // Glasses buttons
2008-05-13 01:05:39 +00:00
}
/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
2008-09-30 20:39:50 +00:00
IncreaseCompanyManagerFaceBits ( this - > face , cmfv , this - > ge , ( ( ( widget - SCMFW_WIDGET_EYECOLOUR_L ) % 3 ) ! = 0 ) ? 1 : - 1 ) ;
2008-05-13 01:05:39 +00:00
}
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
}
break ;
}
}
virtual void OnQueryTextFinished ( char * str )
{
if ( str = = NULL ) return ;
2008-09-30 20:39:50 +00:00
/* Set a new company manager face number */
2008-05-13 01:05:39 +00:00
if ( ! StrEmpty ( str ) ) {
this - > face = strtoul ( str , NULL , 10 ) ;
2008-09-30 20:39:50 +00:00
ScaleAllCompanyManagerFaceBits ( this - > face ) ;
2008-05-13 01:05:39 +00:00
ShowErrorMessage ( INVALID_STRING_ID , STR_FACE_FACECODE_SET , 0 , 0 ) ;
this - > UpdateData ( ) ;
this - > SetDirty ( ) ;
} else {
ShowErrorMessage ( INVALID_STRING_ID , STR_FACE_FACECODE_ERR , 0 , 0 ) ;
}
}
} ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
/** normal/simple company manager face selection window description */
2009-03-15 15:12:06 +00:00
static const WindowDesc _select_company_manager_face_desc (
2007-10-15 19:59:27 +00:00
WDP_AUTO , WDP_AUTO , 190 , 163 , 190 , 163 ,
2008-09-30 20:39:50 +00:00
WC_COMPANY_MANAGER_FACE , WC_NONE ,
2009-02-04 16:59:41 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION ,
2009-03-28 04:14:02 +00:00
_select_company_manager_face_widgets , _nested_select_company_manager_face_widgets , lengthof ( _nested_select_company_manager_face_widgets )
2009-03-15 15:12:06 +00:00
) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
/** advanced company manager face selection window description */
2009-03-15 15:12:06 +00:00
static const WindowDesc _select_company_manager_face_adv_desc (
2007-10-15 19:59:27 +00:00
WDP_AUTO , WDP_AUTO , 220 , 220 , 220 , 220 ,
2008-09-30 20:39:50 +00:00
WC_COMPANY_MANAGER_FACE , WC_NONE ,
2009-02-04 16:59:41 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION ,
2009-03-28 04:14:02 +00:00
_select_company_manager_face_adv_widgets , _nested_select_company_manager_face_adv_widgets , lengthof ( _nested_select_company_manager_face_adv_widgets )
2009-03-15 15:12:06 +00:00
) ;
2007-10-15 19:59:27 +00:00
/**
2008-09-30 20:39:50 +00:00
* Open the simple / advanced company manager face selection window
2007-10-15 19:59:27 +00:00
*
2008-09-30 20:39:50 +00:00
* @ param parent the parent company window
* @ param adv simple or advanced face selection window
2008-04-09 02:02:39 +00:00
* @ param top previous top position of the window
* @ param left previous left position of the window
2007-10-15 19:59:27 +00:00
*/
2008-09-30 20:39:50 +00:00
static void DoSelectCompanyManagerFace ( Window * parent , bool adv , int top , int left )
2007-10-15 19:59:27 +00:00
{
2008-09-30 20:39:50 +00:00
if ( ! IsValidCompanyID ( ( CompanyID ) parent - > window_number ) ) return ;
2007-10-15 19:59:27 +00:00
2008-09-30 20:39:50 +00:00
if ( BringWindowToFrontById ( WC_COMPANY_MANAGER_FACE , parent - > window_number ) ) return ;
new SelectCompanyManagerFaceWindow ( adv ? & _select_company_manager_face_adv_desc : & _select_company_manager_face_desc , parent , adv , top , left ) ; // simple or advanced window
2007-10-15 19:59:27 +00:00
}
2006-10-05 23:24:16 +00:00
/* Names of the widgets. Keep them in the same order as in the widget array */
2008-09-30 20:39:50 +00:00
enum CompanyWindowWidgets {
CW_WIDGET_CLOSEBOX = 0 ,
CW_WIDGET_CAPTION ,
CW_WIDGET_FACE ,
CW_WIDGET_NEW_FACE ,
2009-02-09 02:57:15 +00:00
CW_WIDGET_COLOUR_SCHEME ,
2008-09-30 20:39:50 +00:00
CW_WIDGET_PRESIDENT_NAME ,
CW_WIDGET_COMPANY_NAME ,
CW_WIDGET_BUILD_VIEW_HQ ,
CW_WIDGET_RELOCATE_HQ ,
CW_WIDGET_BUY_SHARE ,
CW_WIDGET_SELL_SHARE ,
CW_WIDGET_COMPANY_PASSWORD ,
2009-01-23 22:18:06 +00:00
CW_WIDGET_COMPANY_JOIN ,
2006-12-07 13:00:41 +00:00
} ;
2006-10-05 23:24:16 +00:00
2008-09-30 20:39:50 +00:00
static const Widget _company_widgets [ ] = {
2008-07-31 17:17:27 +00:00
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_GREY , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } ,
{ WWT_CAPTION , RESIZE_NONE , COLOUR_GREY , 11 , 359 , 0 , 13 , STR_7001 , STR_018C_WINDOW_TITLE_DRAG_THIS } ,
{ WWT_PANEL , RESIZE_NONE , COLOUR_GREY , 0 , 359 , 14 , 157 , 0x0 , STR_NULL } ,
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 89 , 158 , 169 , STR_7004_NEW_FACE , STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT } ,
2009-02-09 03:07:03 +00:00
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 90 , 179 , 158 , 169 , STR_7005_COLOUR_SCHEME , STR_7031_CHANGE_THE_COMPANY_VEHICLE } ,
2008-07-31 17:17:27 +00:00
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 180 , 269 , 158 , 169 , STR_7009_PRESIDENT_NAME , STR_7032_CHANGE_THE_PRESIDENT_S } ,
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 270 , 359 , 158 , 169 , STR_7008_COMPANY_NAME , STR_7033_CHANGE_THE_COMPANY_NAME } ,
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 266 , 355 , 18 , 29 , STR_7072_VIEW_HQ , STR_7070_BUILD_COMPANY_HEADQUARTERS } ,
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_GREY , 266 , 355 , 32 , 43 , STR_RELOCATE_HQ , STR_RELOCATE_COMPANY_HEADQUARTERS } ,
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 0 , 179 , 158 , 169 , STR_7077_BUY_25_SHARE_IN_COMPANY , STR_7079_BUY_25_SHARE_IN_THIS_COMPANY } ,
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 180 , 359 , 158 , 169 , STR_7078_SELL_25_SHARE_IN_COMPANY , STR_707A_SELL_25_SHARE_IN_THIS_COMPANY } ,
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 266 , 355 , 138 , 149 , STR_COMPANY_PASSWORD , STR_COMPANY_PASSWORD_TOOLTIP } ,
2009-01-23 23:56:56 +00:00
{ WWT_PUSHTXTBTN , RESIZE_NONE , COLOUR_GREY , 266 , 355 , 138 , 149 , STR_COMPANY_JOIN , STR_COMPANY_JOIN_TIP } ,
2004-09-07 21:48:09 +00:00
{ WIDGETS_END } ,
2004-08-09 17:04:08 +00:00
} ;
2007-11-21 13:50:36 +00:00
/**
* Draws text " Vehicles: " and number of all vehicle types , or " (none) "
2008-09-30 20:39:50 +00:00
* @ param company ID of company to print statistics of
2007-11-21 13:50:36 +00:00
*/
2009-03-22 12:01:21 +00:00
static void DrawCompanyVehiclesAmount ( CompanyID company , int right )
2004-08-09 17:04:08 +00:00
{
const int x = 110 ;
2007-11-21 13:50:36 +00:00
int y = 63 ;
2006-07-26 03:33:12 +00:00
const Vehicle * v ;
2005-11-13 14:54:09 +00:00
uint train = 0 ;
uint road = 0 ;
uint air = 0 ;
uint ship = 0 ;
2004-09-11 09:40:19 +00:00
2009-03-22 12:01:21 +00:00
DrawString ( x , right , y , STR_7039_VEHICLES , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
FOR_ALL_VEHICLES ( v ) {
2008-09-30 20:39:50 +00:00
if ( v - > owner = = company ) {
2005-11-13 14:54:09 +00:00
switch ( v - > type ) {
2007-03-08 16:27:54 +00:00
case VEH_TRAIN : if ( IsFrontEngine ( v ) ) train + + ; break ;
2007-06-11 14:00:16 +00:00
case VEH_ROAD : if ( IsRoadVehFront ( v ) ) road + + ; break ;
2007-03-08 16:27:54 +00:00
case VEH_AIRCRAFT : if ( IsNormalAircraft ( v ) ) air + + ; break ;
case VEH_SHIP : ship + + ; break ;
2005-11-13 14:54:09 +00:00
default : break ;
2004-08-09 17:04:08 +00:00
}
}
}
2007-04-18 22:10:36 +00:00
if ( train + road + air + ship = = 0 ) {
2009-03-22 12:01:21 +00:00
DrawString ( x + 70 , right , y , STR_7042_NONE , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
} else {
if ( train ! = 0 ) {
2004-12-02 22:53:07 +00:00
SetDParam ( 0 , train ) ;
2009-03-22 12:01:21 +00:00
DrawString ( x + 70 , right , y , STR_TRAINS , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
y + = 10 ;
}
if ( road ! = 0 ) {
2004-12-02 22:53:07 +00:00
SetDParam ( 0 , road ) ;
2009-03-22 12:01:21 +00:00
DrawString ( x + 70 , right , y , STR_ROAD_VEHICLES , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
y + = 10 ;
}
if ( air ! = 0 ) {
2004-12-02 22:53:07 +00:00
SetDParam ( 0 , air ) ;
2009-03-22 12:01:21 +00:00
DrawString ( x + 70 , right , y , STR_AIRCRAFT , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
y + = 10 ;
}
if ( ship ! = 0 ) {
2004-12-02 22:53:07 +00:00
SetDParam ( 0 , ship ) ;
2009-03-22 12:01:21 +00:00
DrawString ( x + 70 , right , y , STR_SHIPS , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
}
}
}
2008-09-30 20:39:50 +00:00
int GetAmountOwnedBy ( const Company * c , Owner owner )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
return ( c - > share_owners [ 0 ] = = owner ) +
( c - > share_owners [ 1 ] = = owner ) +
( c - > share_owners [ 2 ] = = owner ) +
( c - > share_owners [ 3 ] = = owner ) ;
2004-08-09 17:04:08 +00:00
}
2007-11-21 13:50:36 +00:00
/**
* Draws list of all companies with shares
2008-09-30 20:39:50 +00:00
* @ param c pointer to the Company structure
2007-11-21 13:50:36 +00:00
*/
2008-09-30 20:39:50 +00:00
static void DrawCompanyOwnerText ( const Company * c )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
const Company * c2 ;
2007-11-15 17:49:50 +00:00
uint num = 0 ;
const byte height = GetCharacterHeight ( FS_NORMAL ) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
FOR_ALL_COMPANIES ( c2 ) {
uint amt = GetAmountOwnedBy ( c , c2 - > index ) ;
2005-10-23 13:04:44 +00:00
if ( amt ! = 0 ) {
2007-11-15 17:49:50 +00:00
SetDParam ( 0 , amt * 25 ) ;
2008-09-30 20:39:50 +00:00
SetDParam ( 1 , c2 - > index ) ;
2004-08-09 17:04:08 +00:00
2009-03-22 12:01:21 +00:00
DrawString ( 120 , 359 , ( num + + ) * height + 116 , STR_707D_OWNED_BY , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
}
}
}
2007-10-15 19:59:27 +00:00
/**
2008-09-30 20:39:50 +00:00
* Window with general information about a company
2007-10-15 19:59:27 +00:00
*/
2008-09-30 20:39:50 +00:00
struct CompanyWindow : Window
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
CompanyWindowWidgets query_widget ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
CompanyWindow ( const WindowDesc * desc , WindowNumber window_number ) : Window ( desc , window_number )
2008-05-15 14:12:22 +00:00
{
2009-02-09 02:33:10 +00:00
this - > owner = ( Owner ) this - > window_number ;
2008-05-23 23:02:13 +00:00
this - > FindWindowPlacementAndResize ( desc ) ;
2008-05-15 14:12:22 +00:00
}
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
virtual void OnPaint ( )
{
2008-09-30 20:39:50 +00:00
const Company * c = GetCompany ( ( CompanyID ) this - > window_number ) ;
bool local = this - > window_number = = _local_company ;
this - > SetWidgetHiddenState ( CW_WIDGET_NEW_FACE , ! local ) ;
2009-02-09 02:57:15 +00:00
this - > SetWidgetHiddenState ( CW_WIDGET_COLOUR_SCHEME , ! local ) ;
2008-09-30 20:39:50 +00:00
this - > SetWidgetHiddenState ( CW_WIDGET_PRESIDENT_NAME , ! local ) ;
this - > SetWidgetHiddenState ( CW_WIDGET_COMPANY_NAME , ! local ) ;
2009-01-03 17:11:52 +00:00
this - > widget [ CW_WIDGET_BUILD_VIEW_HQ ] . data = ( local & & c - > location_of_HQ = = INVALID_TILE ) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ ;
2009-03-15 00:32:18 +00:00
if ( local & & c - > location_of_HQ ! = INVALID_TILE ) this - > widget [ CW_WIDGET_BUILD_VIEW_HQ ] . type = WWT_PUSHTXTBTN ; // HQ is already built.
2009-01-03 17:11:52 +00:00
this - > SetWidgetDisabledState ( CW_WIDGET_BUILD_VIEW_HQ , ! local & & c - > location_of_HQ = = INVALID_TILE ) ;
this - > SetWidgetHiddenState ( CW_WIDGET_RELOCATE_HQ , ! local | | c - > location_of_HQ = = INVALID_TILE ) ;
2008-09-30 20:39:50 +00:00
this - > SetWidgetHiddenState ( CW_WIDGET_BUY_SHARE , local ) ;
this - > SetWidgetHiddenState ( CW_WIDGET_SELL_SHARE , local ) ;
this - > SetWidgetHiddenState ( CW_WIDGET_COMPANY_PASSWORD , ! local | | ! _networking ) ;
2009-01-23 22:18:06 +00:00
this - > SetWidgetHiddenState ( CW_WIDGET_COMPANY_JOIN , local | | ! _networking ) ;
this - > SetWidgetDisabledState ( CW_WIDGET_COMPANY_JOIN , ! IsHumanCompany ( c - > index ) ) ;
2008-05-15 14:12:22 +00:00
if ( ! local ) {
2008-05-29 15:13:28 +00:00
if ( _settings_game . economy . allow_shares ) { // Shares are allowed
2008-05-15 14:12:22 +00:00
/* If all shares are owned by someone (none by nobody), disable buy button */
2008-09-30 20:39:50 +00:00
this - > SetWidgetDisabledState ( CW_WIDGET_BUY_SHARE , GetAmountOwnedBy ( c , INVALID_OWNER ) = = 0 | |
/* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */
( GetAmountOwnedBy ( c , INVALID_OWNER ) = = 1 & & ! c - > is_ai ) | |
2008-05-15 14:12:22 +00:00
/* Spectators cannot do anything of course */
2008-09-30 20:39:50 +00:00
_local_company = = COMPANY_SPECTATOR ) ;
2008-05-15 14:12:22 +00:00
2008-09-30 20:39:50 +00:00
/* If the company doesn't own any shares, disable sell button */
this - > SetWidgetDisabledState ( CW_WIDGET_SELL_SHARE , ( GetAmountOwnedBy ( c , _local_company ) = = 0 ) | |
2008-05-15 14:12:22 +00:00
/* Spectators cannot do anything of course */
2008-09-30 20:39:50 +00:00
_local_company = = COMPANY_SPECTATOR ) ;
2008-05-15 14:12:22 +00:00
} else { // Shares are not allowed, disable buy/sell buttons
2008-09-30 20:39:50 +00:00
this - > DisableWidget ( CW_WIDGET_BUY_SHARE ) ;
this - > DisableWidget ( CW_WIDGET_SELL_SHARE ) ;
2008-05-15 14:12:22 +00:00
}
}
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > index ) ;
SetDParam ( 1 , c - > index ) ;
2004-08-09 17:04:08 +00:00
2008-05-17 12:48:06 +00:00
this - > DrawWidgets ( ) ;
2007-11-21 13:50:36 +00:00
2009-01-23 23:56:56 +00:00
# ifdef ENABLE_NETWORK
if ( _networking & & NetworkCompanyIsPassworded ( c - > index ) ) {
DrawSprite ( SPR_LOCK , PAL_NONE , this - > widget [ CW_WIDGET_COMPANY_JOIN ] . left - 10 , this - > widget [ CW_WIDGET_COMPANY_JOIN ] . top + 2 ) ;
}
# endif /* ENABLE_NETWORK */
2008-09-30 20:39:50 +00:00
/* Company manager's face */
DrawCompanyManagerFace ( c - > face , c - > colour , 2 , 16 ) ;
2007-11-21 13:50:36 +00:00
2008-05-15 14:12:22 +00:00
/* "xxx (Manager)" */
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > index ) ;
2009-03-22 09:34:06 +00:00
DrawStringMultiLine ( 48 - MAX_LENGTH_PRESIDENT_NAME_PIXELS / 2 , 48 + MAX_LENGTH_PRESIDENT_NAME_PIXELS / 2 , 135 , 157 , STR_7037_PRESIDENT , SA_CENTER ) ;
2007-11-21 13:50:36 +00:00
2008-05-15 14:12:22 +00:00
/* "Inaugurated:" */
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > inaugurated_year ) ;
2009-03-22 12:01:21 +00:00
DrawString ( 110 , this - > width , 23 , STR_7038_INAUGURATED , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
/* "Colour scheme:" */
2009-03-22 12:01:21 +00:00
DrawString ( 110 , this - > width , 43 , STR_7006_COLOUR_SCHEME , TC_FROMSTRING ) ;
2008-05-15 14:12:22 +00:00
/* Draw company-colour bus */
2009-02-09 02:57:15 +00:00
DrawSprite ( SPR_VEH_BUS_SW_VIEW , COMPANY_SPRITE_COLOUR ( c - > index ) , 215 , 44 ) ;
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
/* "Vehicles:" */
2009-03-22 12:01:21 +00:00
DrawCompanyVehiclesAmount ( ( CompanyID ) this - > window_number , this - > width ) ;
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
/* "Company value:" */
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , CalculateCompanyValue ( c ) ) ;
2009-03-22 12:01:21 +00:00
DrawString ( 110 , this - > width , 106 , STR_7076_COMPANY_VALUE , TC_FROMSTRING ) ;
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
/* Shares list */
2008-09-30 20:39:50 +00:00
DrawCompanyOwnerText ( c ) ;
2008-05-15 14:12:22 +00:00
}
2004-08-09 17:04:08 +00:00
2008-05-15 14:12:22 +00:00
virtual void OnClick ( Point pt , int widget )
{
switch ( widget ) {
2008-09-30 20:39:50 +00:00
case CW_WIDGET_NEW_FACE : DoSelectCompanyManagerFace ( this , false ) ; break ;
2004-08-09 17:04:08 +00:00
2009-02-09 02:57:15 +00:00
case CW_WIDGET_COLOUR_SCHEME :
if ( BringWindowToFrontById ( WC_COMPANY_COLOUR , this - > window_number ) ) break ;
2008-09-30 20:39:50 +00:00
new SelectCompanyLiveryWindow ( & _select_company_livery_desc , ( CompanyID ) this - > window_number ) ;
2008-05-15 14:12:22 +00:00
break ;
2008-09-30 20:39:50 +00:00
case CW_WIDGET_PRESIDENT_NAME :
this - > query_widget = CW_WIDGET_PRESIDENT_NAME ;
2008-05-15 14:12:22 +00:00
SetDParam ( 0 , this - > window_number ) ;
2008-09-30 21:18:28 +00:00
ShowQueryString ( STR_PRESIDENT_NAME , STR_700B_PRESIDENT_S_NAME , MAX_LENGTH_PRESIDENT_NAME_BYTES , MAX_LENGTH_PRESIDENT_NAME_PIXELS , this , CS_ALPHANUMERAL , QSF_ENABLE_DEFAULT ) ;
2008-05-15 14:12:22 +00:00
break ;
2008-09-30 20:39:50 +00:00
case CW_WIDGET_COMPANY_NAME :
this - > query_widget = CW_WIDGET_COMPANY_NAME ;
2008-05-15 14:12:22 +00:00
SetDParam ( 0 , this - > window_number ) ;
2008-09-15 19:02:50 +00:00
ShowQueryString ( STR_COMPANY_NAME , STR_700A_COMPANY_NAME , MAX_LENGTH_COMPANY_NAME_BYTES , MAX_LENGTH_COMPANY_NAME_PIXELS , this , CS_ALPHANUMERAL , QSF_ENABLE_DEFAULT ) ;
2008-05-15 14:12:22 +00:00
break ;
2005-01-06 18:54:13 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_BUILD_VIEW_HQ : {
TileIndex tile = GetCompany ( ( CompanyID ) this - > window_number ) - > location_of_HQ ;
2009-01-03 17:11:52 +00:00
if ( tile = = INVALID_TILE ) {
2008-09-30 20:39:50 +00:00
if ( ( byte ) this - > window_number ! = _local_company ) return ;
2008-05-15 14:12:22 +00:00
SetObjectToPlaceWnd ( SPR_CURSOR_HQ , PAL_NONE , VHM_RECT , this ) ;
SetTileSelectSize ( 2 , 2 ) ;
2008-09-30 20:39:50 +00:00
this - > LowerWidget ( CW_WIDGET_BUILD_VIEW_HQ ) ;
this - > InvalidateWidget ( CW_WIDGET_BUILD_VIEW_HQ ) ;
2008-05-15 14:12:22 +00:00
} else {
if ( _ctrl_pressed ) {
ShowExtraViewPortWindow ( tile ) ;
2006-10-05 23:24:16 +00:00
} else {
2008-05-15 14:12:22 +00:00
ScrollMainWindowToTile ( tile ) ;
2006-10-05 23:24:16 +00:00
}
}
2008-05-15 14:12:22 +00:00
break ;
}
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_RELOCATE_HQ :
2008-05-15 14:12:22 +00:00
SetObjectToPlaceWnd ( SPR_CURSOR_HQ , PAL_NONE , VHM_RECT , this ) ;
SetTileSelectSize ( 2 , 2 ) ;
2008-09-30 20:39:50 +00:00
this - > LowerWidget ( CW_WIDGET_RELOCATE_HQ ) ;
this - > InvalidateWidget ( CW_WIDGET_RELOCATE_HQ ) ;
2008-05-15 14:12:22 +00:00
break ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_BUY_SHARE :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , this - > window_number , 0 , CMD_BUY_SHARE_IN_COMPANY | CMD_MSG ( STR_707B_CAN_T_BUY_25_SHARE_IN_THIS ) ) ;
2008-05-15 14:12:22 +00:00
break ;
2004-09-01 21:54:12 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_SELL_SHARE :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , this - > window_number , 0 , CMD_SELL_SHARE_IN_COMPANY | CMD_MSG ( STR_707C_CAN_T_SELL_25_SHARE_IN ) ) ;
2008-05-15 14:12:22 +00:00
break ;
2004-08-09 17:04:08 +00:00
2007-12-02 14:48:26 +00:00
# ifdef ENABLE_NETWORK
2008-09-30 20:39:50 +00:00
case CW_WIDGET_COMPANY_PASSWORD :
if ( this - > window_number = = _local_company ) ShowNetworkCompanyPasswordWindow ( this ) ;
2008-05-15 14:12:22 +00:00
break ;
2009-01-23 22:18:06 +00:00
case CW_WIDGET_COMPANY_JOIN : {
this - > query_widget = CW_WIDGET_COMPANY_JOIN ;
CompanyID company = ( CompanyID ) this - > window_number ;
if ( _network_server ) {
NetworkServerDoMove ( CLIENT_ID_SERVER , company ) ;
MarkWholeScreenDirty ( ) ;
} else if ( NetworkCompanyIsPassworded ( company ) ) {
/* ask for the password */
ShowQueryString ( STR_EMPTY , STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION , 20 , 180 , this , CS_ALPHANUMERAL , QSF_NONE ) ;
} else {
/* just send the join command */
NetworkClientRequestMove ( company ) ;
}
break ;
}
2007-12-02 14:48:26 +00:00
# endif /* ENABLE_NETWORK */
2008-05-15 14:12:22 +00:00
}
}
2004-08-09 17:04:08 +00:00
2008-05-29 11:47:56 +00:00
virtual void OnHundredthTick ( )
2008-05-15 14:12:22 +00:00
{
/* redraw the window every now and then */
2008-05-29 11:47:56 +00:00
this - > SetDirty ( ) ;
2008-05-15 14:12:22 +00:00
}
2004-12-22 23:24:53 +00:00
2008-05-15 14:12:22 +00:00
virtual void OnPlaceObject ( Point pt , TileIndex tile )
{
2009-01-07 14:45:07 +00:00
if ( DoCommandP ( tile , 0 , 0 , CMD_BUILD_COMPANY_HQ | CMD_MSG ( STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS ) ) )
2008-05-15 14:12:22 +00:00
ResetObjectToPlace ( ) ;
2008-09-30 20:39:50 +00:00
this - > widget [ CW_WIDGET_BUILD_VIEW_HQ ] . type = WWT_PUSHTXTBTN ; // this button can now behave as a normal push button
2008-05-15 14:12:22 +00:00
this - > RaiseButtons ( ) ;
}
2006-10-11 00:48:55 +00:00
2008-05-15 14:12:22 +00:00
virtual void OnPlaceObjectAbort ( )
{
this - > RaiseButtons ( ) ;
}
2004-12-22 23:24:53 +00:00
2008-05-15 14:12:22 +00:00
virtual void OnQueryTextFinished ( char * str )
{
2008-09-15 19:02:50 +00:00
if ( str = = NULL ) return ;
2006-10-05 23:24:16 +00:00
2008-05-15 14:12:22 +00:00
switch ( this - > query_widget ) {
default : NOT_REACHED ( ) ;
2006-10-05 23:24:16 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_PRESIDENT_NAME :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , 0 , CMD_RENAME_PRESIDENT | CMD_MSG ( STR_700D_CAN_T_CHANGE_PRESIDENT ) , NULL , str ) ;
2008-05-15 14:12:22 +00:00
break ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
case CW_WIDGET_COMPANY_NAME :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , 0 , 0 , CMD_RENAME_COMPANY | CMD_MSG ( STR_700C_CAN_T_CHANGE_COMPANY_NAME ) , NULL , str ) ;
2008-05-15 14:12:22 +00:00
break ;
2009-01-23 22:18:06 +00:00
# ifdef ENABLE_NETWORK
case CW_WIDGET_COMPANY_JOIN :
NetworkClientRequestMove ( ( CompanyID ) this - > window_number , str ) ;
break ;
# endif /* ENABLE_NETWORK */
2008-05-15 14:12:22 +00:00
}
}
} ;
2004-08-09 17:04:08 +00:00
2009-03-15 15:12:06 +00:00
static const WindowDesc _company_desc (
2007-07-27 12:49:04 +00:00
WDP_AUTO , WDP_AUTO , 360 , 170 , 360 , 170 ,
2007-02-01 15:49:12 +00:00
WC_COMPANY , WC_NONE ,
2004-08-09 17:04:08 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS ,
2009-03-15 15:12:06 +00:00
_company_widgets
) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
void ShowCompany ( CompanyID company )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
if ( ! IsValidCompanyID ( company ) ) return ;
2006-10-31 21:15:56 +00:00
2008-09-30 20:39:50 +00:00
AllocateWindowDescFront < CompanyWindow > ( & _company_desc , company ) ;
2004-08-09 17:04:08 +00:00
}
2008-05-18 20:49:22 +00:00
struct BuyCompanyWindow : Window {
BuyCompanyWindow ( const WindowDesc * desc , WindowNumber window_number ) : Window ( desc , window_number )
{
2008-05-23 23:02:13 +00:00
this - > FindWindowPlacementAndResize ( desc ) ;
2004-08-09 17:04:08 +00:00
}
2008-05-18 20:49:22 +00:00
virtual void OnPaint ( )
{
2008-09-30 20:39:50 +00:00
Company * c = GetCompany ( ( CompanyID ) this - > window_number ) ;
2008-05-18 20:49:22 +00:00
SetDParam ( 0 , STR_COMPANY_NAME ) ;
2008-09-30 20:39:50 +00:00
SetDParam ( 1 , c - > index ) ;
2008-05-18 20:49:22 +00:00
this - > DrawWidgets ( ) ;
2008-09-30 20:39:50 +00:00
DrawCompanyManagerFace ( c - > face , c - > colour , 2 , 16 ) ;
2008-05-18 20:49:22 +00:00
2008-09-30 20:39:50 +00:00
SetDParam ( 0 , c - > index ) ;
SetDParam ( 1 , c - > bankrupt_value ) ;
2009-03-22 09:34:06 +00:00
DrawStringMultiLine ( 95 , 333 , 26 , 116 , STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT , SA_CENTER ) ;
2008-05-18 20:49:22 +00:00
}
virtual void OnClick ( Point pt , int widget )
{
switch ( widget ) {
case 3 :
delete this ;
break ;
case 4 :
2008-12-28 14:37:19 +00:00
DoCommandP ( 0 , this - > window_number , 0 , CMD_BUY_COMPANY | CMD_MSG ( STR_7060_CAN_T_BUY_COMPANY ) ) ;
2008-05-18 20:49:22 +00:00
break ;
}
}
} ;
2004-08-09 17:04:08 +00:00
static const Widget _buy_company_widgets [ ] = {
2008-07-31 17:17:27 +00:00
{ WWT_CLOSEBOX , RESIZE_NONE , COLOUR_LIGHT_BLUE , 0 , 10 , 0 , 13 , STR_00C5 , STR_018B_CLOSE_WINDOW } ,
{ WWT_CAPTION , RESIZE_NONE , COLOUR_LIGHT_BLUE , 11 , 333 , 0 , 13 , STR_00B3_MESSAGE_FROM , STR_018C_WINDOW_TITLE_DRAG_THIS } ,
{ WWT_PANEL , RESIZE_NONE , COLOUR_LIGHT_BLUE , 0 , 333 , 14 , 136 , 0x0 , STR_NULL } ,
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_LIGHT_BLUE , 148 , 207 , 117 , 128 , STR_00C9_NO , STR_NULL } ,
{ WWT_TEXTBTN , RESIZE_NONE , COLOUR_LIGHT_BLUE , 218 , 277 , 117 , 128 , STR_00C8_YES , STR_NULL } ,
2004-09-07 21:48:09 +00:00
{ WIDGETS_END } ,
2004-08-09 17:04:08 +00:00
} ;
2009-03-15 15:12:06 +00:00
static const WindowDesc _buy_company_desc (
2007-07-27 12:49:04 +00:00
153 , 171 , 334 , 137 , 334 , 137 ,
2007-02-01 15:49:12 +00:00
WC_BUY_COMPANY , WC_NONE ,
2009-02-04 16:59:41 +00:00
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION ,
2009-03-15 15:12:06 +00:00
_buy_company_widgets
) ;
2004-08-09 17:04:08 +00:00
2008-09-30 20:39:50 +00:00
void ShowBuyCompanyDialog ( CompanyID company )
2004-08-09 17:04:08 +00:00
{
2008-09-30 20:39:50 +00:00
AllocateWindowDescFront < BuyCompanyWindow > ( & _buy_company_desc , company ) ;
2004-08-09 17:04:08 +00:00
}