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

Commit 3562ee0

Browse files
committed
Fix mouse cursor not drawing in split-screen when custom BuyMenu theme cursors are enabled (followup to 50ddb65)
1 parent 22c0ee4 commit 3562ee0

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

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

Menus/BuyMenuGUI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2063,7 +2063,7 @@ void BuyMenuGUI::Draw(BITMAP *drawBitmap) const {
20632063
if (g_SettingsMan.FactionBuyMenuThemeCursorsDisabled()) {
20642064
draw_sprite(drawBitmap, s_pCursor, m_CursorPos.GetFloorIntX(), m_CursorPos.GetFloorIntY());
20652065
} else {
2066-
m_pGUIController->DrawMouse();
2066+
m_pGUIController->DrawMouse(&drawScreen);
20672067
}
20682068
}
20692069
}

Menus/ObjectPickerGUI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ namespace RTE {
602602
if (g_SettingsMan.FactionBuyMenuThemeCursorsDisabled()) {
603603
draw_sprite(drawBitmap, s_Cursor, m_CursorPos.GetFloorIntX(), m_CursorPos.GetFloorIntY());
604604
} else {
605-
m_GUIControlManager->DrawMouse();
605+
m_GUIControlManager->DrawMouse(&drawScreen);
606606
}
607607
}
608608
}

0 commit comments

Comments
 (0)