Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 93d09f4

Browse files
committed
Merge branch 'development' into 4zk-content-source
2 parents a659c42 + 84e7e3c commit 93d09f4

27 files changed

+327
-174
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,12 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
631631

632632
- Added alternate version of `Scene` Lua function `CalculatePath(startPos, endPos, movePathToGround, digStrength, team)` that works as the previous one, but lets you specify the team to calculate the path for, allowing you to ignore doors on your team.
633633

634+
- Added `Controller` Lua function `IsKeyboardOnlyControlled` that tells you whether the `Controller` is being controlled by keyboard only. Previously the only way to do this was to check that it's not mouse controlled and not gamepad controlled.
635+
636+
- Added `Controller` control state `PIE_MENU_OPENED` that is true for the first Update in which the `PieMenu` is opened.
637+
638+
- Added `Activity` Lua function `GetPlayerController`, which gets you the `Controller` used for GUI stuff and when there's no `Actor` selected in an `Activity`. Be aware, it's very likely possible to cause problems by doing dumb things with this.
639+
634640
</details>
635641

636642
<details><summary><b>Changed</b></summary>

Entities/ACrab.cpp

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,50 +2195,57 @@ void ACrab::Update()
21952195
const float movementThreshold = 1.0F;
21962196
bool isStill = (m_Vel + m_PrevVel).MagnitudeIsLessThan(movementThreshold);
21972197

2198-
if (m_Controller.IsState(MOVE_RIGHT) || m_Controller.IsState(MOVE_LEFT) || m_MoveState == JUMP && m_Status != INACTIVE) {
2199-
if (m_MoveState != JUMP)
2200-
{
2201-
// Restart the stride if we're just starting to walk or crawl
2202-
if (m_MoveState != WALK)
2203-
{
2204-
m_StrideStart[LEFTSIDE] = true;
2205-
m_StrideStart[RIGHTSIDE] = true;
2206-
MoveOutOfTerrain(g_MaterialGrass);
2207-
}
2198+
// If the pie menu is on, try to preserve whatever move state we had before it going into effect.
2199+
// This is only done for digital input, where the user needs to use the keyboard to choose pie slices.
2200+
// For analog input, this doesn't matter - the mouse or aiming analog stick controls the pie menu.
2201+
bool keepOldState = m_Controller.IsKeyboardOnlyControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
2202+
2203+
if (!keepOldState) {
2204+
if (m_Controller.IsState(MOVE_RIGHT) || m_Controller.IsState(MOVE_LEFT) || m_MoveState == JUMP && m_Status != INACTIVE) {
2205+
if (m_MoveState != JUMP)
2206+
{
2207+
// Restart the stride if we're just starting to walk or crawl
2208+
if (m_MoveState != WALK)
2209+
{
2210+
m_StrideStart[LEFTSIDE] = true;
2211+
m_StrideStart[RIGHTSIDE] = true;
2212+
MoveOutOfTerrain(g_MaterialGrass);
2213+
}
22082214

2209-
m_MoveState = WALK;
2215+
m_MoveState = WALK;
22102216

2211-
for (int side = 0; side < SIDECOUNT; ++side)
2212-
{
2213-
m_Paths[side][FGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2214-
m_Paths[side][BGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2215-
}
2216-
}
2217+
for (int side = 0; side < SIDECOUNT; ++side)
2218+
{
2219+
m_Paths[side][FGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2220+
m_Paths[side][BGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2221+
}
2222+
}
22172223

2218-
// Walk backwards if the aiming is already focused in the opposite direction of travel.
2219-
if (std::abs(analogAim.m_X) > 0 || m_Controller.IsState(AIM_SHARP)) {
2220-
for (int side = 0; side < SIDECOUNT; ++side) {
2221-
m_Paths[side][FGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2222-
m_Paths[side][BGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2223-
}
2224-
} else if ((m_Controller.IsState(MOVE_RIGHT) && m_HFlipped) || (m_Controller.IsState(MOVE_LEFT) && !m_HFlipped)) {
2225-
m_HFlipped = !m_HFlipped;
2226-
m_CheckTerrIntersection = true;
2227-
MoveOutOfTerrain(g_MaterialGrass);
2228-
for (int side = 0; side < SIDECOUNT; ++side)
2229-
{
2230-
for (int layer = 0; layer < LAYERCOUNT; ++layer)
2231-
{
2232-
m_Paths[side][layer][m_MoveState].SetHFlip(m_HFlipped);
2233-
m_Paths[side][layer][WALK].Terminate();
2234-
m_Paths[side][layer][STAND].Terminate();
2235-
}
2236-
m_StrideStart[side] = true;
2237-
}
2238-
}
2239-
}
2240-
else
2241-
m_MoveState = STAND;
2224+
// Walk backwards if the aiming is already focused in the opposite direction of travel.
2225+
if (std::abs(analogAim.m_X) > 0 || m_Controller.IsState(AIM_SHARP)) {
2226+
for (int side = 0; side < SIDECOUNT; ++side) {
2227+
m_Paths[side][FGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2228+
m_Paths[side][BGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2229+
}
2230+
} else if ((m_Controller.IsState(MOVE_RIGHT) && m_HFlipped) || (m_Controller.IsState(MOVE_LEFT) && !m_HFlipped)) {
2231+
m_HFlipped = !m_HFlipped;
2232+
m_CheckTerrIntersection = true;
2233+
MoveOutOfTerrain(g_MaterialGrass);
2234+
for (int side = 0; side < SIDECOUNT; ++side)
2235+
{
2236+
for (int layer = 0; layer < LAYERCOUNT; ++layer)
2237+
{
2238+
m_Paths[side][layer][m_MoveState].SetHFlip(m_HFlipped);
2239+
m_Paths[side][layer][WALK].Terminate();
2240+
m_Paths[side][layer][STAND].Terminate();
2241+
}
2242+
m_StrideStart[side] = true;
2243+
}
2244+
}
2245+
} else {
2246+
m_MoveState = STAND;
2247+
}
2248+
}
22422249

22432250
////////////////////////////////////
22442251
// Reload held MO, if applicable

Entities/AHuman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ void AHuman::Update()
30913091
// If the pie menu is on, try to preserve whatever move state we had before it going into effect.
30923092
// This is only done for digital input, where the user needs to use the keyboard to choose pie slices.
30933093
// For analog input, this doesn't matter - the mouse or aiming analog stick controls the pie menu.
3094-
bool keepOldState = !m_Controller.IsMouseControlled() && !m_Controller.IsGamepadControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
3094+
bool keepOldState = m_Controller.IsKeyboardOnlyControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
30953095

30963096
if (!keepOldState) {
30973097
bool crouching = m_Controller.IsState(BODY_CROUCH);

Entities/Activity.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ namespace RTE {
363363
/// </summary>
364364
/// <param name="player">The player to reset the message timer for.</param>
365365
void ResetMessageTimer(int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_MessageTimer[player].Reset(); } }
366+
367+
/// <summary>
368+
/// Gets a pointer to the GUI controller of the specified player.
369+
/// </summary>
370+
/// <param name="player">Which player to get the Controller of.</param>
371+
/// <returns>A pointer to the player's Controller. Ownership is NOT transferred!</returns>
372+
Controller * GetPlayerController(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? &m_PlayerController[player] : nullptr; }
366373
#pragma endregion
367374

368375
#pragma region Team Handling
@@ -629,7 +636,7 @@ namespace RTE {
629636
/// </summary>
630637
/// <param name="player">Which player to get the controlled actor of.</param>
631638
/// <returns>A pointer to the controlled Actor. Ownership is NOT transferred! 0 If no actor is currently controlled by this player.</returns>
632-
Actor * GetControlledActor(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_ControlledActor[player] : 0; }
639+
Actor * GetControlledActor(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_ControlledActor[player] : nullptr; }
633640

634641
/// <summary>
635642
/// Makes the player's ControlledActor the leader of any squad it is a member of.

Entities/PieMenu.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,12 @@ namespace RTE {
844844
m_ActivatedPieSlice = m_HoveredPieSlice->IsEnabled() ? m_HoveredPieSlice : m_ActivatedPieSlice;
845845
m_AlreadyActivatedPieSlice = m_ActivatedPieSlice;
846846

847-
SoundContainer *soundToPlay = m_HoveredPieSlice->IsEnabled() ? g_GUISound.SlicePickedSound() : g_GUISound.DisabledPickedSound();
848-
soundToPlay->Play();
847+
if (m_HoveredPieSlice->GetSubPieMenu() && controller->IsState(ControlState::RELEASE_SECONDARY)) {
848+
g_GUISound.UserErrorSound()->Play();
849+
} else {
850+
SoundContainer *soundToPlay = m_HoveredPieSlice->IsEnabled() ? g_GUISound.SlicePickedSound() : g_GUISound.DisabledPickedSound();
851+
soundToPlay->Play();
852+
}
849853
}
850854

851855
if (IsEnabled()) {

GUI/GUIControlManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,25 +313,25 @@ void GUIControlManager::Draw(GUIScreen *pScreen) {
313313

314314
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
315315

316-
void GUIControlManager::DrawMouse() {
316+
void GUIControlManager::DrawMouse(GUIScreen *guiScreen) {
317317
int MouseX;
318318
int MouseY;
319319
m_Input->GetMousePosition(&MouseX, &MouseY);
320320

321321
switch (m_CursorType) {
322322
// Pointer
323323
case Pointer:
324-
m_Skin->DrawMouse(0, MouseX, MouseY);
324+
m_Skin->DrawMouse(0, MouseX, MouseY, guiScreen);
325325
break;
326326

327327
// Text
328328
case Text:
329-
m_Skin->DrawMouse(1, MouseX, MouseY);
329+
m_Skin->DrawMouse(1, MouseX, MouseY, guiScreen);
330330
break;
331331

332332
// Horizontal Resize
333333
case HorSize:
334-
m_Skin->DrawMouse(2, MouseX, MouseY);
334+
m_Skin->DrawMouse(2, MouseX, MouseY, guiScreen);
335335
break;
336336
default:
337337
break;

GUI/GUIControlManager.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,11 @@ class GUIControlManager {
115115
void Draw(GUIScreen *pScreen);
116116

117117

118-
//////////////////////////////////////////////////////////////////////////////////////////
119-
// Method: DrawMouse
120-
//////////////////////////////////////////////////////////////////////////////////////////
121-
// Description: Draws the mouse.
122-
// Arguments: None.
123-
124-
void DrawMouse();
118+
/// <summary>
119+
/// Draws the mouse to the backbuffer.
120+
/// </summary>
121+
/// <param name="pScreen">The GUIScreen to draw to, overriding the one passed in on construction.</param>
122+
void DrawMouse(GUIScreen *guiScreen = nullptr);
125123

126124

127125
//////////////////////////////////////////////////////////////////////////////////////////
@@ -224,7 +222,7 @@ class GUIControlManager {
224222
// Description: Gets an event from the queue.
225223
// Arguments: Pointer to variable receiving the Event.
226224
// Returns: Returns true when an event was grabbed.
227-
// Returns false when there was no more events in the queue
225+
// Returns false when there was no more events in the queue
228226
// OR the Event pointer is 0.
229227

230228
bool GetEvent(GUIEvent *Event);

GUI/GUISkin.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ GUIBitmap * GUISkin::LoadMousePointer(const std::string &Section) {
292292

293293
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
294294

295-
void GUISkin::DrawMouse(int Image, int X, int Y) {
295+
void GUISkin::DrawMouse(int Image, int X, int Y, GUIScreen *guiScreenOverride) {
296296
assert(Image >= 0 && Image <= 2);
297297

298-
if (m_MousePointers[Image]) { m_Screen->DrawBitmapTrans(m_MousePointers[Image], X - 1, Y - 1, nullptr); }
298+
GUIScreen *targetScreen = guiScreenOverride ? guiScreenOverride : m_Screen;
299+
300+
if (m_MousePointers[Image]) { targetScreen->DrawBitmapTrans(m_MousePointers[Image], X - 1, Y - 1, nullptr); }
299301
}
300302

301303
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

GUI/GUISkin.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,14 @@ class GUISkin {
122122
GUIFont * GetFont(const std::string &Name);
123123

124124

125-
//////////////////////////////////////////////////////////////////////////////////////////
126-
// Method: DrawMouse
127-
//////////////////////////////////////////////////////////////////////////////////////////
128-
// Description: Draws the mouse onto the screen.
129-
// Arguments: Mouse image ID, Position.
130-
131-
void DrawMouse(int Image, int X, int Y);
125+
/// <summary>
126+
/// Draws the mouse onto the screen.
127+
/// </summary>
128+
/// <param name="Image">Mouse image ID.</param>
129+
/// <param name="X">Horizontal position on the screen.</param>
130+
/// <param name="Y">Vertical position on the screen.</param>
131+
/// <param name="pScreen">The GUIScreen to draw to, overriding the one passed in on construction.</param>
132+
void DrawMouse(int Image, int X, int Y, GUIScreen *guiScreenOverride = nullptr);
132133

133134

134135
//////////////////////////////////////////////////////////////////////////////////////////
@@ -150,7 +151,7 @@ class GUISkin {
150151
// An optional target color depth that will determine what format the color
151152
// should be converted to. If this is 0, then the current video color depth
152153
// will be used as target.
153-
154+
154155
unsigned long ConvertColor(unsigned long color, int targetDepth = 0);
155156

156157

Lua/LuaBindingsActivities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace RTE {
4343
.def("HumanBrainCount", &Activity::HumanBrainCount)
4444
.def("AIBrainCount", &Activity::AIBrainCount)
4545
.def("GetControlledActor", &Activity::GetControlledActor)
46+
.def("GetPlayerController", &Activity::GetPlayerController)
4647
.def("SetTeamFunds", &Activity::SetTeamFunds)
4748
.def("GetTeamFunds", &Activity::GetTeamFunds)
4849
.def("SetTeamAISkill", &Activity::SetTeamAISkill)

0 commit comments

Comments
 (0)