summaryrefslogtreecommitdiff
authorPeter Nelson2013-02-17 11:50:22 (GMT)
committer Peter Nelson2013-02-17 17:23:20 (GMT)
commit2e1f3d80c59c0bec9e9f81c83e4dbecc4edf1199 (patch) (side-by-side diff)
tree1bc99b31b79f13b22b186414277196bbd6fb7e11
parent61a0d30e983d613f4724f54ea2d23645c5c07ce0 (diff)
Prepopulate rgb colours when switching from TTD to rgb colours.rgb
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/company_cmd.cpp10
-rw-r--r--src/company_gui.cpp7
-rw-r--r--src/gfx.cpp13
-rw-r--r--src/gfx_func.h1
4 files changed, 28 insertions, 3 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index e79d551..b9f53b6 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -1054,7 +1054,10 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
case 0:
if (rgb) {
c->livery[scheme].rgb1 = p2;
- c->livery[scheme].flags |= LF_RGB;
+ if (!(c->livery[scheme].flags & LF_RGB)) {
+ c->livery[scheme].rgb2 = GetCompanyColourRGB(c->livery[scheme].colour2).data;
+ c->livery[scheme].flags |= LF_RGB;
+ }
} else {
c->livery[scheme].colour1 = colour;
c->livery[scheme].flags &= ~LF_RGB;
@@ -1072,7 +1075,10 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
case 1:
if (rgb) {
c->livery[scheme].rgb2 = p2;
- c->livery[scheme].flags |= LF_RGB;
+ if (!(c->livery[scheme].flags & LF_RGB)) {
+ c->livery[scheme].rgb1 = GetCompanyColourRGB(c->livery[scheme].colour1).data;
+ c->livery[scheme].flags |= LF_RGB;
+ }
} else {
c->livery[scheme].colour2 = colour;
c->livery[scheme].flags &= ~LF_RGB;
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 27a6a83..a86f817 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -913,7 +913,12 @@ public:
if (BringWindowToFrontById(WC_RGB_COLOUR, number)) return;
const Livery *livery = GetSelectedLivery();
- Colour colour = (widget == WID_SCL_PRI_COL_DROPDOWN) ? livery->rgb1 : livery->rgb2;
+ Colour colour;
+ if (livery->flags & LF_RGB) {
+ colour = (widget == WID_SCL_PRI_COL_DROPDOWN) ? livery->rgb1 : livery->rgb2;
+ } else {
+ colour = GetCompanyColourRGB((widget == WID_SCL_PRI_COL_DROPDOWN) ? livery->colour1 : livery->colour2);
+ }
new SelectRGBWindow(&_select_rgb_desc, number, colour, this->sel, this->livery_class, _ctrl_pressed, widget == WID_SCL_PRI_COL_DROPDOWN);
return;
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index f4a7bb3..80588d4 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -2088,6 +2088,19 @@ void SortResolutions(int count)
QSortT(_resolutions, count, &compare_res);
}
+Colour GetCompanyColourRGB(int colour)
+{
+ PaletteID pal = PALETTE_RECOLOUR_START + colour;
+ const byte *map = GetNonSprite(pal, ST_RECOLOUR) + 1;
+
+ Colour rgb;
+ rgb.r = _palette.palette[map[0xCA]].r;
+ rgb.g = _palette.palette[map[0xCA]].g;
+ rgb.b = _palette.palette[map[0xCA]].b;
+ rgb.a = 0x50;
+ return rgb;
+}
+
PaletteID CreateCompanyColourRemap(Colour rgb1, Colour rgb2, bool twocc, PaletteID basemap, PaletteID hint)
{
DeallocateCustomSprite(hint);
diff --git a/src/gfx_func.h b/src/gfx_func.h
index c46d8f1..2e7c370 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -151,6 +151,7 @@ bool ToggleFullScreen(bool fs);
byte GetCharacterWidth(FontSize size, uint32 key);
byte GetDigitWidth(FontSize size = FS_NORMAL);
+Colour GetCompanyColourRGB(int colour);
PaletteID CreateCompanyColourRemap(Colour rgb1, Colour rgb2, bool twocc, PaletteID basemap, PaletteID hint);
/**