Move Game.MouseControl to MouseControl

stable-5.2
Günther Brammer 2009-06-05 17:20:07 +02:00
parent fa05c07d5c
commit ab69802140
12 changed files with 47 additions and 45 deletions

View File

@ -97,7 +97,6 @@ class C4Game
C4PlayerInfoList &RestorePlayerInfos; // Shortcut
C4RoundResults RoundResults;
C4GameMessageList Messages;
C4MouseControl MouseControl;
C4Weather Weather;
C4MaterialMap Material;
C4GameObjects Objects;

View File

@ -144,4 +144,5 @@ class C4MouseControl
int32_t GetPlayer() { return Player; }
};
extern C4MouseControl MouseControl;
#endif

View File

@ -184,7 +184,7 @@ BOOL C4EditCursor::UpdateStatusBar()
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModePlay:
if (Game.MouseControl.GetCaption()) str.CopyUntil(Game.MouseControl.GetCaption(),'|');
if (::MouseControl.GetCaption()) str.CopyUntil(::MouseControl.GetCaption(),'|');
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeEdit:
@ -530,8 +530,8 @@ BOOL C4EditCursor::SetMode(int32_t iMode)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
// Update cursor
if (Mode==C4CNS_ModePlay) Game.MouseControl.ShowCursor();
else Game.MouseControl.HideCursor();
if (Mode==C4CNS_ModePlay) ::MouseControl.ShowCursor();
else ::MouseControl.HideCursor();
// Restore focus
#ifdef _WIN32
SetFocus(hFocus);

View File

@ -63,7 +63,7 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
if (Application.Active)
::GraphicsSystem.Execute();
// update cursor clip
Game.MouseControl.UpdateClip();
::MouseControl.UpdateClip();
return FALSE;
case WM_PAINT:
// Redraw after task switch
@ -425,7 +425,7 @@ BOOL C4FullScreen::ViewportCheck()
if (!fFilm)
{
// Activate mouse control
Game.MouseControl.Init(iPlrNum);
::MouseControl.Init(iPlrNum);
// Display message for how to open observer menu (this message will be cleared if any owned viewport opens)
StdStrBuf sKey;
sKey.Format("<c ffff00><%s></c>", Game.KeyboardInput.GetKeyCodeNameByKeyName("FullscreenMenuOpen", false).getData());

View File

@ -543,7 +543,7 @@ void C4GraphicsSystem::MouseMove(int32_t iButton, int32_t iX, int32_t iY, DWORD
{
// pass on to GUI
// Special: Don't pass if dragging and button is not upped
if (Game.pGUI && Game.pGUI->IsActive() && !Game.MouseControl.IsDragging())
if (Game.pGUI && Game.pGUI->IsActive() && !::MouseControl.IsDragging())
{
bool fResult = Game.pGUI->MouseInput(iButton, iX, iY, dwKeyParam, NULL, pVP);
if (Game.pGUI && Game.pGUI->HasMouseFocus()) { SetMouseInGUI(true, true); return; }
@ -556,7 +556,7 @@ void C4GraphicsSystem::MouseMove(int32_t iButton, int32_t iX, int32_t iY, DWORD
// no GUI: mouse is not in GUI
SetMouseInGUI(false, true);
// mouse control enabled?
if (!Game.MouseControl.IsActive())
if (!::MouseControl.IsActive())
{
// enable mouse in GUI, if a mouse-only-dlg is displayed
if (Game.pGUI && Game.pGUI->GetMouseControlledDialogCount())
@ -571,8 +571,8 @@ void C4GraphicsSystem::MouseMoveToViewport(int32_t iButton, int32_t iX, int32_t
{
// Pass on to mouse controlled viewport
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
if (Game.MouseControl.IsViewport(cvp))
Game.MouseControl.Move( iButton,
if (::MouseControl.IsViewport(cvp))
::MouseControl.Move( iButton,
BoundBy<int32_t>(iX-cvp->OutX,0,cvp->ViewWdt-1),
BoundBy<int32_t>(iY-cvp->OutY,0,cvp->ViewHgt-1),
dwKeyParam );
@ -585,13 +585,13 @@ void C4GraphicsSystem::SetMouseInGUI(bool fInGUI, bool fByMouse)
{
Game.pGUI->Mouse.SetOwnedMouse(fInGUI);
// initial movement to ensure mouse control pos is correct
if (!Game.MouseControl.IsMouseOwned() && !fInGUI && !fByMouse)
if (!::MouseControl.IsMouseOwned() && !fInGUI && !fByMouse)
{
Game.MouseControl.SetOwnedMouse(true);
::MouseControl.SetOwnedMouse(true);
MouseMoveToViewport(C4MC_Button_None, int32_t(Game.pGUI->Mouse.x*C4GUI::GetZoom()), int32_t(Game.pGUI->Mouse.y*C4GUI::GetZoom()), Game.pGUI->Mouse.dwKeys);
}
}
Game.MouseControl.SetOwnedMouse(!fInGUI);
::MouseControl.SetOwnedMouse(!fInGUI);
}
bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll)

View File

@ -470,7 +470,7 @@ void CMouse::Draw(C4TargetFacet &cgo, bool fDrawToolTip)
iOffsetY = -GfxR->fctMouseCursor.Hgt/2;
}
GfxR->fctMouseCursor.Draw(cgo.Surface,x+iOffsetX,y+iOffsetY,0);
if (Game.MouseControl.IsHelp())
if (::MouseControl.IsHelp())
GfxR->fctMouseCursor.Draw(cgo.Surface,x+iOffsetX+5,y+iOffsetY-5,29);
// ToolTip
if (fDrawToolTip && pMouseOverElement)
@ -689,7 +689,7 @@ void Screen::Render(bool fDoBG)
void Screen::RenderMouse(C4TargetFacet &cgo)
{
// draw mouse cursor
Mouse.Draw(cgo, (Mouse.IsMouseStill() && Mouse.IsActiveInput()) || Game.MouseControl.IsHelp());
Mouse.Draw(cgo, (Mouse.IsMouseStill() && Mouse.IsActiveInput()) || ::MouseControl.IsHelp());
}
void Screen::Draw(C4TargetFacet &cgo, bool fDoBG)
@ -761,7 +761,7 @@ bool Screen::MouseInput(int32_t iButton, int32_t iPxX, int32_t iPxY, DWORD dwKey
float fX = float(iPxX) / fZoom;
float fY = float(iPxY) / fZoom;
// help mode and button pressed: Abort help and discard button
if (Game.MouseControl.IsHelp())
if (::MouseControl.IsHelp())
{
switch (iButton)
{
@ -776,7 +776,7 @@ bool Screen::MouseInput(int32_t iButton, int32_t iPxX, int32_t iPxY, DWORD dwKey
break;
default:
// buttons stop help
Game.MouseControl.AbortHelp();
::MouseControl.AbortHelp();
iButton = C4MC_Button_None;
break;
}
@ -909,7 +909,7 @@ bool Screen::RecheckMouseInput()
void Screen::UpdateMouseFocus()
{
// when exclusive mode has changed: Make sure mouse clip is correct
Game.MouseControl.UpdateClip();
::MouseControl.UpdateClip();
}
void Screen::DoContext(ContextMenu *pNewCtx, Element *pAtElement, int32_t iX, int32_t iY)

View File

@ -928,7 +928,7 @@ void FullscreenDialog::DrawBackground(C4TargetFacet &cgo, C4Facet &rFromFct)
void FullscreenDialog::OnHelpBtn(C4GUI::Control *pBtn)
{
Game.MouseControl.SetHelp();
::MouseControl.SetHelp();
}

View File

@ -233,13 +233,13 @@ void C4MenuItem::MouseInput(C4GUI::CMouse &rMouse, int32_t iButton, int32_t iX,
else if (iButton == C4MC_Button_LeftUp)
{
// left-click performed
pMenu->UserEnter(Game.MouseControl.GetPlayer(), this, false);
pMenu->UserEnter(::MouseControl.GetPlayer(), this, false);
return;
}
else if (iButton == C4MC_Button_RightUp)
{
// right-up: Alternative enter command
pMenu->UserEnter(Game.MouseControl.GetPlayer(), this, true);
pMenu->UserEnter(::MouseControl.GetPlayer(), this, true);
return;
}
// inherited; this is just setting some vars
@ -250,7 +250,7 @@ void C4MenuItem::MouseInput(C4GUI::CMouse &rMouse, int32_t iButton, int32_t iX,
void C4MenuItem::MouseEnter(C4GUI::CMouse &rMouse)
{
// callback to menu: Select item
pMenu->UserSelectItem(Game.MouseControl.GetPlayer(), this);
pMenu->UserSelectItem(::MouseControl.GetPlayer(), this);
typedef C4GUI::Element ParentClass;
ParentClass::MouseEnter(rMouse);
}
@ -263,7 +263,7 @@ void C4MenuItem::DoDragging(C4GUI::CMouse &rMouse, int32_t iX, int32_t iY, DWORD
if (Max(Abs(iX - iDragX), Abs(iY - iDragY)) >= C4MC_DragSensitivity)
{
// then do a drag!
Game.MouseControl.StartConstructionDrag(id);
::MouseControl.StartConstructionDrag(id);
// this disables the window: Release mouse
rMouse.ReleaseButtons();
rMouse.pDragElement = NULL;

View File

@ -1405,3 +1405,5 @@ void C4MouseControl::StartConstructionDrag(C4ID id)
CreateDragImage(DragID);
Selection.Clear();
}
C4MouseControl MouseControl;

View File

@ -449,7 +449,7 @@ void C4ObjectMenu::OnUserEnter(int32_t Player, int32_t iIndex, bool fRight)
void C4ObjectMenu::OnUserClose()
{
// Queue
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(Game.MouseControl.GetPlayer(),COM_MenuClose,0));
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(::MouseControl.GetPlayer(),COM_MenuClose,0));
}
bool C4ObjectMenu::IsReadOnly()
@ -466,7 +466,7 @@ bool C4ObjectMenu::IsReadOnly()
// if the player is eliminated, do not control either!
if (!pVP->fIsNoOwnerViewport)
{
C4Player *pPlr = Game.Players.Get(Game.MouseControl.GetPlayer());
C4Player *pPlr = Game.Players.Get(::MouseControl.GetPlayer());
if (pPlr && pPlr->Eliminated) return true;
}
return false;

View File

@ -769,7 +769,7 @@ BOOL C4Player::FinalInit(BOOL fInitialValue)
// Init player's mouse control
if (LocalControl)
if (MouseControl)
Game.MouseControl.Init(Number);
::MouseControl.Init(Number);
// Set initial value
if (fInitialValue)
@ -2283,14 +2283,14 @@ void C4Player::ToggleMouseControl()
// Activate mouse control if it's available
if (!MouseControl && !Game.Players.MouseControlTaken())
{
Game.MouseControl.Init(Number);
::MouseControl.Init(Number);
MouseControl=TRUE;
}
// Deactivate mouse control
else if (MouseControl)
{
Game.MouseControl.Clear();
Game.MouseControl.Default();
::MouseControl.Clear();
::MouseControl.Default();
MouseControl = 0;
// Scrolling isn't possible any more
if (ViewMode == C4PVM_Scrolling)

View File

@ -165,7 +165,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
// Viewport mouse control
if (Game.MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch (uMsg)
{
@ -505,7 +505,7 @@ gboolean C4ViewportWindow::OnScrollStatic(GtkWidget* widget, GdkEventScroll* eve
{
C4ViewportWindow* window = static_cast<C4ViewportWindow*>(user_data);
if (Game.MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch(event->direction)
{
@ -525,7 +525,7 @@ gboolean C4ViewportWindow::OnButtonPressStatic(GtkWidget* widget, GdkEventButton
{
C4ViewportWindow* window = static_cast<C4ViewportWindow*>(user_data);
if (Game.MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch(event->button)
{
@ -566,7 +566,7 @@ gboolean C4ViewportWindow::OnButtonReleaseStatic(GtkWidget* widget, GdkEventButt
{
C4ViewportWindow* window = static_cast<C4ViewportWindow*>(user_data);
if (Game.MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch (event->button)
{
@ -601,7 +601,7 @@ gboolean C4ViewportWindow::OnMotionNotifyStatic(GtkWidget* widget, GdkEventMotio
{
C4ViewportWindow* window = static_cast<C4ViewportWindow*>(user_data);
if (Game.MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(window->cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
::GraphicsSystem.MouseMove(C4MC_Button_None, (int32_t)event->x, (int32_t)event->y, event->state, window->cvp);
}
@ -670,7 +670,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e)
case ButtonPress:
{
static int last_left_click, last_right_click;
if (Game.MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch (e.xbutton.button)
{
@ -727,7 +727,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e)
}
break;
case ButtonRelease:
if (Game.MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
switch (e.xbutton.button)
{
@ -758,7 +758,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e)
}
break;
case MotionNotify:
if (Game.MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
if (::MouseControl.IsViewport(cvp) && (Console.EditCursor.GetMode()==C4CNS_ModePlay))
{
::GraphicsSystem.MouseMove(C4MC_Button_None, e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp);
}
@ -859,12 +859,12 @@ void C4Viewport::DrawOverlay(C4TargetFacet &cgo, const ZoomData &GameZoom)
// Control overlays (if not film/replay)
if (!Game.C4S.Head.Film || !Game.C4S.Head.Replay)
// Mouse control
if (Game.MouseControl.IsViewport(this))
if (::MouseControl.IsViewport(this))
{
C4ST_STARTNEW(MouseStat, "C4Viewport::DrawOverlay: Mouse")
if (Config.Graphics.ShowCommands) // Now, ShowCommands is respected even for mouse control...
DrawMouseButtons(cgo);
Game.MouseControl.Draw(cgo, GameZoom);
::MouseControl.Draw(cgo, GameZoom);
// Draw GUI-mouse in EM if active
if (pWindow && Game.pGUI) Game.pGUI->RenderMouse(cgo);
C4ST_STOP(MouseStat)
@ -947,7 +947,7 @@ void C4Viewport::DrawCursorInfo(C4TargetFacet &cgo)
}
// Draw commands
if (Config.Graphics.ShowCommands /*|| Game.MouseControl.IsViewport(this)*/ ) // Now, ShowCommands is respected even for mouse control
if (Config.Graphics.ShowCommands /*|| ::MouseControl.IsViewport(this)*/ ) // Now, ShowCommands is respected even for mouse control
if (realcursor)
if (cgo.Hgt>C4SymbolSize)
{
@ -990,7 +990,7 @@ void C4Viewport::DrawMenu(C4TargetFacet &cgo)
if (ResetMenuPositions) pPlr->Cursor->Menu->ResetLocation();
// if mouse is dragging, make it transparent to easy construction site drag+drop
bool fDragging=false;
if (Game.MouseControl.IsDragging() && Game.MouseControl.IsViewport(this))
if (::MouseControl.IsDragging() && ::MouseControl.IsViewport(this))
{
fDragging = true;
lpDDraw->ActivateBlitModulation(0xafffffff);
@ -1215,13 +1215,13 @@ void C4Viewport::AdjustPosition()
float iTargetViewY = pPlr->ViewY - ViewHgt / (Zoom * 2);
// add mouse auto scroll
float iPrefViewX = ViewX - ViewOffsX, iPrefViewY = ViewY - ViewOffsY;
if(pPlr->MouseControl && Game.MouseControl.InitCentered && Config.General.MouseAScroll)
if(pPlr->MouseControl && ::MouseControl.InitCentered && Config.General.MouseAScroll)
{
int32_t iAutoScrollBorder = Min(Min(ViewWdt/10,ViewHgt/10), C4SymbolSize);
if(iAutoScrollBorder)
{
iPrefViewX += BoundBy<int32_t>(0, Game.MouseControl.VpX - ViewWdt + iAutoScrollBorder, Game.MouseControl.VpX - iAutoScrollBorder) * iScrollRange * BoundBy<int32_t>(Config.General.MouseAScroll, 0, 100) / 100 / iAutoScrollBorder;
iPrefViewY += BoundBy<int32_t>(0, Game.MouseControl.VpY - ViewHgt + iAutoScrollBorder, Game.MouseControl.VpY - iAutoScrollBorder) * iScrollRange * BoundBy<int32_t>(Config.General.MouseAScroll, 0, 100) / 100 / iAutoScrollBorder;
iPrefViewX += BoundBy<int32_t>(0, ::MouseControl.VpX - ViewWdt + iAutoScrollBorder, ::MouseControl.VpX - iAutoScrollBorder) * iScrollRange * BoundBy<int32_t>(Config.General.MouseAScroll, 0, 100) / 100 / iAutoScrollBorder;
iPrefViewY += BoundBy<int32_t>(0, ::MouseControl.VpY - ViewHgt + iAutoScrollBorder, ::MouseControl.VpY - iAutoScrollBorder) * iScrollRange * BoundBy<int32_t>(Config.General.MouseAScroll, 0, 100) / 100 / iAutoScrollBorder;
}
}
// scroll range
@ -1541,7 +1541,7 @@ void C4Viewport::SetOutputSize(int32_t iDrawX, int32_t iDrawY, int32_t iOutX, in
if (pPlr=Game.Players.Get(Player))
if (pPlr->MouseControl)
{
Game.MouseControl.UpdateClip();
::MouseControl.UpdateClip();
// and inform GUI
if (Game.pGUI)
//Game.pGUI->SetBounds(C4Rect(iOutX, iOutY, iOutWdt, iOutHgt));