mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
This commit is contained in:
parent
1e14976bbf
commit
5e7ae74345
9
newgrf.c
9
newgrf.c
@ -59,6 +59,9 @@ static uint32 _ttdpatch_flags[8];
|
|||||||
/* Used by Action 0x06 to preload a pseudo sprite and modify its content */
|
/* Used by Action 0x06 to preload a pseudo sprite and modify its content */
|
||||||
static byte *_preload_sprite = NULL;
|
static byte *_preload_sprite = NULL;
|
||||||
|
|
||||||
|
/* Set if any vehicle is loaded which uses 2cc (two company colours) */
|
||||||
|
bool _have_2cc = false;
|
||||||
|
|
||||||
|
|
||||||
typedef enum GrfDataType {
|
typedef enum GrfDataType {
|
||||||
GDT_SOUND,
|
GDT_SOUND,
|
||||||
@ -459,7 +462,10 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x27: /* Miscellaneous flags */
|
case 0x27: /* Miscellaneous flags */
|
||||||
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf);
|
FOR_EACH_OBJECT {
|
||||||
|
ei[i].misc_flags = grf_load_byte(&buf);
|
||||||
|
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x28: /* Cargo classes allowed */
|
case 0x28: /* Cargo classes allowed */
|
||||||
@ -3055,6 +3061,7 @@ static void ResetNewGRFData(void)
|
|||||||
_misc_grf_features = 0;
|
_misc_grf_features = 0;
|
||||||
_traininfo_vehicle_pitch = 0;
|
_traininfo_vehicle_pitch = 0;
|
||||||
_traininfo_vehicle_width = 29;
|
_traininfo_vehicle_width = 29;
|
||||||
|
_have_2cc = false;
|
||||||
|
|
||||||
InitializeSoundPool();
|
InitializeSoundPool();
|
||||||
InitializeSpriteGroupPool();
|
InitializeSpriteGroupPool();
|
||||||
|
1
newgrf.h
1
newgrf.h
@ -61,6 +61,7 @@ typedef struct GRFConfig {
|
|||||||
|
|
||||||
extern GRFConfig *_first_grfconfig;
|
extern GRFConfig *_first_grfconfig;
|
||||||
extern SpriteID _signal_base;
|
extern SpriteID _signal_base;
|
||||||
|
extern bool _have_2cc;
|
||||||
|
|
||||||
void LoadNewGRF(uint load_index, uint file_index);
|
void LoadNewGRF(uint load_index, uint file_index);
|
||||||
|
|
||||||
|
48
player_gui.c
48
player_gui.c
@ -17,6 +17,7 @@
|
|||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
#include "newgrf.h"
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
#include "network_data.h"
|
#include "network_data.h"
|
||||||
@ -317,7 +318,13 @@ static void ShowColourDropDownMenu(Window *w, uint32 widget)
|
|||||||
static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
|
static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_CREATE: LowerWindowWidget(w, WP(w, livery_d).livery_class + 2); break;
|
case WE_CREATE:
|
||||||
|
LowerWindowWidget(w, WP(w, livery_d).livery_class + 2);
|
||||||
|
if (!_have_2cc) {
|
||||||
|
HideWindowWidget(w, 11);
|
||||||
|
HideWindowWidget(w, 12);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
const Player *p = GetPlayer(w->window_number);
|
const Player *p = GetPlayer(w->window_number);
|
||||||
@ -353,10 +360,12 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
|
|||||||
DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? 0xC : 0x10);
|
DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? 0xC : 0x10);
|
||||||
|
|
||||||
DrawSprite(SPR_SQUARE | GENERAL_SPRITE_COLOR(p->livery[scheme].colour1) | PALETTE_MODIFIER_COLOR, 152, y);
|
DrawSprite(SPR_SQUARE | GENERAL_SPRITE_COLOR(p->livery[scheme].colour1) | PALETTE_MODIFIER_COLOR, 152, y);
|
||||||
DrawSprite(SPR_SQUARE | GENERAL_SPRITE_COLOR(p->livery[scheme].colour2) | PALETTE_MODIFIER_COLOR, 277, y);
|
|
||||||
|
|
||||||
DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? 0xC : 2);
|
DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? 0xC : 2);
|
||||||
|
|
||||||
|
if (_have_2cc) {
|
||||||
|
DrawSprite(SPR_SQUARE | GENERAL_SPRITE_COLOR(p->livery[scheme].colour2) | PALETTE_MODIFIER_COLOR, 277, y);
|
||||||
DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? 0xC : 2);
|
DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? 0xC : 2);
|
||||||
|
}
|
||||||
|
|
||||||
y += 14;
|
y += 14;
|
||||||
}
|
}
|
||||||
@ -443,7 +452,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Widget _select_player_livery_widgets[] = {
|
static const Widget _select_player_livery_2cc_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
||||||
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
||||||
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
|
||||||
@ -461,10 +470,37 @@ static const Widget _select_player_livery_widgets[] = {
|
|||||||
{ WIDGETS_END },
|
{ WIDGETS_END },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _select_player_livery_desc = {
|
static const WindowDesc _select_player_livery_2cc_desc = {
|
||||||
-1,-1, 400, 49 + 1 * 14,
|
-1,-1, 400, 49 + 1 * 14,
|
||||||
WC_PLAYER_COLOR, 0,
|
WC_PLAYER_COLOR, 0,
|
||||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
||||||
|
_select_player_livery_2cc_widgets,
|
||||||
|
SelectPlayerLiveryWndProc
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const Widget _select_player_livery_widgets[] = {
|
||||||
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
||||||
|
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 274, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
||||||
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
|
||||||
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, SPR_IMG_TRAINLIST, STR_LIVERY_TRAIN_TIP },
|
||||||
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP },
|
||||||
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP },
|
||||||
|
{ WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
|
||||||
|
{ WWT_PANEL, RESIZE_NONE, 14, 110, 274, 14, 35, 0x0, STR_NULL },
|
||||||
|
{ WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL },
|
||||||
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
|
||||||
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP },
|
||||||
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
|
||||||
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP },
|
||||||
|
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 274, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
|
||||||
|
{ WIDGETS_END },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const WindowDesc _select_player_livery_desc = {
|
||||||
|
-1, -1, 275, 49 + 1 * 14,
|
||||||
|
WC_PLAYER_COLOR, 0,
|
||||||
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
||||||
_select_player_livery_widgets,
|
_select_player_livery_widgets,
|
||||||
SelectPlayerLiveryWndProc
|
SelectPlayerLiveryWndProc
|
||||||
};
|
};
|
||||||
@ -722,7 +758,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 4: {/* change color */
|
case 4: {/* change color */
|
||||||
Window *wf = AllocateWindowDescFront(&_select_player_livery_desc, w->window_number);
|
Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
|
||||||
if (wf != NULL) {
|
if (wf != NULL) {
|
||||||
wf->caption_color = wf->window_number;
|
wf->caption_color = wf->window_number;
|
||||||
WP(wf,livery_d).livery_class = LC_OTHER;
|
WP(wf,livery_d).livery_class = LC_OTHER;
|
||||||
|
Loading…
Reference in New Issue
Block a user