Changeset - r9302:115cfeb49cd5
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-05-18 20:49:22
rubidium@openttd.org
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
2 files changed with 49 insertions and 47 deletions:
0 comments (0 inline, 0 general)
src/engine_gui.cpp
Show inline comments
 
@@ -66,55 +66,54 @@ static const DrawEngineInfo _draw_engine
 
	{ DrawAircraftEngine, DrawAircraftEngineInfo },
 
};
 

	
 
static void EnginePreviewWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		EngineID engine = w->window_number;
 
		const DrawEngineInfo* dei;
 
		int width;
 
struct EnginePreviewWindow : Window {
 
	EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
	}
 

	
 
		w->DrawWidgets();
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 

	
 
		EngineID engine = this->window_number;
 
		SetDParam(0, GetEngineCategoryName(engine));
 
		DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
 

	
 
		SetDParam(0, engine);
 
		DrawStringCentered(w->width >> 1, 80, STR_ENGINE_NAME, TC_BLACK);
 
		DrawStringCentered(this->width >> 1, 80, STR_ENGINE_NAME, TC_BLACK);
 

	
 
		dei = &_draw_engine_list[GetEngine(engine)->type];
 
		const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
 

	
 
		width = w->width;
 
		int width = this->width;
 
		dei->engine_proc(width >> 1, 100, engine, 0);
 
		dei->info_proc(engine, width >> 1, 130, width - 52);
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		switch (e->we.click.widget) {
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case 4:
 
				DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
 
				DoCommandP(0, this->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
 
				/* Fallthrough */
 
			case 3:
 
				delete w;
 
				delete this;
 
				break;
 
		}
 
		break;
 
	}
 
}
 
};
 

	
 
static const WindowDesc _engine_preview_desc = {
 
	WDP_CENTER, WDP_CENTER, 300, 192, 300, 192,
 
	WC_ENGINE_PREVIEW, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_engine_preview_widgets,
 
	EnginePreviewWndProc
 
	NULL
 
};
 

	
 

	
 
void ShowEnginePreviewWindow(EngineID engine)
 
{
 
	AllocateWindowDescFront<Window>(&_engine_preview_desc, engine);
 
	AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
 
}
 

	
 
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
src/player_gui.cpp
Show inline comments
 
@@ -1360,35 +1360,38 @@ void ShowPlayerCompany(PlayerID player)
 

	
 

	
 

	
 
static void BuyCompanyWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
		case WE_PAINT: {
 
			Player *p = GetPlayer((PlayerID)w->window_number);
 
			SetDParam(0, STR_COMPANY_NAME);
 
			SetDParam(1, p->index);
 
			w->DrawWidgets();
 
struct BuyCompanyWindow : Window {
 
	BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
	}
 

	
 
			DrawPlayerFace(p->face, p->player_color, 2, 16);
 
	virtual void OnPaint()
 
	{
 
		Player *p = GetPlayer((PlayerID)this->window_number);
 
		SetDParam(0, STR_COMPANY_NAME);
 
		SetDParam(1, p->index);
 
		this->DrawWidgets();
 

	
 
		DrawPlayerFace(p->face, p->player_color, 2, 16);
 

	
 
			SetDParam(0, p->index);
 
			SetDParam(1, p->bankrupt_value);
 
			DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
 
		} break;
 
		SetDParam(0, p->index);
 
		SetDParam(1, p->bankrupt_value);
 
		DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
 
	}
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				case 3:
 
					delete w;
 
					break;
 
				case 4: {
 
					DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
 
					break;
 
				}
 
			}
 
			break;
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case 3:
 
				delete this;
 
				break;
 

	
 
			case 4:
 
				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
 
				break;
 
		}
 
	}
 
}
 
};
 

	
 
static const Widget _buy_company_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 
@@ -1404,13 +1407,13 @@ static const WindowDesc _buy_company_des
 
	WC_BUY_COMPANY, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_buy_company_widgets,
 
	BuyCompanyWndProc
 
	NULL
 
};
 

	
 

	
 
void ShowBuyCompanyDialog(uint player)
 
{
 
	AllocateWindowDescFront<Window>(&_buy_company_desc, player);
 
	AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, player);
 
}
 

	
 
/********** HIGHSCORE and ENDGAME windows */
0 comments (0 inline, 0 general)