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 {nullptr}
 
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.

844 {
846 }
C4Facet ViewportArea
Definition: C4Viewport.h:171
void Default()
Definition: C4Facet.cpp:31

Here is the call graph for this function:

C4ViewportList::~C4ViewportList ( )
default

Member Function Documentation

void C4ViewportList::Clear ( )

Definition at line 848 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4GraphicsSystem::Clear().

849 {
850  C4Viewport *next;
851  while (FirstViewport)
852  {
853  next=FirstViewport->Next;
854  delete FirstViewport;
855  FirstViewport=next;
856  }
857  FirstViewport=nullptr;
858 }
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 956 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::ClearPointers().

957 {
958  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
959  cvp->ClearPointers(pObj);
960 }
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 961 of file C4Viewport.cpp.

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

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

962 {
963  // Close all matching viewports
964  int32_t iLastCount = GetViewportCount();
965  C4Viewport *next,*prev=nullptr;
966  for (C4Viewport *cvp=FirstViewport; cvp; cvp=next)
967  {
968  next=cvp->Next;
969  if (cvp->Player==iPlayer || (iPlayer==NO_OWNER && cvp->fIsNoOwnerViewport))
970  {
971  delete cvp;
972  if (prev) prev->Next=next;
973  else FirstViewport=next;
974  }
975  else
976  prev=cvp;
977  }
978  // Anything was done?
979  if (GetViewportCount()!=iLastCount)
980  {
981  // Recalculate viewports
983  // Action sound
984  if (!fSilent) StartSoundEffect("UI::CloseViewport");
985  }
986  return true;
987 }
void RecalculateViewports()
Definition: C4Viewport.cpp:989
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:137
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 883 of file C4Viewport.cpp.

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

884 {
885  if (!cvp) return false;
886  // Chop the start of the chain off
887  if (FirstViewport == cvp)
888  {
889  FirstViewport = cvp->Next;
890  delete cvp;
891  StartSoundEffect("UI::CloseViewport");
892  }
893  // Take out of the chain
894  else for (C4Viewport * prev = FirstViewport; prev; prev = prev->Next)
895  {
896  if (prev->Next == cvp)
897  {
898  prev->Next = cvp->Next;
899  delete cvp;
900  StartSoundEffect("UI::CloseViewport");
901  }
902  }
903  // Recalculate viewports
905  // Done
906  return true;
907 }
void RecalculateViewports()
Definition: C4Viewport.cpp:989
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 917 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().

918 {
919  // Create and init new viewport, add to viewport list
920  int32_t iLastCount = GetViewportCount();
921  C4Viewport *nvp = new C4Viewport;
922  bool fOkay = nvp->Init(iPlayer, false);
923  if (!fOkay) { delete nvp; return false; }
924  C4Viewport *pLast;
925  for (pLast=FirstViewport; pLast && pLast->Next; pLast=pLast->Next) {}
926  if (pLast) pLast->Next=nvp; else FirstViewport=nvp;
927  // Recalculate viewports
929  // Viewports start off at centered position
930  nvp->CenterPosition();
931  // Initial player zoom values to viewport (in case they were set early in InitializePlayer, loaded from savegame, etc.)
932  C4Player *plr = ::Players.Get(iPlayer);
933  if (plr)
934  {
935  plr->ZoomToViewport(nvp, true, false, false);
936  plr->ZoomLimitsToViewport(nvp);
937  }
938  // Action sound
939  if (GetViewportCount()!=iLastCount) if (!fSilent)
940  StartSoundEffect("UI::CloseViewport");
941  return true;
942 }
void ZoomLimitsToViewport(C4Viewport *vp)
Definition: C4Player.cpp:1858
void RecalculateViewports()
Definition: C4Viewport.cpp:989
void ZoomToViewport(C4Viewport *vp, bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1842
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 944 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

945 {
946  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
947  cvp->DisableFoW();
948 }
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 874 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().

875 {
876  for (int i=0, iNum=BackgroundAreas.GetCount(); i<iNum; ++i)
877  {
878  const C4Rect &rc = BackgroundAreas.Get(i);
880  }
881 }
size_t GetCount() const
Definition: C4Rect.h:106
C4Surface * pSurface
Definition: C4Window.h:274
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
Definition: C4Rect.h:27
C4GraphicsResource GraphicsResource
int32_t Wdt
Definition: C4Rect.h:30
bool BlitSurfaceTile(C4Surface *sfcSurface, C4Surface *sfcTarget, float iToX, float iToY, float iToWdt, float iToHgt, float iOffsetX, float iOffsetY, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:535
int32_t y
Definition: C4Rect.h:30
C4RectList BackgroundAreas
Definition: C4Viewport.h:172
C4Draw * pDraw
Definition: C4Draw.cpp:42
C4Rect & Get(size_t idx)
Definition: C4Rect.h:107
int32_t x
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
C4Surface * Surface
Definition: C4Facet.h:117

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ViewportList::EnableFoW ( )

Definition at line 950 of file C4Viewport.cpp.

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

951 {
952  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
953  cvp->EnableFoW();
954 }
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 860 of file C4Viewport.cpp.

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

Referenced by C4GraphicsSystem::Execute().

861 {
862  // Background redraw
863  if (DrawBackground)
865  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
866  {
867  if (cvp->GetWindow())
868  cvp->GetWindow()->RequestUpdate();
869  else
870  cvp->Execute();
871  }
872 }
void DrawFullscreenBackground()
Definition: C4Viewport.cpp:874
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 1146 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().

1147 {
1148  // safety: move valid?
1149  if ((!Game.C4S.Head.Replay || !Game.C4S.Head.Film) && !GetViewport(NO_OWNER)) return false;
1150  C4Viewport *vp = GetFirstViewport();
1151  if (!vp) return false;
1152  // move then (old static code crap...)
1153  static int32_t vp_vx=0; static int32_t vp_vy=0; static int32_t vp_vf=0;
1154  int32_t dx=vScrollBy.x; int32_t dy=vScrollBy.y;
1155  if (Game.FrameCounter-vp_vf < 5)
1156  { dx += vp_vx; dy += vp_vy; }
1157  vp_vx=dx; vp_vy=dy; vp_vf=Game.FrameCounter;
1158  vp->ScrollView(dx, dy);
1159  return true;
1160 }
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
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:128
void ScrollView(float byX, float byY)
Definition: C4Viewport.cpp:734
const int NO_OWNER
Definition: C4Constants.h:137
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 1078 of file C4Viewport.cpp.

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

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

1079 {
1080  // default audibility radius
1081  if (!iAudibilityRadius) iAudibilityRadius = C4AudibilityRadius;
1082  // Accumulate audibility by viewports
1083  int32_t iAudible=0; *iPan = 0;
1084  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
1085  {
1086  float distanceToCenterOfViewport = Distance(cvp->GetViewCenterX(),cvp->GetViewCenterY(),iX,iY);
1087  int32_t audibility = Clamp<int32_t>(100 - 100 * distanceToCenterOfViewport / C4AudibilityRadius, 0, 100);
1088  if (audibility > iAudible)
1089  {
1090  iAudible = audibility;
1091  if (outPlayer) *outPlayer = cvp->Player;
1092  }
1093  *iPan += (iX-(cvp->GetViewCenterX())) / 5;
1094  }
1095  *iPan = Clamp<int32_t>(*iPan, -100, 100);
1096  return iAudible;
1097 }
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:25
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 1070 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().

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

Here is the caller graph for this function:

int32_t C4ViewportList::GetViewportCount ( )

Definition at line 1063 of file C4Viewport.cpp.

References FirstViewport, iResult, and C4Viewport::Next.

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

1064 {
1065  int32_t iResult = 0;
1066  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next) iResult++;
1067  return iResult;
1068 }
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 1174 of file C4Viewport.cpp.

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

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

1175 {
1176  // Pass on to mouse controlled viewport
1177  for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
1178  if (::MouseControl.IsViewport(cvp))
1179  ::MouseControl.Move( iButton,
1180  Clamp<int32_t>(iX-cvp->OutX,0,cvp->ViewWdt-1),
1181  Clamp<int32_t>(iY-cvp->OutY,0,cvp->ViewHgt-1),
1182  dwKeyParam );
1183 }
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 989 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().

990 {
991 
992  // Fullscreen only
993  if (Application.isEditor) return;
994 
995  // Sort viewports
997 
998  // Viewport area
999  int32_t iBorderTop = 0;
1001  iBorderTop = C4UpperBoardHeight;
1003 
1004  // Redraw flag
1006 #ifdef _WIN32
1007  // reset mouse clipping
1008  ClipCursor(nullptr);
1009 #else
1010  // StdWindow handles this.
1011 #endif
1012  // reset GUI dlg pos
1014 
1015  // fullscreen background: First, cover all of screen
1018 
1019  // Viewports
1020  C4Viewport *cvp;
1021  int32_t iViews = 0;
1022  for (cvp=FirstViewport; cvp; cvp=cvp->Next) iViews++;
1023  if (!iViews) return;
1024  int32_t iViewsH = (int32_t) sqrt(float(iViews));
1025  int32_t iViewsX = iViews / iViewsH;
1026  int32_t iViewsL = iViews % iViewsH;
1027  int32_t cViewH,cViewX,ciViewsX;
1028  int32_t cViewWdt,cViewHgt,cOffWdt,cOffHgt,cOffX,cOffY;
1029  cvp=FirstViewport;
1030  for (cViewH=0; cViewH<iViewsH; cViewH++)
1031  {
1032  ciViewsX = iViewsX; if (cViewH<iViewsL) ciViewsX++;
1033  for (cViewX=0; cViewX<ciViewsX; cViewX++)
1034  {
1035  cViewWdt = ViewportArea.Wdt/ciViewsX;
1036  cViewHgt = ViewportArea.Hgt/iViewsH;
1037  cOffX = ViewportArea.X;
1038  cOffY = ViewportArea.Y;
1039  cOffWdt = cOffHgt = 0;
1040  if (ciViewsX * cViewWdt < ViewportArea.Wdt)
1041  cOffX = (ViewportArea.Wdt - ciViewsX * cViewWdt) / 2;
1042  if (iViewsH * cViewHgt < ViewportArea.Hgt)
1043  cOffY = (ViewportArea.Hgt - iViewsH * cViewHgt) / 2 + ViewportArea.Y;
1045  {
1046  if (cViewX < ciViewsX - 1) cOffWdt=4;
1047  if (cViewH < iViewsH - 1) cOffHgt=4;
1048  }
1049  int32_t coViewWdt=cViewWdt-cOffWdt;
1050  int32_t coViewHgt=cViewHgt-cOffHgt;
1051  C4Rect rcOut(cOffX+cViewX*cViewWdt, cOffY+cViewH*cViewHgt, coViewWdt, coViewHgt);
1052  cvp->SetOutputSize(rcOut.x,rcOut.y,rcOut.x,rcOut.y,rcOut.Wdt,rcOut.Hgt);
1053  cvp=cvp->Next;
1054  // clip down area avaiable for background drawing
1055  BackgroundAreas.ClipByRect(rcOut);
1056  }
1057  }
1058  // and finally recalculate script menus
1059  if (::Game.ScriptGuiRoot)
1060  ::Game.ScriptGuiRoot->RequestLayoutUpdate();
1061 }
void AddRect(const C4Rect &rNewRect)
Definition: C4Rect.h:101
C4Config Config
Definition: C4Config.cpp:833
float Y
Definition: C4Facet.h:118
C4Game Game
Definition: C4Globals.cpp:52
C4Facet ViewportArea
Definition: C4Viewport.h:171
C4Surface * pSurface
Definition: C4Window.h:274
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
Definition: C4Rect.h:27
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:101
void SortViewportsByPlayerControl()
C4ConfigGraphics Graphics
Definition: C4Config.h:253
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
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:97
void ClipByRect(const C4Rect &rClip)
Definition: C4Rect.cpp:173
float Hgt
Definition: C4Facet.h:118
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:233
void Clear()
Definition: C4Rect.h:105
float Wdt
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
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 1099 of file C4Viewport.cpp.

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

Referenced by RecalculateViewports().

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

1136 {
1137  // safety: switch valid?
1138  if ((!Game.C4S.Head.Film || !Game.C4S.Head.Replay) && !GetViewport(NO_OWNER)) return false;
1139  // do switch then
1140  C4Viewport *vp = GetFirstViewport();
1141  if (!vp) return false;
1142  vp->NextPlayer();
1143  return true;
1144 }
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
bool Replay
Definition: C4Scenario.h:72
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
const int NO_OWNER
Definition: C4Constants.h:137
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 1168 of file C4Viewport.cpp.

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

1169 {
1170  for (C4Viewport *vp = FirstViewport; vp; vp = vp->Next) vp->ChangeZoom(C4GFX_ZoomStep);
1171  return true;
1172 }
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 1162 of file C4Viewport.cpp.

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

1163 {
1164  for (C4Viewport *vp = FirstViewport; vp; vp = vp->Next) vp->ChangeZoom(1.0f/C4GFX_ZoomStep);
1165  return true;
1166 }
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: