OpenClonk
C4ViewportList Class Reference

#include <C4Viewport.h>

Collaboration diagram for C4ViewportList:
[legend]

Public Member Functions

 C4ViewportList ()
 
 ~C4ViewportList ()
 
void Clear ()
 
void ClearPointers (C4Object *obj)
 
void Execute (bool DrawBackground)
 
void SortViewportsByPlayerControl ()
 
void RecalculateViewports ()
 
void DisableFoW ()
 
void EnableFoW ()
 
bool CreateViewport (int32_t player_nr, bool silent=false)
 
bool CloseViewport (int32_t player_nr, bool silent)
 
int32_t GetViewportCount ()
 
C4ViewportGetViewport (int32_t player_nr, C4Viewport *prev=nullptr)
 
C4ViewportGetFirstViewport ()
 
bool CloseViewport (C4Viewport *viewport)
 
int32_t GetAudibility (int32_t x, int32_t y, int32_t *pan, int32_t audibility_radius=0, int32_t *out_player=nullptr)
 
bool ViewportNextPlayer ()
 
bool FreeScroll (C4Vec2D scroll_by)
 
bool ViewportZoomOut ()
 
bool ViewportZoomIn ()
 

Protected Member Functions

void MouseMoveToViewport (int32_t button, int32_t x, int32_t y, DWORD key_param)
 
void DrawFullscreenBackground ()
 

Protected Attributes

C4ViewportFirstViewport {nullptr}
 
C4Facet ViewportArea
 
C4RectList BackgroundAreas
 

Friends

class C4GUI::Screen
 
class C4GraphicsSystem
 

Detailed Description

Definition at line 144 of file C4Viewport.h.

Constructor & Destructor Documentation

◆ C4ViewportList()

C4ViewportList::C4ViewportList ( )

Definition at line 1027 of file C4Viewport.cpp.

1028 {
1030 }
void Default()
Definition: C4Facet.cpp:31
C4Facet ViewportArea
Definition: C4Viewport.h:174

References C4Facet::Default(), and ViewportArea.

Here is the call graph for this function:

◆ ~C4ViewportList()

C4ViewportList::~C4ViewportList ( )
default

Member Function Documentation

◆ Clear()

void C4ViewportList::Clear ( )

Definition at line 1032 of file C4Viewport.cpp.

1033 {
1034  C4Viewport *next;
1035  while (FirstViewport)
1036  {
1037  next = FirstViewport->Next;
1038  delete FirstViewport;
1039  FirstViewport = next;
1040  }
1041  FirstViewport = nullptr;
1042 }
C4Viewport * Next
Definition: C4Viewport.h:112
C4Viewport * FirstViewport
Definition: C4Viewport.h:173

References FirstViewport, and C4Viewport::Next.

Referenced by C4GraphicsSystem::Clear().

Here is the caller graph for this function:

◆ ClearPointers()

void C4ViewportList::ClearPointers ( C4Object obj)

Definition at line 1178 of file C4Viewport.cpp.

1179 {
1180  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1181  {
1182  viewport->ClearPointers(obj);
1183  }
1184 }

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::ClearPointers().

Here is the caller graph for this function:

◆ CloseViewport() [1/2]

bool C4ViewportList::CloseViewport ( C4Viewport viewport)

Definition at line 1073 of file C4Viewport.cpp.

1074 {
1075  if (!viewport)
1076  {
1077  return false;
1078  }
1079  // Chop the start of the chain off
1080  if (FirstViewport == viewport)
1081  {
1082  FirstViewport = viewport->Next;
1083  delete viewport;
1084  StartSoundEffect("UI::CloseViewport");
1085  }
1086  // Take out of the chain
1087  else for (C4Viewport * prev = FirstViewport; prev; prev = prev->Next)
1088  {
1089  if (prev->Next == viewport)
1090  {
1091  prev->Next = viewport->Next;
1092  delete viewport;
1093  StartSoundEffect("UI::CloseViewport");
1094  }
1095  }
1096  // Deleting a viewport may leave us with no context selected
1097  if (pDraw)
1098  {
1100  }
1101  // Recalculate viewports
1103  // Done
1104  return true;
1105 }
C4Draw * pDraw
Definition: C4Draw.cpp:42
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
virtual bool EnsureMainContextSelected()=0
void RecalculateViewports()

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

Here is the call graph for this function:

◆ CloseViewport() [2/2]

bool C4ViewportList::CloseViewport ( int32_t  player_nr,
bool  silent 
)

Definition at line 1186 of file C4Viewport.cpp.

1187 {
1188  // Close all matching viewports
1189  int32_t last_count = GetViewportCount();
1190  C4Viewport *next;
1191  C4Viewport *prev = nullptr;
1192  for (C4Viewport *viewport = FirstViewport; viewport; viewport = next)
1193  {
1194  next = viewport->Next;
1195  if (viewport->Player == player_nr || (player_nr == NO_OWNER && viewport->fIsNoOwnerViewport))
1196  {
1197  delete viewport;
1198  if (prev)
1199  {
1200  prev->Next = next;
1201  }
1202  else
1203  {
1204  FirstViewport = next;
1205  }
1206  }
1207  else
1208  {
1209  prev = viewport;
1210  }
1211  }
1212  // Anything was done?
1213  if (GetViewportCount() != last_count)
1214  {
1215  // Recalculate viewports
1217  // Action sound
1218  if (!silent)
1219  {
1220  StartSoundEffect("UI::CloseViewport");
1221  }
1222  }
1223  return true;
1224 }
const int NO_OWNER
Definition: C4Constants.h:137
int32_t GetViewportCount()

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateViewport()

bool C4ViewportList::CreateViewport ( int32_t  player_nr,
bool  silent = false 
)

Definition at line 1119 of file C4Viewport.cpp.

1120 {
1121  // Create and init new viewport, add to viewport list
1122  int32_t last_count = GetViewportCount();
1123  C4Viewport *viewport = new C4Viewport;
1124  bool is_okay = viewport->Init(player_nr, false);
1125  if (!is_okay)
1126  {
1127  delete viewport;
1128  return false;
1129  }
1130  C4Viewport *last;
1131  for (last = FirstViewport; last && last->Next; last = last->Next)
1132  {
1133 
1134  }
1135  if (last)
1136  {
1137  last->Next = viewport;
1138  }
1139  else
1140  {
1141  FirstViewport = viewport;
1142  }
1143  // Recalculate viewports
1145  // Viewports start off at centered position
1146  viewport->CenterPosition();
1147  // Initial player zoom values to viewport (in case they were set early in InitializePlayer, loaded from savegame, etc.)
1148  C4Player *player = ::Players.Get(player_nr);
1149  if (player)
1150  {
1151  player->ZoomToViewport(viewport, true, false, false);
1152  player->ZoomLimitsToViewport(viewport);
1153  }
1154  // Action sound
1155  if (!silent && GetViewportCount() != last_count)
1156  {
1157  StartSoundEffect("UI::CloseViewport");
1158  }
1159  return true;
1160 }
C4PlayerList Players
C4Player * Get(int iPlayer) const
bool Init(int32_t for_player, bool set_temporary_only)
Definition: C4Viewport.cpp:786
void CenterPosition()
Definition: C4Viewport.cpp:755

References C4Viewport::CenterPosition(), FirstViewport, C4PlayerList::Get(), GetViewportCount(), C4Viewport::Init(), C4Viewport::Next, C4ScriptGuiWindowPropertyName::player, Players, RecalculateViewports(), and StartSoundEffect().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisableFoW()

void C4ViewportList::DisableFoW ( )

Definition at line 1162 of file C4Viewport.cpp.

1163 {
1164  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1165  {
1166  viewport->DisableFoW();
1167  }
1168 }

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

Here is the caller graph for this function:

◆ DrawFullscreenBackground()

void C4ViewportList::DrawFullscreenBackground ( )
protected

Definition at line 1064 of file C4Viewport.cpp.

1065 {
1066  for (int i = 0, num = BackgroundAreas.GetCount(); i < num; ++i)
1067  {
1068  const C4Rect &rc = BackgroundAreas.Get(i);
1069  pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, FullScreen.pSurface, rc.x, rc.y, rc.Wdt, rc.Hgt, -rc.x, -rc.y, nullptr);
1070  }
1071 }
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
C4GraphicsResource GraphicsResource
bool BlitSurfaceTile(C4Surface *sfcSurface, C4Surface *sfcTarget, float iToX, float iToY, float iToWdt, float iToHgt, float iOffsetX, float iOffsetY, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:529
C4Surface * Surface
Definition: C4Facet.h:117
Definition: C4Rect.h:28
int32_t y
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
size_t GetCount() const
Definition: C4Rect.h:106
C4Rect & Get(size_t idx)
Definition: C4Rect.h:107
C4RectList BackgroundAreas
Definition: C4Viewport.h:175
C4Surface * pSurface
Definition: C4Window.h:275

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnableFoW()

void C4ViewportList::EnableFoW ( )

Definition at line 1170 of file C4Viewport.cpp.

1171 {
1172  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1173  {
1174  viewport->EnableFoW();
1175  }
1176 }

References FirstViewport, and C4Viewport::Next.

Referenced by C4Game::LoadScenarioSection().

Here is the caller graph for this function:

◆ Execute()

void C4ViewportList::Execute ( bool  DrawBackground)

Definition at line 1044 of file C4Viewport.cpp.

1045 {
1046  // Background redraw
1047  if (draw_background)
1048  {
1050  }
1051  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1052  {
1053  if (viewport->GetWindow())
1054  {
1055  viewport->GetWindow()->RequestUpdate();
1056  }
1057  else
1058  {
1059  viewport->Execute();
1060  }
1061  }
1062 }
void DrawFullscreenBackground()

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

Referenced by C4GraphicsSystem::Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeScroll()

bool C4ViewportList::FreeScroll ( C4Vec2D  scroll_by)

Definition at line 1421 of file C4Viewport.cpp.

1422 {
1423  // safety: move valid?
1424  if ((!Game.C4S.Head.Replay || !Game.C4S.Head.Film) && !GetViewport(NO_OWNER))
1425  {
1426  return false;
1427  }
1428  C4Viewport *viewport = GetFirstViewport();
1429  if (!viewport)
1430  {
1431  return false;
1432  }
1433  // move then (old static code crap...)
1434  static int32_t vp_vx = 0;
1435  static int32_t vp_vy = 0;
1436  static int32_t vp_vf = 0;
1437  int32_t dx = scroll_by.x;
1438  int32_t dy = scroll_by.y;
1439  if (Game.FrameCounter-vp_vf < 5)
1440  {
1441  dx += vp_vx;
1442  dy += vp_vy;
1443  }
1444  vp_vx = dx;
1445  vp_vy = dy;
1446  vp_vf = Game.FrameCounter;
1447  viewport->ScrollView(dx, dy);
1448  return true;
1449 }
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
int32_t FrameCounter
Definition: C4Game.h:129
bool Replay
Definition: C4Scenario.h:72
int32_t Film
Definition: C4Scenario.h:73
C4SHead Head
Definition: C4Scenario.h:232
void ScrollView(float by_x, float by_y)
Definition: C4Viewport.cpp:882
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:159
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)
int32_t x
Definition: C4Facet.h:42
int32_t y
Definition: C4Facet.h:42

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAudibility()

int32_t C4ViewportList::GetAudibility ( int32_t  x,
int32_t  y,
int32_t *  pan,
int32_t  audibility_radius = 0,
int32_t *  out_player = nullptr 
)

Definition at line 1340 of file C4Viewport.cpp.

1341 {
1342  // default audibility radius
1343  if (!audibility_radius)
1344  {
1345  audibility_radius = C4AudibilityRadius;
1346  }
1347  // Accumulate audibility by viewports
1348  int32_t audible = 0;
1349  *pan = 0;
1350  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1351  {
1352  float distanceToCenterOfViewport = Distance(viewport->GetViewCenterX(), viewport->GetViewCenterY(), x, y);
1353  int32_t audibility = Clamp<int32_t>(100 - 100 * distanceToCenterOfViewport / C4AudibilityRadius, 0, 100);
1354  if (audibility > audible)
1355  {
1356  audible = audibility;
1357  if (out_player)
1358  {
1359  *out_player = viewport->Player;
1360  }
1361  }
1362  *pan += (x-(viewport->GetViewCenterX())) / 5;
1363  }
1364  *pan = Clamp<int32_t>(*pan, -100, 100);
1365  return audible;
1366 }
const int32_t C4AudibilityRadius
Definition: C4SoundSystem.h:30
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:25

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFirstViewport()

C4Viewport* C4ViewportList::GetFirstViewport ( )
inline

Definition at line 159 of file C4Viewport.h.

159 { return FirstViewport; }

References FirstViewport.

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

Here is the caller graph for this function:

◆ GetViewport()

C4Viewport * C4ViewportList::GetViewport ( int32_t  player_nr,
C4Viewport prev = nullptr 
)

Definition at line 1328 of file C4Viewport.cpp.

1329 {
1330  for (C4Viewport *viewport = prev ? prev->Next : FirstViewport; viewport ; viewport = viewport ->Next)
1331  {
1332  if (viewport->Player == player || (player == NO_OWNER && viewport ->fIsNoOwnerViewport))
1333  {
1334  return viewport;
1335  }
1336  }
1337  return nullptr;
1338 }

References FirstViewport, C4Viewport::Next, NO_OWNER, and C4ScriptGuiWindowPropertyName::player.

Referenced by 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().

Here is the caller graph for this function:

◆ GetViewportCount()

int32_t C4ViewportList::GetViewportCount ( )

Definition at line 1318 of file C4Viewport.cpp.

1319 {
1320  int32_t amount = 0;
1321  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1322  {
1323  amount++;
1324  }
1325  return amount;
1326 }

References FirstViewport, and C4Viewport::Next.

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

Here is the caller graph for this function:

◆ MouseMoveToViewport()

void C4ViewportList::MouseMoveToViewport ( int32_t  button,
int32_t  x,
int32_t  y,
DWORD  key_param 
)
protected

Definition at line 1463 of file C4Viewport.cpp.

1464 {
1465  // Pass on to mouse controlled viewport
1466  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next)
1467  {
1468  if (::MouseControl.IsViewport(viewport))
1469  {
1470  ::MouseControl.Move( button,
1471  Clamp<int32_t>(x-viewport->OutX,0,viewport->ViewWdt-1),
1472  Clamp<int32_t>(y-viewport->OutY,0,viewport->ViewHgt-1),
1473  key_param );
1474  }
1475  }
1476 }
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)

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecalculateViewports()

void C4ViewportList::RecalculateViewports ( )

Definition at line 1226 of file C4Viewport.cpp.

1227 {
1228 
1229  // Fullscreen only
1230  if (Application.isEditor) return;
1231 
1232  // Sort viewports
1234 
1235  // Viewport area
1236  int32_t border_top = 0;
1238  {
1239  border_top = C4UpperBoardHeight;
1240  }
1241  ViewportArea.Set(FullScreen.pSurface, 0, border_top, C4GUI::GetScreenWdt(), C4GUI::GetScreenHgt() - border_top);
1242 
1243  // Redraw flag
1245 #ifdef _WIN32
1246  // reset mouse clipping
1247  ClipCursor(nullptr);
1248 #else
1249  // StdWindow handles this.
1250 #endif
1251  // reset GUI dlg pos
1253 
1254  // fullscreen background: First, cover all of screen
1257 
1258  // Viewports
1259  C4Viewport *viewport;
1260  int32_t view_count = 0;
1261  for (viewport = FirstViewport; viewport; viewport = viewport->Next)
1262  {
1263  view_count++;
1264  }
1265  if (!view_count)
1266  {
1267  return;
1268  }
1269  int32_t iViewsH = (int32_t) sqrt(float(view_count));
1270  int32_t iViewsX = view_count / iViewsH;
1271  int32_t iViewsL = view_count % iViewsH;
1272  int32_t cViewH, cViewX, ciViewsX;
1273  int32_t cViewWdt, cViewHgt, cOffWdt, cOffHgt, cOffX, cOffY;
1274  viewport=FirstViewport;
1275  for (cViewH = 0; cViewH < iViewsH; cViewH++)
1276  {
1277  ciViewsX = iViewsX;
1278  if (cViewH < iViewsL)
1279  {
1280  ciViewsX++;
1281  }
1282  for (cViewX=0; cViewX < ciViewsX; cViewX++)
1283  {
1284  cViewWdt = ViewportArea.Wdt/ciViewsX;
1285  cViewHgt = ViewportArea.Hgt/iViewsH;
1286  cOffX = ViewportArea.X;
1287  cOffY = ViewportArea.Y;
1288  cOffWdt = cOffHgt = 0;
1289  if (ciViewsX * cViewWdt < ViewportArea.Wdt)
1290  {
1291  cOffX = (ViewportArea.Wdt - ciViewsX * cViewWdt) / 2;
1292  }
1293  if (iViewsH * cViewHgt < ViewportArea.Hgt)
1294  {
1295  cOffY = (ViewportArea.Hgt - iViewsH * cViewHgt) / 2 + ViewportArea.Y;
1296  }
1298  {
1299  if (cViewX < ciViewsX - 1) cOffWdt=4;
1300  if (cViewH < iViewsH - 1) cOffHgt=4;
1301  }
1302  int32_t coViewWdt = cViewWdt-cOffWdt;
1303  int32_t coViewHgt = cViewHgt-cOffHgt;
1304  C4Rect rcOut(cOffX+cViewX*cViewWdt, cOffY+cViewH*cViewHgt, coViewWdt, coViewHgt);
1305  viewport->SetOutputSize(rcOut.x,rcOut.y,rcOut.x,rcOut.y,rcOut.Wdt,rcOut.Hgt);
1306  viewport = viewport->Next;
1307  // clip down area avaiable for background drawing
1308  BackgroundAreas.ClipByRect(rcOut);
1309  }
1310  }
1311  // and finally recalculate script menus
1312  if (::Game.ScriptGuiRoot)
1313  {
1314  ::Game.ScriptGuiRoot->RequestLayoutUpdate();
1315  }
1316 }
C4Config Config
Definition: C4Config.cpp:930
const int C4UpperBoardHeight
Definition: C4Constants.h:59
C4Application Application
Definition: C4Globals.cpp:44
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
int32_t SplitscreenDividers
Definition: C4Config.h:98
int32_t UpperBoard
Definition: C4Config.h:102
C4ConfigGraphics Graphics
Definition: C4Config.h:257
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
float Y
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
void SetPreferredDlgRect(const C4Rect &rtNewPref)
Definition: C4Gui.h:2651
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
void AddRect(const C4Rect &rNewRect)
Definition: C4Rect.h:101
void ClipByRect(const C4Rect &rClip)
Definition: C4Rect.cpp:173
void Clear()
Definition: C4Rect.h:105
void SetOutputSize(int32_t draw_x, int32_t draw_y, int32_t out_x, int32_t out_y, int32_t out_wdt, int32_t out_hgt)
Definition: C4Viewport.cpp:926
void SortViewportsByPlayerControl()
int32_t GetScreenHgt()
Definition: C4Gui.h:2825
int32_t GetScreenWdt()
Definition: C4Gui.h:2824

References C4RectList::AddRect(), Application, BackgroundAreas, C4UpperBoardHeight, C4RectList::Clear(), C4RectList::ClipByRect(), Config, FirstViewport, FullScreen, Game, C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), C4Config::Graphics, GraphicsSystem, C4Facet::Hgt, C4Rect::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, C4Facet::Wdt, C4Rect::Wdt, C4Facet::X, C4Rect::x, C4Facet::Y, and C4Rect::y.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SortViewportsByPlayerControl()

void C4ViewportList::SortViewportsByPlayerControl ( )

Definition at line 1368 of file C4Viewport.cpp.

1369 {
1370 
1371  // Sort
1372  bool is_sorted;
1373  C4Player *player_a, *player_b;
1374  C4Viewport *viewport, *next, *prev;
1375  do
1376  {
1377  is_sorted = true;
1378  for (prev = nullptr, viewport = FirstViewport; viewport && (next = viewport->Next); viewport=next)
1379  {
1380  // Get players
1381  player_a = ::Players.Get(viewport->Player);
1382  player_b = ::Players.Get(next->Player);
1383  // Swap order
1384  if (player_a && player_b && player_a->ControlSet && player_b->ControlSet && ( player_a->ControlSet->GetLayoutOrder() > player_b->ControlSet->GetLayoutOrder() ))
1385  {
1386  if (prev) prev->Next = next; else FirstViewport = next;
1387  viewport->Next = next->Next;
1388  next->Next = viewport;
1389  prev = next;
1390  next = viewport;
1391  is_sorted = false;
1392  }
1393  // Don't swap
1394  else
1395  {
1396  prev = viewport;
1397  }
1398  }
1399  }
1400  while (!is_sorted);
1401 
1402 }
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:90

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

Referenced by RecalculateViewports().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ViewportNextPlayer()

bool C4ViewportList::ViewportNextPlayer ( )

Definition at line 1404 of file C4Viewport.cpp.

1405 {
1406  // safety: switch valid?
1407  if ((!Game.C4S.Head.Film || !Game.C4S.Head.Replay) && !GetViewport(NO_OWNER))
1408  {
1409  return false;
1410  }
1411  // do switch then
1412  C4Viewport *viewport = GetFirstViewport();
1413  if (!viewport)
1414  {
1415  return false;
1416  }
1417  viewport->NextPlayer();
1418  return true;
1419 }
void NextPlayer()
Definition: C4Viewport.cpp:962

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

Referenced by C4Game::InitKeyboard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ViewportZoomIn()

bool C4ViewportList::ViewportZoomIn ( )

Definition at line 1457 of file C4Viewport.cpp.

1458 {
1459  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next) viewport->ChangeZoom(C4GFX_ZoomStep);
1460  return true;
1461 }
const float C4GFX_ZoomStep

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

Here is the caller graph for this function:

◆ ViewportZoomOut()

bool C4ViewportList::ViewportZoomOut ( )

Definition at line 1451 of file C4Viewport.cpp.

1452 {
1453  for (C4Viewport *viewport = FirstViewport; viewport; viewport = viewport->Next) viewport->ChangeZoom(1.0f/C4GFX_ZoomStep);
1454  return true;
1455 }

References C4GFX_ZoomStep, FirstViewport, and C4Viewport::Next.

Referenced by C4Game::InitKeyboard().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4GraphicsSystem

friend class C4GraphicsSystem
friend

Definition at line 177 of file C4Viewport.h.

◆ C4GUI::Screen

friend class C4GUI::Screen
friend

Definition at line 176 of file C4Viewport.h.

Member Data Documentation

◆ BackgroundAreas

C4RectList C4ViewportList::BackgroundAreas
protected

Definition at line 175 of file C4Viewport.h.

Referenced by DrawFullscreenBackground(), and RecalculateViewports().

◆ FirstViewport

◆ ViewportArea

C4Facet C4ViewportList::ViewportArea
protected

Definition at line 174 of file C4Viewport.h.

Referenced by C4ViewportList(), and RecalculateViewports().


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