1 | Index: binaries/data/mods/public/simulation/components/Player.js
|
---|
2 | ===================================================================
|
---|
3 | --- binaries/data/mods/public/simulation/components/Player.js (revision 19773)
|
---|
4 | +++ binaries/data/mods/public/simulation/components/Player.js (working copy)
|
---|
5 | @@ -120,7 +120,13 @@
|
---|
6 |
|
---|
7 | Player.prototype.SetColor = function(r, g, b)
|
---|
8 | {
|
---|
9 | + let oldColor = this.color;
|
---|
10 | this.color = { "r": r/255.0, "g": g/255.0, "b": b/255.0, "a": 1.0 };
|
---|
11 | +
|
---|
12 | + // Used in atlas
|
---|
13 | + Engine.BroadcastMessage(MT_PlayerColorChanged, {
|
---|
14 | + "player": this.playerID
|
---|
15 | + });
|
---|
16 | };
|
---|
17 |
|
---|
18 | Player.prototype.GetColor = function()
|
---|
19 | Index: source/simulation2/MessageTypes.h
|
---|
20 | ===================================================================
|
---|
21 | --- source/simulation2/MessageTypes.h (revision 19773)
|
---|
22 | +++ source/simulation2/MessageTypes.h (working copy)
|
---|
23 | @@ -490,6 +490,22 @@
|
---|
24 | };
|
---|
25 |
|
---|
26 | /**
|
---|
27 | + * Sent by aura manager when a value of a certain entity's component is changed
|
---|
28 | + */
|
---|
29 | +class CMessagePlayerColorChanged : public CMessage
|
---|
30 | +{
|
---|
31 | +public:
|
---|
32 | + DEFAULT_MESSAGE_IMPL(PlayerColorChanged)
|
---|
33 | +
|
---|
34 | + CMessagePlayerColorChanged(player_id_t player) :
|
---|
35 | + player(player)
|
---|
36 | + {
|
---|
37 | + }
|
---|
38 | +
|
---|
39 | + player_id_t player;
|
---|
40 | +};
|
---|
41 | +
|
---|
42 | +/**
|
---|
43 | * Sent by aura and tech managers when a value of a certain template's component is changed
|
---|
44 | */
|
---|
45 | class CMessageTemplateModification : public CMessage
|
---|
46 | Index: source/simulation2/TypeList.h
|
---|
47 | ===================================================================
|
---|
48 | --- source/simulation2/TypeList.h (revision 19773)
|
---|
49 | +++ source/simulation2/TypeList.h (working copy)
|
---|
50 | @@ -60,6 +60,7 @@
|
---|
51 | MESSAGE(MinimapPing)
|
---|
52 | MESSAGE(CinemaPathEnded)
|
---|
53 | MESSAGE(CinemaQueueEnded)
|
---|
54 | +MESSAGE(PlayerColorChanged)
|
---|
55 |
|
---|
56 | // TemplateManager must come before all other (non-test) components,
|
---|
57 | // so that it is the first to be (de)serialized
|
---|
58 | Index: source/simulation2/components/CCmpSelectable.cpp
|
---|
59 | ===================================================================
|
---|
60 | --- source/simulation2/components/CCmpSelectable.cpp (revision 19773)
|
---|
61 | +++ source/simulation2/components/CCmpSelectable.cpp (working copy)
|
---|
62 | @@ -56,6 +56,7 @@
|
---|
63 | {
|
---|
64 | componentManager.SubscribeToMessageType(MT_OwnershipChanged);
|
---|
65 | componentManager.SubscribeToMessageType(MT_PositionChanged);
|
---|
66 | + componentManager.SubscribeToMessageType(MT_PlayerColorChanged);
|
---|
67 | componentManager.SubscribeToMessageType(MT_TerrainChanged);
|
---|
68 | componentManager.SubscribeToMessageType(MT_WaterChanged);
|
---|
69 | }
|
---|
70 | @@ -393,6 +394,22 @@
|
---|
71 | InvalidateStaticOverlay();
|
---|
72 | break;
|
---|
73 | }
|
---|
74 | + case MT_PlayerColorChanged:
|
---|
75 | + {
|
---|
76 | + CmpPtr<ICmpOwnership> cmpOwnership(GetEntityHandle());
|
---|
77 | + if (!cmpOwnership)
|
---|
78 | + break;
|
---|
79 | + const CMessagePlayerColorChanged& msgData = static_cast<const CMessagePlayerColorChanged&> (msg);
|
---|
80 | + cmpSelectable->SetSelectionHighlight(GetOwnerPlayerColor(playerColor, new_ent), true);
|
---|
81 | +
|
---|
82 | + if (msgData.player == cmpOwnership->GetOwner())
|
---|
83 | + {
|
---|
84 | + LOGWARNING("bla %d", cmpOwnership->GetOwner());
|
---|
85 | + InvalidateStaticOverlay();
|
---|
86 | + }
|
---|
87 | +
|
---|
88 | + break;
|
---|
89 | + }
|
---|
90 | case MT_TerrainChanged:
|
---|
91 | case MT_WaterChanged:
|
---|
92 | InvalidateStaticOverlay();
|
---|
93 | Index: source/simulation2/components/CCmpTerritoryManager.cpp
|
---|
94 | ===================================================================
|
---|
95 | --- source/simulation2/components/CCmpTerritoryManager.cpp (revision 19773)
|
---|
96 | +++ source/simulation2/components/CCmpTerritoryManager.cpp (working copy)
|
---|
97 | @@ -60,6 +60,7 @@
|
---|
98 | static void ClassInit(CComponentManager& componentManager)
|
---|
99 | {
|
---|
100 | componentManager.SubscribeGloballyToMessageType(MT_OwnershipChanged);
|
---|
101 | + componentManager.SubscribeGloballyToMessageType(MT_PlayerColorChanged);
|
---|
102 | componentManager.SubscribeGloballyToMessageType(MT_PositionChanged);
|
---|
103 | componentManager.SubscribeGloballyToMessageType(MT_ValueModification);
|
---|
104 | componentManager.SubscribeToMessageType(MT_ObstructionMapShapeChanged);
|
---|
105 | @@ -216,7 +217,12 @@
|
---|
106 | RenderSubmit(msgData.collector);
|
---|
107 | break;
|
---|
108 | }
|
---|
109 | + case MT_PlayerColorChanged:
|
---|
110 | + {
|
---|
111 | + MakeDirty();
|
---|
112 | + break;
|
---|
113 | }
|
---|
114 | + }
|
---|
115 | }
|
---|
116 |
|
---|
117 | // Check whether the entity is either a settlement or territory influence;
|
---|
118 | Index: source/simulation2/scripting/MessageTypeConversions.cpp
|
---|
119 | ===================================================================
|
---|
120 | --- source/simulation2/scripting/MessageTypeConversions.cpp (revision 19773)
|
---|
121 | +++ source/simulation2/scripting/MessageTypeConversions.cpp (working copy)
|
---|
122 | @@ -517,6 +517,22 @@
|
---|
123 | return new CMessageCinemaQueueEnded();
|
---|
124 | }
|
---|
125 |
|
---|
126 | +////////////////////////////////
|
---|
127 | +
|
---|
128 | +JS::Value CMessagePlayerColorChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
---|
129 | +{
|
---|
130 | + TOJSVAL_SETUP();
|
---|
131 | + SET_MSG_PROPERTY(player);
|
---|
132 | + return JS::ObjectValue(*obj);
|
---|
133 | +}
|
---|
134 | +
|
---|
135 | +CMessage* CMessagePlayerColorChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
---|
136 | +{
|
---|
137 | + FROMJSVAL_SETUP();
|
---|
138 | + GET_MSG_PROPERTY(player_id_t, player);
|
---|
139 | + return new CMessagePlayerColorChanged(player);
|
---|
140 | +}
|
---|
141 | +
|
---|
142 | ////////////////////////////////////////////////////////////////
|
---|
143 |
|
---|
144 | CMessage* CMessageFromJSVal(int mtid, ScriptInterface& scriptingInterface, JS::HandleValue val)
|
---|