OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ViewportList Class Reference

#include <C4Viewport.h>

Collaboration diagram for C4ViewportList:
[legend]

Public Member Functions

 C4ViewportList ()
 
 ~C4ViewportList ()
 
void Clear ()
 
void ClearPointers (C4Object *pObj)
 
void Execute (bool DrawBackground)
 
void SortViewportsByPlayerControl ()
 
void RecalculateViewports ()
 
void DisableFoW ()
 
void EnableFoW ()
 
bool CreateViewport (int32_t iPlayer, bool fSilent=false)
 
bool CloseViewport (int32_t iPlayer, bool fSilent)
 
int32_t GetViewportCount ()
 
C4ViewportGetViewport (int32_t iPlayer, C4Viewport *pPrev=nullptr)
 
C4ViewportGetFirstViewport ()
 
bool CloseViewport (C4Viewport *cvp)
 
int32_t GetAudibility (int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius=0, int32_t *outPlayer=nullptr)
 
bool ViewportNextPlayer ()
 
bool FreeScroll (C4Vec2D vScrollBy)
 
bool ViewportZoomOut ()
 
bool ViewportZoomIn ()
 

Protected Member Functions

void MouseMoveToViewport (int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
void DrawFullscreenBackground ()
 

Protected Attributes

C4ViewportFirstViewport
 
C4Facet ViewportArea
 
C4RectList BackgroundAreas
 

Friends

class C4GUI::Screen
 
class C4GraphicsSystem
 

Detailed Description

Definition at line 141 of file C4Viewport.h.

Constructor & Destructor Documentation

C4ViewportList::C4ViewportList ( )

Definition at line 843 of file C4Viewport.cpp.

References C4Facet::Default(), and ViewportArea.

843  :
844  FirstViewport(nullptr)
845 {
847 }
C4Facet ViewportArea
Definition: C4Viewport.h:171
void Default()
Definition: C4Facet.cpp:31
C4Viewport * FirstViewport
Definition: C4Viewport.h:170

Here is the call graph for this function:

C4ViewportList::~C4ViewportList ( )

Definition at line 848 of file C4Viewport.cpp.

849 {
850 }

Member Function Documentation

void C4ViewportList::Clear ( )

Definition at line 851 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4GraphicsSystem::Clear().

852 {
853  C4Viewport *next;
854  while (FirstViewport)
855  {
856  next=FirstViewport->Next;
857  delete FirstViewport;
858  FirstViewport=next;
859  }
860  FirstViewport=nullptr;
861 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

void C4ViewportList::ClearPointers ( C4Object pObj)

Definition at line 959 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::ClearPointers().

960 {
961  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
962  cvp->ClearPointers(pObj);
963 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

bool C4ViewportList::CloseViewport ( int32_t  iPlayer,
bool  fSilent 
)

Definition at line 964 of file C4Viewport.cpp.

References FirstViewport, GetViewportCount(), C4Viewport::Next, NO_OWNER, RecalculateViewports(), and StartSoundEffect().

Referenced by C4ViewportWindow::Close(), C4PlayerList::Remove(), and C4FullScreen::ViewportCheck().

965 {
966  // Close all matching viewports
967  int32_t iLastCount = GetViewportCount();
968  C4Viewport *next,*prev=nullptr;
969  for (C4Viewport *cvp=FirstViewport; cvp; cvp=next)
970  {
971  next=cvp->Next;
972  if (cvp->Player==iPlayer || (iPlayer==NO_OWNER && cvp->fIsNoOwnerViewport))
973  {
974  delete cvp;
975  if (prev) prev->Next=next;
976  else FirstViewport=next;
977  }
978  else
979  prev=cvp;
980  }
981  // Anything was done?
982  if (GetViewportCount()!=iLastCount)
983  {
984  // Recalculate viewports
986  // Action sound
987  if (!fSilent) StartSoundEffect("UI::CloseViewport");
988  }
989  return true;
990 }
void RecalculateViewports()
Definition: C4Viewport.cpp:992
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
const int NO_OWNER
Definition: C4Constants.h:138
C4Viewport * Next
Definition: C4Viewport.h:109
int32_t GetViewportCount()

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ViewportList::CloseViewport ( C4Viewport cvp)

Definition at line 886 of file C4Viewport.cpp.

References FirstViewport, C4Viewport::Next, RecalculateViewports(), and StartSoundEffect().

887 {
888  if (!cvp) return false;
889  // Chop the start of the chain off
890  if (FirstViewport == cvp)
891  {
892  FirstViewport = cvp->Next;
893  delete cvp;
894  StartSoundEffect("UI::CloseViewport");
895  }
896  // Take out of the chain
897  else for (C4Viewport * prev = FirstViewport; prev; prev = prev->Next)
898  {
899  if (prev->Next == cvp)
900  {
901  prev->Next = cvp->Next;
902  delete cvp;
903  StartSoundEffect("UI::CloseViewport");
904  }
905  }
906  // Recalculate viewports
908  // Done
909  return true;
910 }
void RecalculateViewports()
Definition: C4Viewport.cpp:992
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the call graph for this function:

bool C4ViewportList::CreateViewport ( int32_t  iPlayer,
bool  fSilent = false 
)

Definition at line 920 of file C4Viewport.cpp.

References C4Viewport::CenterPosition(), FirstViewport, C4PlayerList::Get(), GetViewportCount(), C4Viewport::Init(), C4Viewport::Next, Players, RecalculateViewports(), StartSoundEffect(), C4Player::ZoomLimitsToViewport(), and C4Player::ZoomToViewport().

Referenced by ConsoleDlgProc(), C4Console::InitGame(), C4Game::InitGameFinal(), C4Game::JoinPlayer(), C4AppDelegate::newViewportForPlayer:, C4FullScreen::ViewportCheck(), and C4Console::ViewportNew().

921 {
922  // Create and init new viewport, add to viewport list
923  int32_t iLastCount = GetViewportCount();
924  C4Viewport *nvp = new C4Viewport;
925  bool fOkay = nvp->Init(iPlayer, false);
926  if (!fOkay) { delete nvp; return false; }
927  C4Viewport *pLast;
928  for (pLast=FirstViewport; pLast && pLast->Next; pLast=pLast->Next) {}
929  if (pLast) pLast->Next=nvp; else FirstViewport=nvp;
930  // Recalculate viewports
932  // Viewports start off at centered position
933  nvp->CenterPosition();
934  // Initial player zoom values to viewport (in case they were set early in InitializePlayer, loaded from savegame, etc.)
935  C4Player *plr = ::Players.Get(iPlayer);
936  if (plr)
937  {
938  plr->ZoomToViewport(nvp, true, false, false);
939  plr->ZoomLimitsToViewport(nvp);
940  }
941  // Action sound
942  if (GetViewportCount()!=iLastCount) if (!fSilent)
943  StartSoundEffect("UI::CloseViewport");
944  return true;
945 }
void ZoomLimitsToViewport(C4Viewport *vp)
Definition: C4Player.cpp:1862
void RecalculateViewports()
Definition: C4Viewport.cpp:992
void ZoomToViewport(C4Viewport *vp, bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1846
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4Player * Get(int iPlayer) const
C4PlayerList Players
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
void CenterPosition()
Definition: C4Viewport.cpp:630
C4Viewport * Next
Definition: C4Viewport.h:109
bool Init(int32_t iPlayer, bool fSetTempOnly)
Definition: C4Viewport.cpp:658
int32_t GetViewportCount()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ViewportList::DisableFoW ( )

Definition at line 947 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

948 {
949  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
950  cvp->DisableFoW();
951 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

void C4ViewportList::DrawFullscreenBackground ( )
protected

Definition at line 877 of file C4Viewport.cpp.

References BackgroundAreas, C4Draw::BlitSurfaceTile(), C4GraphicsResource::fctBackground, FullScreen, C4RectList::Get(), C4RectList::GetCount(), GraphicsResource, C4Rect::Hgt, pDraw, C4Window::pSurface, C4Facet::Surface, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by Execute().

878 {
879  for (int i=0, iNum=BackgroundAreas.GetCount(); i<iNum; ++i)
880  {
881  const C4Rect &rc = BackgroundAreas.Get(i);
883  }
884 }
size_t GetCount() const
Definition: C4Rect.h:108
C4Surface * pSurface
Definition: C4Window.h:279
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
Definition: C4Rect.h:29
C4GraphicsResource GraphicsResource
int32_t Wdt
Definition: C4Rect.h:32
bool BlitSurfaceTile(C4Surface *sfcSurface, C4Surface *sfcTarget, float iToX, float iToY, float iToWdt, float iToHgt, float iOffsetX, float iOffsetY, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:538
int32_t y
Definition: C4Rect.h:32
C4RectList BackgroundAreas
Definition: C4Viewport.h:172
C4Draw * pDraw
Definition: C4Draw.cpp:45
C4Rect & Get(size_t idx)
Definition: C4Rect.h:109
int32_t x
Definition: C4Rect.h:32
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ViewportList::EnableFoW ( )

Definition at line 953 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

954 {
955  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
956  cvp->EnableFoW();
957 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

void C4ViewportList::Execute ( bool  DrawBackground)

Definition at line 863 of file C4Viewport.cpp.

References DrawFullscreenBackground(), FirstViewport, and C4Viewport::Next.

Referenced by C4GraphicsSystem::Execute().

864 {
865  // Background redraw
866  if (DrawBackground)
868  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
869  {
870  if (cvp->GetWindow())
871  cvp->GetWindow()->RequestUpdate();
872  else
873  cvp->Execute();
874  }
875 }
void DrawFullscreenBackground()
Definition: C4Viewport.cpp:877
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ViewportList::FreeScroll ( C4Vec2D  vScrollBy)

Definition at line 1149 of file C4Viewport.cpp.

References C4Game::C4S, C4SHead::Film, C4Game::FrameCounter, Game, GetFirstViewport(), GetViewport(), C4Scenario::Head, NO_OWNER, C4SHead::Replay, C4Viewport::ScrollView(), C4Vec2D::x, and C4Vec2D::y.

Referenced by C4Game::InitKeyboard().

1150 {
1151  // safety: move valid?
1152  if ((!Game.C4S.Head.Replay || !Game.C4S.Head.Film) && !GetViewport(NO_OWNER)) return false;
1153  C4Viewport *vp = GetFirstViewport();
1154  if (!vp) return false;
1155  // move then (old static code crap...)
1156  static int32_t vp_vx=0; static int32_t vp_vy=0; static int32_t vp_vf=0;
1157  int32_t dx=vScrollBy.x; int32_t dy=vScrollBy.y;
1158  if (Game.FrameCounter-vp_vf < 5)
1159  { dx += vp_vx; dy += vp_vy; }
1160  vp_vx=dx; vp_vy=dy; vp_vf=Game.FrameCounter;
1161  vp->ScrollView(dx, dy);
1162  return true;
1163 }
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:76
bool Replay
Definition: C4Scenario.h:72
int32_t y
Definition: C4Facet.h:42
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
int32_t FrameCounter
Definition: C4Game.h:130
void ScrollView(float byX, float byY)
Definition: C4Viewport.cpp:734
const int NO_OWNER
Definition: C4Constants.h:138
C4SHead Head
Definition: C4Scenario.h:230
int32_t Film
Definition: C4Scenario.h:73
int32_t x
Definition: C4Facet.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4ViewportList::GetAudibility ( int32_t  iX,
int32_t  iY,
int32_t *  iPan,
int32_t  iAudibilityRadius = 0,
int32_t *  outPlayer = nullptr 
)

Definition at line 1081 of file C4Viewport.cpp.

References C4AudibilityRadius, Distance(), FirstViewport, and C4Viewport::Next.

Referenced by C4Object::Init(), and C4SoundInstance::SetVolumeByPos().

1082 {
1083  // default audibility radius
1084  if (!iAudibilityRadius) iAudibilityRadius = C4AudibilityRadius;
1085  // Accumulate audibility by viewports
1086  int32_t iAudible=0; *iPan = 0;
1087  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
1088  {
1089  float distanceToCenterOfViewport = Distance(cvp->GetViewCenterX(),cvp->GetViewCenterY(),iX,iY);
1090  int32_t audibility = Clamp<int32_t>(100 - 100 * distanceToCenterOfViewport / C4AudibilityRadius, 0, 100);
1091  if (audibility > iAudible)
1092  {
1093  iAudible = audibility;
1094  if (outPlayer) *outPlayer = cvp->Player;
1095  }
1096  *iPan += (iX-(cvp->GetViewCenterX())) / 5;
1097  }
1098  *iPan = Clamp<int32_t>(*iPan, -100, 100);
1099  return iAudible;
1100 }
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:24
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
const int32_t C4AudibilityRadius
Definition: C4SoundSystem.h:30
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

C4Viewport* C4ViewportList::GetFirstViewport ( )
inline

Definition at line 156 of file C4Viewport.h.

References FirstViewport.

Referenced by C4GraphicsSystem::DoSaveScreenshot(), FreeScroll(), C4Menu::GetViewport(), and ViewportNextPlayer().

156 { return FirstViewport; }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170

Here is the caller graph for this function:

C4Viewport * C4ViewportList::GetViewport ( int32_t  iPlayer,
C4Viewport pPrev = nullptr 
)

Definition at line 1073 of file C4Viewport.cpp.

References FirstViewport, C4Viewport::Next, and NO_OWNER.

Referenced by C4Object::ActivateMenu(), C4MainMenu::ActivateObserver(), C4Game::DoKeyboardInput(), C4MainMenu::DoRefillInternal(), FreeScroll(), C4MainMenu::MenuCommand(), C4MouseControl::Move(), C4ScriptGuiWindow::OnMouseIn(), C4Player::SetViewMode(), C4MouseControl::UpdateClip(), C4FullScreen::ViewportCheck(), ViewportNextPlayer(), ViewportWinProc(), C4Player::ZoomLimitsToViewports(), and C4Player::ZoomToViewports().

1074 {
1075  for (C4Viewport *cvp=pPrev ? pPrev->Next : FirstViewport; cvp; cvp=cvp->Next)
1076  if (cvp->Player==iPlayer || (iPlayer==NO_OWNER && cvp->fIsNoOwnerViewport))
1077  return cvp;
1078  return nullptr;
1079 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
const int NO_OWNER
Definition: C4Constants.h:138
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

int32_t C4ViewportList::GetViewportCount ( )

Definition at line 1066 of file C4Viewport.cpp.

References FirstViewport, iResult, and C4Viewport::Next.

Referenced by CloseViewport(), CreateViewport(), C4GraphicsSystem::FlashMessage(), and C4FullScreen::ViewportCheck().

1067 {
1068  int32_t iResult = 0;
1069  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next) iResult++;
1070  return iResult;
1071 }
int iResult
Definition: C4GroupMain.cpp:39
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the caller graph for this function:

void C4ViewportList::MouseMoveToViewport ( int32_t  iButton,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
protected

Definition at line 1177 of file C4Viewport.cpp.

References FirstViewport, C4MouseControl::IsViewport(), MouseControl, C4MouseControl::Move(), and C4Viewport::Next.

Referenced by C4GUI::Screen::MouseMove(), and C4GUI::Screen::SetMouseInGUI().

1178 {
1179  // Pass on to mouse controlled viewport
1180  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
1181  if (::MouseControl.IsViewport(cvp))
1182  ::MouseControl.Move( iButton,
1183  Clamp<int32_t>(iX-cvp->OutX,0,cvp->ViewWdt-1),
1184  Clamp<int32_t>(iY-cvp->OutY,0,cvp->ViewHgt-1),
1185  dwKeyParam );
1186 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
bool IsViewport(C4Viewport *pViewport)
void Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFlags, bool fCenter=false)
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ViewportList::RecalculateViewports ( )

Definition at line 992 of file C4Viewport.cpp.

References C4RectList::AddRect(), Application, BackgroundAreas, C4UpperBoardHeight, C4RectList::Clear(), C4RectList::ClipByRect(), Config, FirstViewport, FullScreen, Game, C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), C4Config::Graphics, GraphicsSystem, C4Rect::Hgt, C4Facet::Hgt, C4GraphicsSystem::InvalidateBg(), C4Application::isEditor, C4Viewport::Next, pGUI, C4Window::pSurface, C4Game::ScriptGuiRoot, C4Facet::Set(), C4Viewport::SetOutputSize(), C4GUI::Screen::SetPreferredDlgRect(), SortViewportsByPlayerControl(), C4ConfigGraphics::SplitscreenDividers, C4ConfigGraphics::UpperBoard, ViewportArea, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, and C4Facet::Y.

Referenced by CloseViewport(), CreateViewport(), C4GraphicsSystem::DoSaveScreenshot(), C4Game::InitFullscreenComponents(), C4Game::LoadScenarioSection(), C4MainMenu::MenuCommand(), and C4Game::OnResolutionChanged().

993 {
994 
995  // Fullscreen only
996  if (Application.isEditor) return;
997 
998  // Sort viewports
1000 
1001  // Viewport area
1002  int32_t iBorderTop = 0;
1004  iBorderTop = C4UpperBoardHeight;
1006 
1007  // Redraw flag
1009 #ifdef _WIN32
1010  // reset mouse clipping
1011  ClipCursor(nullptr);
1012 #else
1013  // StdWindow handles this.
1014 #endif
1015  // reset GUI dlg pos
1017 
1018  // fullscreen background: First, cover all of screen
1021 
1022  // Viewports
1023  C4Viewport *cvp;
1024  int32_t iViews = 0;
1025  for (cvp=FirstViewport; cvp; cvp=cvp->Next) iViews++;
1026  if (!iViews) return;
1027  int32_t iViewsH = (int32_t) sqrt(float(iViews));
1028  int32_t iViewsX = iViews / iViewsH;
1029  int32_t iViewsL = iViews % iViewsH;
1030  int32_t cViewH,cViewX,ciViewsX;
1031  int32_t cViewWdt,cViewHgt,cOffWdt,cOffHgt,cOffX,cOffY;
1032  cvp=FirstViewport;
1033  for (cViewH=0; cViewH<iViewsH; cViewH++)
1034  {
1035  ciViewsX = iViewsX; if (cViewH<iViewsL) ciViewsX++;
1036  for (cViewX=0; cViewX<ciViewsX; cViewX++)
1037  {
1038  cViewWdt = ViewportArea.Wdt/ciViewsX;
1039  cViewHgt = ViewportArea.Hgt/iViewsH;
1040  cOffX = ViewportArea.X;
1041  cOffY = ViewportArea.Y;
1042  cOffWdt = cOffHgt = 0;
1043  if (ciViewsX * cViewWdt < ViewportArea.Wdt)
1044  cOffX = (ViewportArea.Wdt - ciViewsX * cViewWdt) / 2;
1045  if (iViewsH * cViewHgt < ViewportArea.Hgt)
1046  cOffY = (ViewportArea.Hgt - iViewsH * cViewHgt) / 2 + ViewportArea.Y;
1048  {
1049  if (cViewX < ciViewsX - 1) cOffWdt=4;
1050  if (cViewH < iViewsH - 1) cOffHgt=4;
1051  }
1052  int32_t coViewWdt=cViewWdt-cOffWdt;
1053  int32_t coViewHgt=cViewHgt-cOffHgt;
1054  C4Rect rcOut(cOffX+cViewX*cViewWdt, cOffY+cViewH*cViewHgt, coViewWdt, coViewHgt);
1055  cvp->SetOutputSize(rcOut.x,rcOut.y,rcOut.x,rcOut.y,rcOut.Wdt,rcOut.Hgt);
1056  cvp=cvp->Next;
1057  // clip down area avaiable for background drawing
1058  BackgroundAreas.ClipByRect(rcOut);
1059  }
1060  }
1061  // and finally recalculate script menus
1062  if (::Game.ScriptGuiRoot)
1063  ::Game.ScriptGuiRoot->RequestLayoutUpdate();
1064 }
void AddRect(const C4Rect &rNewRect)
Definition: C4Rect.h:103
C4Config Config
Definition: C4Config.cpp:831
float Y
Definition: C4Facet.h:120
C4Game Game
Definition: C4Globals.cpp:52
C4Facet ViewportArea
Definition: C4Viewport.h:171
C4Surface * pSurface
Definition: C4Window.h:279
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
Definition: C4Rect.h:29
int32_t GetScreenWdt()
Definition: C4Gui.h:2821
void SetPreferredDlgRect(const C4Rect &rtNewPref)
Definition: C4Gui.h:2648
const int C4UpperBoardHeight
Definition: C4Constants.h:59
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
int32_t UpperBoard
Definition: C4Config.h:102
void SortViewportsByPlayerControl()
C4ConfigGraphics Graphics
Definition: C4Config.h:254
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1194
C4RectList BackgroundAreas
Definition: C4Viewport.h:172
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
int32_t GetScreenHgt()
Definition: C4Gui.h:2822
C4Viewport * Next
Definition: C4Viewport.h:109
int32_t SplitscreenDividers
Definition: C4Config.h:98
void ClipByRect(const C4Rect &rClip)
Definition: C4Rect.cpp:173
float Hgt
Definition: C4Facet.h:120
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:235
void Clear()
Definition: C4Rect.h:107
float Wdt
Definition: C4Facet.h:120
float X
Definition: C4Facet.h:120
void SetOutputSize(int32_t iDrawX, int32_t iDrawY, int32_t iOutX, int32_t iOutY, int32_t iOutWdt, int32_t iOutHgt)
Definition: C4Viewport.cpp:778
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ViewportList::SortViewportsByPlayerControl ( )

Definition at line 1102 of file C4Viewport.cpp.

References C4Player::ControlSet, FirstViewport, C4PlayerList::Get(), C4PlayerControlAssignmentSet::GetLayoutOrder(), C4Viewport::Next, and Players.

Referenced by RecalculateViewports().

1103 {
1104 
1105  // Sort
1106  bool fSorted;
1107  C4Player *pPlr1,*pPlr2;
1108  C4Viewport *pView,*pNext,*pPrev;
1109  do
1110  {
1111  fSorted = true;
1112  for (pPrev=nullptr,pView=FirstViewport; pView && (pNext = pView->Next); pView=pNext)
1113  {
1114  // Get players
1115  pPlr1 = ::Players.Get(pView->Player);
1116  pPlr2 = ::Players.Get(pNext->Player);
1117  // Swap order
1118  if (pPlr1 && pPlr2 && pPlr1->ControlSet && pPlr2->ControlSet && ( pPlr1->ControlSet->GetLayoutOrder() > pPlr2->ControlSet->GetLayoutOrder() ))
1119  {
1120  if (pPrev) pPrev->Next = pNext; else FirstViewport = pNext;
1121  pView->Next = pNext->Next;
1122  pNext->Next = pView;
1123  pPrev = pNext;
1124  pNext = pView;
1125  fSorted = false;
1126  }
1127  // Don't swap
1128  else
1129  {
1130  pPrev = pView;
1131  }
1132  }
1133  }
1134  while (!fSorted);
1135 
1136 }
C4Player * Get(int iPlayer) const
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
C4PlayerList Players
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ViewportList::ViewportNextPlayer ( )

Definition at line 1138 of file C4Viewport.cpp.

References C4Game::C4S, C4SHead::Film, Game, GetFirstViewport(), GetViewport(), C4Scenario::Head, C4Viewport::NextPlayer(), NO_OWNER, and C4SHead::Replay.

Referenced by C4Game::InitKeyboard().

1139 {
1140  // safety: switch valid?
1141  if ((!Game.C4S.Head.Film || !Game.C4S.Head.Replay) && !GetViewport(NO_OWNER)) return false;
1142  // do switch then
1143  C4Viewport *vp = GetFirstViewport();
1144  if (!vp) return false;
1145  vp->NextPlayer();
1146  return true;
1147 }
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:76
bool Replay
Definition: C4Scenario.h:72
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
const int NO_OWNER
Definition: C4Constants.h:138
void NextPlayer()
Definition: C4Viewport.cpp:808
C4SHead Head
Definition: C4Scenario.h:230
int32_t Film
Definition: C4Scenario.h:73

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ViewportList::ViewportZoomIn ( )

Definition at line 1171 of file C4Viewport.cpp.

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

1172 {
1173  for (C4Viewport *vp = FirstViewport; vp; vp = vp->Next) vp->ChangeZoom(C4GFX_ZoomStep);
1174  return true;
1175 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109
const float C4GFX_ZoomStep

Here is the caller graph for this function:

bool C4ViewportList::ViewportZoomOut ( )

Definition at line 1165 of file C4Viewport.cpp.

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

1166 {
1167  for (C4Viewport *vp = FirstViewport; vp; vp = vp->Next) vp->ChangeZoom(1.0f/C4GFX_ZoomStep);
1168  return true;
1169 }
C4Viewport * FirstViewport
Definition: C4Viewport.h:170
C4Viewport * Next
Definition: C4Viewport.h:109
const float C4GFX_ZoomStep

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4GraphicsSystem
friend

Definition at line 174 of file C4Viewport.h.

friend class C4GUI::Screen
friend

Definition at line 173 of file C4Viewport.h.

Member Data Documentation

C4RectList C4ViewportList::BackgroundAreas
protected

Definition at line 172 of file C4Viewport.h.

Referenced by DrawFullscreenBackground(), and RecalculateViewports().

C4Facet C4ViewportList::ViewportArea
protected

Definition at line 171 of file C4Viewport.h.

Referenced by C4ViewportList(), and RecalculateViewports().


The documentation for this class was generated from the following files: