summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2019-02-13 22:05:08 +0000
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-03-03 09:15:39 +0100
commite0c2ad1b6591859a1a30216e396cdab6e6bb028f (patch)
treeb8d65be4898bbb1e783be8f589a48b465c7745a9
parent3c047b124e28db45621de06d5556c96598352fc7 (diff)
downloadopenttd-e0c2ad1b6591859a1a30216e396cdab6e6bb028f.tar.xz
Add: AI functions to get/set company colours.
-rw-r--r--src/script/api/ai/ai_company.hpp.sq65
-rw-r--r--src/script/api/ai_changelog.hpp4
-rw-r--r--src/script/api/game/game_company.hpp.sq93
-rw-r--r--src/script/api/script_company.cpp30
-rw-r--r--src/script/api/script_company.hpp81
-rw-r--r--src/script/api/template/template_company.hpp.sq4
6 files changed, 243 insertions, 34 deletions
diff --git a/src/script/api/ai/ai_company.hpp.sq b/src/script/api/ai/ai_company.hpp.sq
index 7ed55d97b..ecab99c91 100644
--- a/src/script/api/ai/ai_company.hpp.sq
+++ b/src/script/api/ai/ai_company.hpp.sq
@@ -21,16 +21,57 @@ void SQAICompany_Register(Squirrel *engine)
SQAICompany.PreRegister(engine);
SQAICompany.AddConstructor<void (ScriptCompany::*)(), 1>(engine, "x");
- SQAICompany.DefSQConst(engine, ScriptCompany::CURRENT_QUARTER, "CURRENT_QUARTER");
- SQAICompany.DefSQConst(engine, ScriptCompany::EARLIEST_QUARTER, "EARLIEST_QUARTER");
- SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_FIRST, "COMPANY_FIRST");
- SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_LAST, "COMPANY_LAST");
- SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_INVALID, "COMPANY_INVALID");
- SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_SELF, "COMPANY_SELF");
- SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_SPECTATOR, "COMPANY_SPECTATOR");
- SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_MALE, "GENDER_MALE");
- SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_FEMALE, "GENDER_FEMALE");
- SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_INVALID, "GENDER_INVALID");
+ SQAICompany.DefSQConst(engine, ScriptCompany::CURRENT_QUARTER, "CURRENT_QUARTER");
+ SQAICompany.DefSQConst(engine, ScriptCompany::EARLIEST_QUARTER, "EARLIEST_QUARTER");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_FIRST, "COMPANY_FIRST");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_LAST, "COMPANY_LAST");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_INVALID, "COMPANY_INVALID");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_SELF, "COMPANY_SELF");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COMPANY_SPECTATOR, "COMPANY_SPECTATOR");
+ SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_MALE, "GENDER_MALE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_FEMALE, "GENDER_FEMALE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::GENDER_INVALID, "GENDER_INVALID");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_DEFAULT, "LS_DEFAULT");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_STEAM, "LS_STEAM");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_DIESEL, "LS_DIESEL");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_ELECTRIC, "LS_ELECTRIC");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_MONORAIL, "LS_MONORAIL");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_MAGLEV, "LS_MAGLEV");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_DMU, "LS_DMU");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_EMU, "LS_EMU");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_STEAM, "LS_PASSENGER_WAGON_STEAM");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_DIESEL, "LS_PASSENGER_WAGON_DIESEL");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_ELECTRIC, "LS_PASSENGER_WAGON_ELECTRIC");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_MONORAIL, "LS_PASSENGER_WAGON_MONORAIL");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_MAGLEV, "LS_PASSENGER_WAGON_MAGLEV");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_WAGON, "LS_FREIGHT_WAGON");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_BUS, "LS_BUS");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_TRUCK, "LS_TRUCK");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_SHIP, "LS_PASSENGER_SHIP");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_SHIP, "LS_FREIGHT_SHIP");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_HELICOPTER, "LS_HELICOPTER");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_SMALL_PLANE, "LS_SMALL_PLANE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_LARGE_PLANE, "LS_LARGE_PLANE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_TRAM, "LS_PASSENGER_TRAM");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_TRAM, "LS_FREIGHT_TRAM");
+ SQAICompany.DefSQConst(engine, ScriptCompany::LS_INVALID, "LS_INVALID");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_DARK_BLUE, "COLOUR_DARK_BLUE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_PALE_GREEN, "COLOUR_PALE_GREEN");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_PINK, "COLOUR_PINK");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_YELLOW, "COLOUR_YELLOW");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_RED, "COLOUR_RED");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_LIGHT_BLUE, "COLOUR_LIGHT_BLUE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_GREEN, "COLOUR_GREEN");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_DARK_GREEN, "COLOUR_DARK_GREEN");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_BLUE, "COLOUR_BLUE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_CREAM, "COLOUR_CREAM");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_MAUVE, "COLOUR_MAUVE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_PURPLE, "COLOUR_PURPLE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_ORANGE, "COLOUR_ORANGE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_BROWN, "COLOUR_BROWN");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_GREY, "COLOUR_GREY");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_WHITE, "COLOUR_WHITE");
+ SQAICompany.DefSQConst(engine, ScriptCompany::COLOUR_INVALID, "COLOUR_INVALID");
SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::ResolveCompanyID, "ResolveCompanyID", 2, ".i");
SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::IsMine, "IsMine", 2, ".i");
@@ -59,6 +100,10 @@ void SQAICompany_Register(Squirrel *engine)
SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::GetAutoRenewMonths, "GetAutoRenewMonths", 2, ".i");
SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::SetAutoRenewMoney, "SetAutoRenewMoney", 2, ".i");
SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::GetAutoRenewMoney, "GetAutoRenewMoney", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::SetPrimaryLiveryColour, "SetPrimaryLiveryColour", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::SetSecondaryLiveryColour, "SetSecondaryLiveryColour", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::GetPrimaryLiveryColour, "GetPrimaryLiveryColour", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &ScriptCompany::GetSecondaryLiveryColour, "GetSecondaryLiveryColour", 2, ".i");
SQAICompany.PostRegister(engine);
}
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index bba36b7ea..24b5d5b51 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -22,6 +22,10 @@
* \li AIAirport::GetMonthlyMaintenanceCost
* \li AIGroup::SetParent
* \li AIGroup::GetParent
+ * \li AICompany::SetPrimaryLiveryColour
+ * \li AICompany::SetSecondaryLiveryColour
+ * \li AICompany::GetPrimaryLiveryColour
+ * \li AICompany::GetSecondaryLiveryColour
*
* Other changes:
* \li AIBridge::GetName takes one extra parameter to refer the vehicle type
diff --git a/src/script/api/game/game_company.hpp.sq b/src/script/api/game/game_company.hpp.sq
index 29476fc8a..626664484 100644
--- a/src/script/api/game/game_company.hpp.sq
+++ b/src/script/api/game/game_company.hpp.sq
@@ -21,30 +21,71 @@ void SQGSCompany_Register(Squirrel *engine)
SQGSCompany.PreRegister(engine);
SQGSCompany.AddConstructor<void (ScriptCompany::*)(), 1>(engine, "x");
- SQGSCompany.DefSQConst(engine, ScriptCompany::CURRENT_QUARTER, "CURRENT_QUARTER");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EARLIEST_QUARTER, "EARLIEST_QUARTER");
- SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_FIRST, "COMPANY_FIRST");
- SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_LAST, "COMPANY_LAST");
- SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_INVALID, "COMPANY_INVALID");
- SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_SELF, "COMPANY_SELF");
- SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_SPECTATOR, "COMPANY_SPECTATOR");
- SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_MALE, "GENDER_MALE");
- SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_FEMALE, "GENDER_FEMALE");
- SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_INVALID, "GENDER_INVALID");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_CONSTRUCTION, "EXPENSES_CONSTRUCTION");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_NEW_VEHICLES, "EXPENSES_NEW_VEHICLES");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_TRAIN_RUN, "EXPENSES_TRAIN_RUN");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_ROADVEH_RUN, "EXPENSES_ROADVEH_RUN");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_AIRCRAFT_RUN, "EXPENSES_AIRCRAFT_RUN");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_SHIP_RUN, "EXPENSES_SHIP_RUN");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_PROPERTY, "EXPENSES_PROPERTY");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_TRAIN_INC, "EXPENSES_TRAIN_INC");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_ROADVEH_INC, "EXPENSES_ROADVEH_INC");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_AIRCRAFT_INC, "EXPENSES_AIRCRAFT_INC");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_SHIP_INC, "EXPENSES_SHIP_INC");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_LOAN_INT, "EXPENSES_LOAN_INT");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_OTHER, "EXPENSES_OTHER");
- SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_INVALID, "EXPENSES_INVALID");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::CURRENT_QUARTER, "CURRENT_QUARTER");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EARLIEST_QUARTER, "EARLIEST_QUARTER");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_FIRST, "COMPANY_FIRST");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_LAST, "COMPANY_LAST");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_INVALID, "COMPANY_INVALID");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_SELF, "COMPANY_SELF");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COMPANY_SPECTATOR, "COMPANY_SPECTATOR");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_MALE, "GENDER_MALE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_FEMALE, "GENDER_FEMALE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_INVALID, "GENDER_INVALID");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_DEFAULT, "LS_DEFAULT");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_STEAM, "LS_STEAM");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_DIESEL, "LS_DIESEL");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_ELECTRIC, "LS_ELECTRIC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_MONORAIL, "LS_MONORAIL");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_MAGLEV, "LS_MAGLEV");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_DMU, "LS_DMU");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_EMU, "LS_EMU");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_STEAM, "LS_PASSENGER_WAGON_STEAM");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_DIESEL, "LS_PASSENGER_WAGON_DIESEL");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_ELECTRIC, "LS_PASSENGER_WAGON_ELECTRIC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_MONORAIL, "LS_PASSENGER_WAGON_MONORAIL");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_WAGON_MAGLEV, "LS_PASSENGER_WAGON_MAGLEV");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_WAGON, "LS_FREIGHT_WAGON");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_BUS, "LS_BUS");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_TRUCK, "LS_TRUCK");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_SHIP, "LS_PASSENGER_SHIP");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_SHIP, "LS_FREIGHT_SHIP");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_HELICOPTER, "LS_HELICOPTER");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_SMALL_PLANE, "LS_SMALL_PLANE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_LARGE_PLANE, "LS_LARGE_PLANE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_PASSENGER_TRAM, "LS_PASSENGER_TRAM");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_FREIGHT_TRAM, "LS_FREIGHT_TRAM");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::LS_INVALID, "LS_INVALID");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_DARK_BLUE, "COLOUR_DARK_BLUE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_PALE_GREEN, "COLOUR_PALE_GREEN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_PINK, "COLOUR_PINK");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_YELLOW, "COLOUR_YELLOW");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_RED, "COLOUR_RED");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_LIGHT_BLUE, "COLOUR_LIGHT_BLUE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_GREEN, "COLOUR_GREEN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_DARK_GREEN, "COLOUR_DARK_GREEN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_BLUE, "COLOUR_BLUE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_CREAM, "COLOUR_CREAM");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_MAUVE, "COLOUR_MAUVE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_PURPLE, "COLOUR_PURPLE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_ORANGE, "COLOUR_ORANGE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_BROWN, "COLOUR_BROWN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_GREY, "COLOUR_GREY");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_WHITE, "COLOUR_WHITE");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::COLOUR_INVALID, "COLOUR_INVALID");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_CONSTRUCTION, "EXPENSES_CONSTRUCTION");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_NEW_VEHICLES, "EXPENSES_NEW_VEHICLES");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_TRAIN_RUN, "EXPENSES_TRAIN_RUN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_ROADVEH_RUN, "EXPENSES_ROADVEH_RUN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_AIRCRAFT_RUN, "EXPENSES_AIRCRAFT_RUN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_SHIP_RUN, "EXPENSES_SHIP_RUN");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_PROPERTY, "EXPENSES_PROPERTY");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_TRAIN_INC, "EXPENSES_TRAIN_INC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_ROADVEH_INC, "EXPENSES_ROADVEH_INC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_AIRCRAFT_INC, "EXPENSES_AIRCRAFT_INC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_SHIP_INC, "EXPENSES_SHIP_INC");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_LOAN_INT, "EXPENSES_LOAN_INT");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_OTHER, "EXPENSES_OTHER");
+ SQGSCompany.DefSQConst(engine, ScriptCompany::EXPENSES_INVALID, "EXPENSES_INVALID");
SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::ResolveCompanyID, "ResolveCompanyID", 2, ".i");
SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetName, "SetName", 2, "..");
@@ -69,6 +110,10 @@ void SQGSCompany_Register(Squirrel *engine)
SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetAutoRenewStatus, "GetAutoRenewStatus", 2, ".i");
SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetAutoRenewMonths, "GetAutoRenewMonths", 2, ".i");
SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetAutoRenewMoney, "GetAutoRenewMoney", 2, ".i");
+ SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetPrimaryLiveryColour, "SetPrimaryLiveryColour", 3, ".ii");
+ SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetSecondaryLiveryColour, "SetSecondaryLiveryColour", 3, ".ii");
+ SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetPrimaryLiveryColour, "GetPrimaryLiveryColour", 2, ".i");
+ SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetSecondaryLiveryColour, "GetSecondaryLiveryColour", 2, ".i");
SQGSCompany.PostRegister(engine);
}
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index a1f40c5e1..54888c33c 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -296,3 +296,33 @@
return ::Company::Get((CompanyID)company)->settings.engine_renew_money;
}
+
+/* static */ bool ScriptCompany::SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour)
+{
+ return ScriptObject::DoCommand(0, scheme, colour, CMD_SET_COMPANY_COLOUR);
+}
+
+/* static */ bool ScriptCompany::SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour)
+{
+ return ScriptObject::DoCommand(0, scheme | 1 << 8, colour, CMD_SET_COMPANY_COLOUR);
+}
+
+/* static */ ScriptCompany::Colours ScriptCompany::GetPrimaryLiveryColour(ScriptCompany::LiveryScheme scheme)
+{
+ if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
+
+ const Company *c = ::Company::GetIfValid(_current_company);
+ if (c == NULL) return COLOUR_INVALID;
+
+ return (ScriptCompany::Colours)c->livery[scheme].colour1;
+}
+
+/* static */ ScriptCompany::Colours ScriptCompany::GetSecondaryLiveryColour(ScriptCompany::LiveryScheme scheme)
+{
+ if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
+
+ const Company *c = ::Company::GetIfValid(_current_company);
+ if (c == NULL) return COLOUR_INVALID;
+
+ return (ScriptCompany::Colours)c->livery[scheme].colour2;
+}
diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp
index dc917500b..55cb7a930 100644
--- a/src/script/api/script_company.hpp
+++ b/src/script/api/script_company.hpp
@@ -14,6 +14,8 @@
#include "script_text.hpp"
#include "../../economy_type.h"
+#include "../../livery.h"
+#include "../../gfx_type.h"
/**
* Class that handles all company related functions.
@@ -46,6 +48,55 @@ public:
GENDER_INVALID = -1, ///< An invalid gender.
};
+ /** List of different livery schemes. */
+ enum LiveryScheme {
+ LS_DEFAULT, ///< Default scheme.
+ LS_STEAM, ///< Steam engines.
+ LS_DIESEL, ///< Diesel engines.
+ LS_ELECTRIC, ///< Electric engines.
+ LS_MONORAIL, ///< Monorail engines.
+ LS_MAGLEV, ///< Maglev engines.
+ LS_DMU, ///< DMUs and their passenger wagons.
+ LS_EMU, ///< EMUs and their passenger wagons.
+ LS_PASSENGER_WAGON_STEAM, ///< Passenger wagons attached to steam engines.
+ LS_PASSENGER_WAGON_DIESEL, ///< Passenger wagons attached to diesel engines.
+ LS_PASSENGER_WAGON_ELECTRIC, ///< Passenger wagons attached to electric engines.
+ LS_PASSENGER_WAGON_MONORAIL, ///< Passenger wagons attached to monorail engines.
+ LS_PASSENGER_WAGON_MAGLEV, ///< Passenger wagons attached to maglev engines.
+ LS_FREIGHT_WAGON, ///< Freight wagons.
+ LS_BUS, ///< Buses.
+ LS_TRUCK, ///< Trucks.
+ LS_PASSENGER_SHIP, ///< Passenger ships.
+ LS_FREIGHT_SHIP, ///< Freight ships.
+ LS_HELICOPTER, ///< Helicopters.
+ LS_SMALL_PLANE, ///< Small aeroplanes.
+ LS_LARGE_PLANE, ///< Large aeroplanes.
+ LS_PASSENGER_TRAM, ///< Passenger trams.
+ LS_FREIGHT_TRAM, ///< Freight trams.
+ LS_INVALID = -1,
+ };
+
+ /** List of colours. */
+ enum Colours {
+ COLOUR_DARK_BLUE,
+ COLOUR_PALE_GREEN,
+ COLOUR_PINK,
+ COLOUR_YELLOW,
+ COLOUR_RED,
+ COLOUR_LIGHT_BLUE,
+ COLOUR_GREEN,
+ COLOUR_DARK_GREEN,
+ COLOUR_BLUE,
+ COLOUR_CREAM,
+ COLOUR_MAUVE,
+ COLOUR_PURPLE,
+ COLOUR_ORANGE,
+ COLOUR_BROWN,
+ COLOUR_GREY,
+ COLOUR_WHITE,
+ COLOUR_INVALID = ::INVALID_COLOUR
+ };
+
/**
* Types of expenses.
* @api -ai
@@ -331,6 +382,36 @@ public:
* @return The minimum required money for autorenew to work.
*/
static Money GetAutoRenewMoney(CompanyID company);
+
+ /**
+ * Set primary colour for your company.
+ * @param scheme Livery scheme to set.
+ * @param colour Colour to set.
+ * @return False if unable to set primary colour of the livery scheme (e.g. colour in use).
+ */
+ static bool SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour);
+
+ /**
+ * Set secondary colour for your company.
+ * @param scheme Livery scheme to set.
+ * @param colour Colour to set.
+ * @return False if unable to set secondary colour of the livery scheme.
+ */
+ static bool SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour);
+
+ /**
+ * Get primary colour of a livery for your company.
+ * @param scheme Livery scheme to get.
+ * @return Primary colour of livery.
+ */
+ static ScriptCompany::Colours GetPrimaryLiveryColour(LiveryScheme scheme);
+
+ /**
+ * Get secondary colour of a livery for your company.
+ * @param scheme Livery scheme to get.
+ * @return Secondary colour of livery.
+ */
+ static ScriptCompany::Colours GetSecondaryLiveryColour(LiveryScheme scheme);
};
DECLARE_POSTFIX_INCREMENT(ScriptCompany::CompanyID)
diff --git a/src/script/api/template/template_company.hpp.sq b/src/script/api/template/template_company.hpp.sq
index 7dc63f24b..82c10381a 100644
--- a/src/script/api/template/template_company.hpp.sq
+++ b/src/script/api/template/template_company.hpp.sq
@@ -19,6 +19,10 @@ namespace SQConvert {
template <> inline int Return<ScriptCompany::CompanyID>(HSQUIRRELVM vm, ScriptCompany::CompanyID res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptCompany::Gender GetParam(ForceType<ScriptCompany::Gender>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCompany::Gender)tmp; }
template <> inline int Return<ScriptCompany::Gender>(HSQUIRRELVM vm, ScriptCompany::Gender res) { sq_pushinteger(vm, (int32)res); return 1; }
+ template <> inline ScriptCompany::LiveryScheme GetParam(ForceType<ScriptCompany::LiveryScheme>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCompany::LiveryScheme)tmp; }
+ template <> inline int Return<ScriptCompany::LiveryScheme>(HSQUIRRELVM vm, ScriptCompany::LiveryScheme res) { sq_pushinteger(vm, (int32)res); return 1; }
+ template <> inline ScriptCompany::Colours GetParam(ForceType<ScriptCompany::Colours>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCompany::Colours)tmp; }
+ template <> inline int Return<ScriptCompany::Colours>(HSQUIRRELVM vm, ScriptCompany::Colours res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptCompany::ExpensesType GetParam(ForceType<ScriptCompany::ExpensesType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCompany::ExpensesType)tmp; }
template <> inline int Return<ScriptCompany::ExpensesType>(HSQUIRRELVM vm, ScriptCompany::ExpensesType res) { sq_pushinteger(vm, (int32)res); return 1; }