OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MainMenu.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2008-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 // Engine internal C4Menus: Main menu, Options, Player join, Hostility, etc.
18 
19 #include "C4Include.h"
20 #include "gui/C4MainMenu.h"
21 
22 #include "game/C4Application.h"
23 #include "object/C4DefList.h"
24 #include "game/C4FullScreen.h"
25 #include "game/C4Viewport.h"
26 #include "player/C4Player.h"
27 #include "gui/C4GameOverDlg.h"
29 #include "game/C4Game.h"
30 #include "player/C4PlayerList.h"
31 #include "object/C4GameObjects.h"
32 #include "network/C4Network2.h"
33 #include "control/C4GameControl.h"
34 #include "object/C4Def.h"
35 
36 // -----------------------------------------------------------
37 // C4MainMenu
38 
39 C4MainMenu::C4MainMenu() : C4Menu() // will be re-adjusted later
40 {
41  Clear();
42 }
43 
45 {
48 }
49 
50 bool C4MainMenu::Init(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra, int32_t iExtraData, int32_t iId, int32_t iStyle)
51 {
52  if (!DoInit(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle)) return false;
53  Player=iPlayer;
54  return true;
55 }
56 
57 bool C4MainMenu::InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra, int32_t iExtraData, int32_t iId, int32_t iStyle)
58 {
59  if (!DoInitRefSym(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle)) return false;
60  Player=iPlayer;
61  return true;
62 }
63 
64 bool C4MainMenu::ActivateNewPlayer(int32_t iPlayer)
65 {
66  // league or replay game
67  if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false;
68  // Max player limit
69  if (::Players.GetCount() >= Game.Parameters.MaxPlayers) return false;
70 
71  // Menu symbol/init
72  if (GfxR->fctPlayerClr.Surface)
73  GfxR->fctPlayerClr.Surface->SetClr(0xff);
74  InitRefSym(GfxR->fctPlayerClr, LoadResStr("IDS_MENU_NOPLRFILES"), iPlayer);
75  for (DirectoryIterator iter(Config.General.UserDataPath); *iter; ++iter)
76  if (WildcardMatch("*.ocp", *iter))
77  {
78  char szFilename[_MAX_PATH+1], szCommand[_MAX_PATH+30+1];
79  SCopy(*iter, szFilename, _MAX_PATH);
80  if (DirectoryExists(szFilename)) continue;
81  if (::Players.FileInUse(szFilename)) continue;
82  // Open group
83  C4Group hGroup;
84  if (!hGroup.Open(szFilename)) continue;
85  // Load player info
86  C4PlayerInfoCore C4P;
87  if (!C4P.Load(hGroup)) { hGroup.Close(); continue; }
88  // Close group
89  hGroup.Close();
90  // Add player item
91  sprintf(szCommand, "JoinPlayer:%s", szFilename);
92  StdStrBuf sItemText;
93  sItemText.Format(LoadResStr("IDS_MENU_NEWPLAYER"), C4P.PrefName);
94  C4FacetSurface fctSymbol;
95  // Add menu item
96  Add(sItemText.getData(), fctSymbol, szCommand);
97  // Reset symbol facet (menu holds on to the surface)
98  fctSymbol.Default();
99  }
100 
101  // Alignment
103  // Go back to options menu on close
104  SetCloseCommand("ActivateMenu:Main");
105 
106  return true;
107 }
108 
109 bool C4MainMenu::DoRefillInternal(bool &rfRefilled)
110 {
111  // Variables
112  C4FacetSurface fctSymbol;
113  C4Player *pPlayer;
114  C4IDList ListItems;
115  C4Facet fctTarget;
116  bool fWasEmpty = !GetItemCount();
117 
118  // Refill
119  switch (Identification)
120  {
121  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122  case C4MN_Hostility:
123  {
124  // Clear items
125  ClearItems();
126  // Refill player
127  if (!(pPlayer = ::Players.Get(Player))) return false;
128  // Refill items
129  C4Player *pPlr; int32_t iIndex;
130  for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
131  // Ignore player self and invisible
132  if (pPlr != pPlayer) if (!pPlr->IsInvisible())
133  {
134  // Symbol
135  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
136  pPlayer->DrawHostility(fctSymbol,iIndex);
137  // Message
138  StdStrBuf sMsg;
139  bool isFriendly = pPlayer->Hostility.find(pPlr) == pPlayer->Hostility.end();
140  if (isFriendly)
141  sMsg.Format(LoadResStr("IDS_MENU_ATTACK"),pPlr->GetName());
142  else
143  sMsg.Format(LoadResStr("IDS_MENU_NOATTACK"),pPlr->GetName());
144  // Command
145  char szCommand[1000];
146  sprintf(szCommand,"SetHostility:%i",pPlr->Number);
147  // Info caption
148  char szInfoCaption[C4MaxTitle+1],szFriendly[50],szNot[30]="";
149  SCopy(LoadResStr(isFriendly ? "IDS_MENU_ATTACKHOSTILE" : "IDS_MENU_ATTACKFRIENDLY"),szFriendly);
150  if (!isFriendly) SCopy(LoadResStr("IDS_MENU_ATTACKNOT"),szNot);
151  sprintf(szInfoCaption,LoadResStr("IDS_MENU_ATTACKINFO"),pPlr->GetName(),szFriendly,szNot);
152  if (iIndex==pPlayer->Number) SCopy(LoadResStr("IDS_MENU_ATTACKSELF"),szInfoCaption);
153  // Add item
154  Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,nullptr,szInfoCaption);
155  fctSymbol.Default();
156  }
157  break;
158  }
159  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
160  case C4MN_TeamSelection:
161  case C4MN_TeamSwitch:
162  {
163  // Clear items
164  ClearItems();
165  // add all teams as menu items
166  // 2do: Icon
167  C4Team *pTeam; int32_t i=0; bool fAddNewTeam=Game.Teams.IsAutoGenerateTeams();
168  for (;;)
169  {
170  pTeam = Game.Teams.GetTeamByIndex(i);
171  if (pTeam)
172  {
173  // next regular team
174  ++i;
175  // do not add a new team if an empty team exists
176  if (!pTeam->GetPlayerCount()) fAddNewTeam = false;
177  }
178  else if (fAddNewTeam)
179  {
180  // join new team
181  fAddNewTeam = false;
182  }
183  else
184  {
185  // all teams done
186  break;
187  }
188  // create team symbol: Icon spec if specified; otherwise flag for empty and crew for nonempty team
189  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
190  const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : nullptr;
191  bool fHasIcon = false;
192  if (szIconSpec && *szIconSpec)
193  {
194  fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, nullptr, pTeam->GetColor());
195  }
196  if (!fHasIcon)
197  {
198  if (pTeam && pTeam->GetPlayerCount())
199  ::GraphicsResource.fctCrewClr.DrawClr(fctSymbol, true, pTeam->GetColor());
200  else
202  }
203  StdStrBuf sTeamName;
204  if (pTeam)
205  {
206  sTeamName.Take(pTeam->GetNameWithParticipants());
207  }
208  else
209  sTeamName.Ref(LoadResStr("IDS_PRC_NEWTEAM"));
210  const char *szOperation = (Identification == C4MN_TeamSwitch) ? "TeamSwitch" : "TeamSel";
211  Add(sTeamName.getData(), fctSymbol,FormatString("%s:%d", szOperation, pTeam ? pTeam->GetID() : TEAMID_New).getData(),
212  C4MN_Item_NoCount,nullptr,FormatString(LoadResStr("IDS_MSG_JOINTEAM"), sTeamName.getData()).getData(), C4ID(pTeam ? pTeam->GetID() : 0));
213  fctSymbol.Default();
214  }
215  break;
216  }
217  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
218  case C4MN_Observer: // observer menu
219  {
220  // Clear items
221  ClearItems();
222  // Check validity
224  if (!pVP) return false;
225  int32_t iInitialSelection = 0;
226  // Add free view
227  AddRefSym(LoadResStr("IDS_MSG_FREEVIEW"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Star), "Observe:Free", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MSG_FREELYSCROLLAROUNDTHEMAP"));
228  // Add players
229  C4Player *pPlr; int32_t iIndex;
230  for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
231  {
232  // Ignore invisible
233  if (!pPlr->IsInvisible())
234  {
235  // Symbol
236  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
237  ::GraphicsResource.fctPlayerClr.DrawClr(fctSymbol, true, pPlr->ColorDw);
238  // Message
239  StdStrBuf sMsg;
240  DWORD dwClr = pPlr->ColorDw;
241  sMsg.Format("<c %x>%s</c>", (unsigned int)C4GUI::MakeColorReadableOnBlack(dwClr), pPlr->GetName());
242  // Command
243  StdStrBuf sCommand;
244  sCommand.Format("Observe:%d", (int)pPlr->Number);
245  // Info caption
246  StdStrBuf sInfo;
247  sInfo.Format(LoadResStr("IDS_TEXT_FOLLOWVIEWOFPLAYER"), pPlr->GetName());
248  // Add item
249  Add(sMsg.getData(),fctSymbol,sCommand.getData(),C4MN_Item_NoCount,nullptr,sInfo.getData());
250  fctSymbol.Default();
251  // check if this is the currently selected player
252  if (pVP->GetPlayer() == pPlr->Number) iInitialSelection = GetItemCount()-1;
253  }
254  // Initial selection on followed player
255  if (fWasEmpty) SetSelection(iInitialSelection, false, true);
256  }
257  }
258  break;
259  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
260  default:
261  // No internal refill needed
262  return true;
263  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
264  }
265 
266  // Successfull internal refill
267  rfRefilled = true;
268  return true;
269 }
270 
271 void C4MainMenu::OnSelectionChanged(int32_t iNewSelection)
272 {
273  // immediate player highlight in observer menu
275  {
276  C4MenuItem *pItem = GetSelectedItem();
277  if (pItem)
278  {
279  if (SEqual2(pItem->GetCommand(), "Observe:"))
280  MenuCommand(pItem->GetCommand(), false);
281  }
282  }
283 }
284 
285 void C4MainMenu::OnUserSelectItem(int32_t Player, int32_t iIndex)
286 {
287  // direct selection for non-sync-menus
288  SetSelection(iIndex, true, true);
289 }
290 
291 void C4MainMenu::OnUserEnter(int32_t Player, int32_t iIndex, bool fRight)
292 {
293  // direct menu control
294  // but ensure selection is Okay before
295  SetSelection(iIndex, true, false);
296  Enter(fRight);
297 }
298 
300 {
301  // just close
302  TryClose(false, true);
303 }
304 
305 bool C4MainMenu::ActivateGoals(int32_t iPlayer, bool fDoActivate)
306 {
307  C4FacetSurface fctSymbol;
308  C4Facet fctGF; // goal fulfilled facet
309 
310  if (fDoActivate)
311  {
312  // Menu symbol/init
313  InitRefSym(GfxR->fctMenu.GetPhase(4),LoadResStr("IDS_MENU_CPGOALS"),iPlayer);
315  SetPermanent(false);
317  }
318  // determine if the goals are fulfilled - do the calls even if the menu is not to be opened to ensure synchronization
319  C4IDList GoalList, FulfilledGoalList;
320  C4RoundResults::EvaluateGoals(GoalList, FulfilledGoalList, iPlayer);
321  // Add Items
322  if (fDoActivate)
323  {
324  int32_t iNumGoals = GoalList.GetNumberOfIDs(), cnt;
325  C4ID idGoal; C4Def *pDef;
326  for (int32_t i=0; i<iNumGoals; ++i)
327  if ((idGoal = GoalList.GetID(i, &cnt)))
328  if ((pDef = C4Id2Def(idGoal)))
329  {
330  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
331  // 2do: If an object instance is known, draw the object instead?
332  // this would allow us to do dynamic pictures and overlays; e.g. draw the actual, required settlement score
333  // for settlement score goals
334  // Same for pDef->GetName(), pDef->GetDesc()
335  pDef->Draw(fctSymbol);
336  if (FulfilledGoalList.GetIDCount(idGoal))
337  {
338  fctGF.Surface=fctSymbol.Surface;
340  }
341  StdStrBuf Command; Command.Format("Player:Goal:%s", idGoal.ToString());
342  Add(pDef->GetName(),fctSymbol,Command.getData(),C4MN_Item_NoCount,nullptr,"");
343  }
344  // Go back to options menu on close
345  SetCloseCommand("ActivateMenu:Main");
346  }
347  // Done
348  return true;
349 }
350 
351 bool C4MainMenu::ActivateRules(int32_t iPlayer)
352 {
353  // Menu symbol/init
354  char Command[256];
355  C4FacetSurface fctSymbol;
356  InitRefSym(GfxR->fctMenu.GetPhase(5),LoadResStr("IDS_MENU_CPRULES"),iPlayer);
358  SetPermanent(false);
359  // Items
360  int32_t cnt; C4ID idGoal; C4Def *pDef;
361  for (cnt=0; (idGoal=::Objects.GetListID(C4D_Rule,cnt)); cnt++)
362  if ((pDef=C4Id2Def(idGoal)))
363  {
364  fctSymbol.Create(C4SymbolSize,C4SymbolSize); pDef->Draw(fctSymbol);
365  sprintf(Command, "Player:Rule:%s", idGoal.ToString());
366  Add(pDef->GetName(),fctSymbol,Command,C4MN_Item_NoCount,nullptr,"");
367  }
368  // Go back to options menu on close
369  SetCloseCommand("ActivateMenu:Main");
370  // Done
371  return true;
372 }
373 
374 bool LooksLikeInteger(const char *szInt)
375 {
376  // safety
377  if (!szInt) return false;
378  // check sign
379  if (*szInt == '+' || *szInt == '-') ++szInt;
380  // check int32_t length
381  if (!*szInt) return false;
382  // must contain only digits now
383  char c;
384  while ((c = *(szInt++))) if (!Inside<char>(c, '0', '9')) return false;
385  // it's an int32_t
386  return true;
387 }
388 
389 bool C4MainMenu::ActivateSavegame(int32_t iPlayer)
390 {
391  // Check if saving is possible
392  if (!Game.CanQuickSave()) return false;
393 
394  // Menu symbol/init
395  char DirPath[_MAX_PATH+1];
396  char ScenName[_MAX_PATH+1]; *ScenName=0;
397 
398  InitRefSym(GfxR->fctMenu.GetPhase(0), LoadResStr("IDS_MENU_CPSAVEGAME"), iPlayer);
400  SetPermanent(true);
401 
402  // target file name mask
403  // get folder & filename to store in
404  // some magic is needed to ensure savegames are stored properly into their folders
406  if (DirPath[strlen(DirPath) - 1] == '\\') DirPath[strlen(DirPath) - 1] = 0;
407  RemoveExtension(DirPath);
408  if (LooksLikeInteger(DirPath))
409  {
410  // ScenTitle.ocf\%d.ocs-names (old-style savegames)
411  // get owning folder
412  if (Game.pParentGroup)
413  {
414  // owning folder determines filename
416  }
417  else
418  {
419  // no owning folder known: too bad
420  // make a vague guess based on the scenario title
422  }
423  }
424  else
425  {
426  // DirPath is a valid filename for now...
427  SCopy(DirPath, ScenName);
428  // but remove trailing numbers to adjust new-style savegames
429  char *pScenNameEnd = ScenName+SLen(ScenName);
430  while (Inside<char>(*--pScenNameEnd, '0', '9'))
431  if (pScenNameEnd == ScenName)
432  {
433  // should not happen: digit-only-filenames should have been caught earlier
434  SCopy("dbg_error!", ScenName);
435  pScenNameEnd = ScenName+SLen(ScenName)-1;
436  }
437  pScenNameEnd[1]=0;
438  }
439 
440  // New Style 2007:
441  // * scenarios are saved into ScenName.ocf/ScenName123.ocs to keep umlauts out of filenames
442  // * language titles are stored in folders as title component
443  StdStrBuf strFilename, strTitle;
444  strFilename.Format("%s.ocf%c%s%%d.ocs", ScenName, DirectorySeparator, ScenName);
445  strTitle = Game.ScenarioTitle;
446 
447  // Create menu items
448  StdStrBuf strFilenameIndexed, strCommand, strCaption, strSavePath;
449  for (int32_t i = 1; i <= 10; i++)
450  {
451  // Index filename
452  strFilenameIndexed.Format(strFilename.getData(), i);
453  // Compose commmand
454  strCommand.Format("Save:Game:%s:%s", strFilenameIndexed.getData(), strTitle.getData()); // Notice: the language title might contain ':' and thus confuse the segment list - but C4Menu::MenuCommand will try to handle this...
455  // Check free slot
456  strSavePath.Format("%s%c%s", Config.AtUserDataPath(C4CFN_Savegames), DirectorySeparator, strFilenameIndexed.getData());
457  bool fFree = !C4Group_IsGroup(strSavePath.getData());
458  // Item caption
459  strCaption = LoadResStr("IDS_MENU_CPSAVEGAME");
460  // add menu item
461  AddRefSym(strCaption.getData(), GfxR->fctMenu.GetPhase(i - 1, fFree ? 2 : 1), strCommand.getData(), C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSAVEGAMEINFO"));
462  }
463 
464  // Go back to options menu on close
465  SetCloseCommand("ActivateMenu:Main");
466 
467  return true;
468 }
469 
470 bool C4MainMenu::ActivateHost(int32_t iPlayer)
471 {
472  // Menu symbol/init
475  SetPermanent(true);
476  // Clients
477  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
478  {
479  bool fHost = (pClient->getID() == 0);
480  StdStrBuf strText, strCommand;
481  strText.Format("%s (%s)", pClient->getName(), pClient->getCore().getNick());
482  strCommand.Format("Host:Kick:%d", pClient->getID());
483  C4GUI::Icons iIcon = fHost ? C4GUI::Ico_Host : (pClient->isActivated() ? C4GUI::Ico_Client : C4GUI::Ico_ObserverClient);
484  AddRefSym(strText.getData(), C4GUI::Icon::GetIconFacet(iIcon), strCommand.getData());
485  }
486  // Go back to options menu on close
487  SetCloseCommand("ActivateMenu:Main");
488  return true;
489 }
490 
491 bool C4MainMenu::ActivateClient(int32_t iPlayer)
492 {
493  // Menu symbol/init
494  C4FacetSurface fctSymbol;
495  InitRefSym(C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), LoadResStr("IDS_MENU_DISCONNECTFROMSERVER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
497  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
498  Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Part");
499  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
500  Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
501  SetCloseCommand("ActivateMenu:Main");
502  return true;
503 }
504 
505 bool C4MainMenu::ActivateSurrender(int32_t iPlayer)
506 {
507  C4FacetSurface fctSymbol;
510  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
511  Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Surrender");
512  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
513  Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
514  SetCloseCommand("ActivateMenu:Main");
515  return true;
516 }
517 
518 bool C4MainMenu::ActivateOptions(int32_t iPlayer, int32_t selection)
519 {
520  // Menu symbol/init
521  InitRefSym(GfxR->fctOptions.GetPhase(0), LoadResStr("IDS_MNU_OPTIONS"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
523  SetPermanent(true);
524  // Sound
525  AddRefSym(LoadResStr("IDS_DLG_SOUND"), GfxR->fctOptions.GetPhase(17 + Config.Sound.RXSound),"Options:Sound",C4MN_Item_NoCount);
526  // Music
527  AddRefSym(LoadResStr("IDS_MNU_MUSIC"), GfxR->fctOptions.GetPhase(1 + Config.Sound.RXMusic),"Options:Music",C4MN_Item_NoCount);
528  // Music
529  AddRefSym(LoadResStr("IDS_MENU_DISPLAY"), GfxR->fctMenu.GetPhase(8), "ActivateMenu:Display");
530  // Restore selection
531  SetSelection(selection, false, true);
532  // Go back to main menu on close
533  SetCloseCommand("ActivateMenu:Main");
534  // Done
535  return true;
536 }
537 
538 bool C4MainMenu::ActivateDisplay(int32_t iPlayer, int32_t selection)
539 {
540  // Menu symbol/init
541  InitRefSym(GfxR->fctMenu.GetPhase(8), LoadResStr("IDS_MENU_DISPLAY"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
543  SetPermanent(true);
544  // Crew player names
545  AddRefSym(LoadResStr("IDS_MNU_PLAYERNAMES"), GfxR->fctOptions.GetPhase(7 + Config.Graphics.ShowCrewNames), "Display:PlayerNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_PLAYERNAMES_DESC"));
546  // Crew clonk names
547  AddRefSym(LoadResStr("IDS_MNU_CLONKNAMES"), GfxR->fctOptions.GetPhase(9 + Config.Graphics.ShowCrewCNames), "Display:ClonkNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CLONKNAMES_DESC"));
548  // Upper Board
549  if (!Application.isEditor)
550  {
551  AddRefSym(LoadResStr("IDS_MNU_UPPERBOARD"),GfxR->fctOptions.GetPhase(3 + Config.Graphics.UpperBoard),"Display:UpperBoard",C4MN_Item_NoCount);
552  }
553  // FPS
554  if (!Application.isEditor)
555  AddRefSym(LoadResStr("IDS_MNU_FPS"), GfxR->fctOptions.GetPhase(5 + Config.General.FPS), "Display:FPS", C4MN_Item_NoCount);
556  // Clock
557  if (!Application.isEditor)
558  AddRefSym(LoadResStr("IDS_MNU_CLOCK"), GfxR->fctOptions.GetPhase(15 + Config.Graphics.ShowClock), "Display:Clock", C4MN_Item_NoCount);
559  // Restore selection
560  SetSelection(selection, false, true);
561  // Go back to options menu on close
562  SetCloseCommand("ActivateMenu:Options");
563  // Done
564  return true;
565 }
566 
567 bool C4MainMenu::ActivateMain(int32_t iPlayer)
568 {
569  // Determine player
570  C4Player *pPlr = ::Players.Get(iPlayer);
571  // Menu symbol/init
572  C4FacetSurface fctSymbol;
573  fctSymbol.Create(C4SymbolSize, C4SymbolSize);
574  GfxR->fctOKCancel.Draw(fctSymbol, true, 1, 1);
575  Init(fctSymbol, LoadResStr(pPlr ? "IDS_MENU_CPMAIN" : "IDS_MENU_OBSERVER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
577  // Goals+Rules (player menu only)
578  // Goal menu can't be shown because of script callbacks
579  // Rule menu could be shown, but rule activation would issue script callbacks and trigger client activation
580  // Showing rules but not showing goals would be strange anyway
581  if (pPlr)
582  {
583  // Goals
584  AddRefSym(LoadResStr("IDS_MENU_CPGOALS"),GfxR->fctMenu.GetPhase(4),"ActivateMenu:Goals",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPGOALSINFO"));
585  // Rules
586  AddRefSym(LoadResStr("IDS_MENU_CPRULES"),GfxR->fctMenu.GetPhase(5),"ActivateMenu:Rules",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPRULESINFO"));
587  }
588  // Observer menu in free viewport
589  if (!pPlr)
590  {
591  AddRefSym(LoadResStr("IDS_TEXT_VIEW"),C4GUI::Icon::GetIconFacet(C4GUI::Ico_View),"ActivateMenu:Observer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_TEXT_DETERMINEPLAYERVIEWTOFOLL"));
592  }
593  // Hostility (player menu only)
594  if (pPlr && (::Players.GetCount() > 1))
595  {
596  GfxR->fctFlagClr.Surface->SetClr(0xff0000);
597  AddRefSym(LoadResStr("IDS_MENU_CPATTACK"),GfxR->fctMenu.GetPhase(7),"ActivateMenu:Hostility",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPATTACKINFO"));
598  }
599  // Team change
600  if (pPlr && Game.Teams.IsTeamSwitchAllowed())
601  {
602  C4Facet fctTeams; fctTeams = C4GUI::Icon::GetIconFacet(C4GUI::Ico_Team);
603  AddRefSym(LoadResStr("IDS_MSG_SELTEAM"),fctTeams,"ActivateMenu:TeamSel",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MSG_ALLOWSYOUTOJOINADIFFERENT"));
604  }
605  // Player join
607  {
608  AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPNEWPLAYERINFO"));
609  }
610  // Save game (player menu only - should we allow saving games with no players in it?)
611  if (pPlr && (!::Network.isEnabled() || ::Network.isHost()))
612  {
613  AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPSAVEGAMEINFO"));
614  }
615  // Options
616  AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MNU_OPTIONSINFO"));
617  // Disconnect
618  if (::Network.isEnabled())
619  {
620  // Host
621  if (::Network.isHost() && Game.Clients.getClient(nullptr))
622  AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE"));
623  // Client
624  if (!::Network.isHost())
625  AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES"));
626  }
627  // Surrender (player menu only)
628  if (pPlr)
629  AddRefSym(LoadResStr("IDS_MENU_CPSURRENDER"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Surrender), "ActivateMenu:Surrender", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSURRENDERINFO"));
630  // Abort
631  if (!Application.isEditor)
632  AddRefSym(LoadResStr("IDS_MENU_ABORT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Exit), "Abort", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_ABORT_DESC"));
633  // No empty menus
634  if (GetItemCount()==0) Close(false);
635  // Done
636  return true;
637 }
638 
639 bool C4MainMenu::ActivateHostility(int32_t iPlayer)
640 {
641  // Init menu
642  C4FacetSurface fctSymbol;
643  fctSymbol.Create(C4SymbolSize, C4SymbolSize);
644  GfxR->fctMenu.GetPhase(7).Draw(fctSymbol);
645  Init(fctSymbol, LoadResStr("IDS_MENU_CPATTACK"), iPlayer, C4MN_Extra_None, 0, C4MN_Hostility);
647  SetPermanent(true);
648  Refill();
649  // Go back to options menu on close
650  SetCloseCommand("ActivateMenu:Main");
651  return true;
652 }
653 
654 bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
655 {
656  // Determine player
657  C4Player *pPlr = ::Players.Get(Player);
658  // Activate
659  if (SEqual2(szCommand,"ActivateMenu:"))
660  {
661  if (C4GameOverDlg::IsShown()) return false; // no new menus during game over dlg
662  if (SEqual(szCommand+13,"Main")) return ActivateMain(Player);
663  if (SEqual(szCommand+13,"Hostility")) return ActivateHostility(Player);
664  if (SEqual(szCommand+13,"NewPlayer")) return ActivateNewPlayer(Player);
665  if (SEqual(szCommand+13,"Goals"))
666  {
668  return true;
669  }
670  if (SEqual(szCommand+13,"Rules")) return ActivateRules(Player);
671  if (SEqual(szCommand+13,"Host")) return ActivateHost(Player);
672  if (SEqual(szCommand+13,"Client")) return ActivateClient(Player);
673  if (SEqual(szCommand+13,"Options")) return ActivateOptions(Player);
674  if (SEqual(szCommand+13,"Display")) return ActivateDisplay(Player);
675  if (SEqual(szCommand+13,"Save:Game")) return ActivateSavegame(Player);
676  if (SEqual(szCommand+13,"TeamSel")) return pPlr ? pPlr->ActivateMenuTeamSelection(true) : false;
677  if (SEqual(szCommand+13,"Surrender")) return ActivateSurrender(Player);
678  if (SEqual(szCommand+13,"Observer")) return ActivateObserver();
679  }
680  // JoinPlayer
681  if (SEqual2(szCommand,"JoinPlayer:"))
682  {
683  // not in league or replay mode
684  if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false;
685  // join player
686  // 2do: not for observers and such?
687  Players.JoinNew(szCommand+11);
688  return true;
689  }
690  // SetHostility
691  if (SEqual2(szCommand,"SetHostility:"))
692  {
693  // only if allowed
694  if (!Game.Teams.IsHostilityChangeAllowed()) return false;
695  int32_t iOpponent; sscanf(szCommand+13,"%i",&iOpponent);
696  C4Player *pOpponent = ::Players.Get(iOpponent);
697  if (!pOpponent || pOpponent->GetType() != C4PT_User) return false;
699  return true;
700  }
701  // Abort
702  if (SEqual2(szCommand,"Abort"))
703  {
705  return true;
706  }
707  // Surrender
708  if (SEqual2(szCommand,"Surrender"))
709  {
711  return true;
712  }
713  // Save game
714  if (SEqual2(szCommand, "Save:Game:"))
715  {
716  char strFilename[_MAX_PATH + 1]; SCopySegment(szCommand, 2, strFilename, ':', _MAX_PATH);
717  char strTitle[_MAX_PATH + 1]; SCopy(szCommand + SCharPos(':', szCommand, 2) + 1, strTitle, _MAX_PATH);
718  Game.QuickSave(strFilename, strTitle);
720  return true;
721  }
722  // Kick
723  if (SEqual2(szCommand,"Host:Kick:"))
724  {
725  int iClientID = atoi(szCommand+10);
726  if (iClientID && ::Network.isEnabled())
727  {
728  if (Game.Parameters.isLeague() && ::Players.GetAtClient(iClientID))
729  ::Network.Vote(VT_Kick, true, iClientID);
730  else
731  {
732  C4Client *pClient = Game.Clients.getClientByID(iClientID);
733  if (pClient) Game.Clients.CtrlRemove(pClient, LoadResStr("IDS_MSG_KICKBYMENU"));
734  Close(true);
735  }
736  }
737  return true;
738  }
739  // Part
740  if (SEqual2(szCommand,"Part"))
741  {
742  if (::Network.isEnabled())
743  {
745  ::Network.Vote(VT_Kick, true, ::Control.ClientID());
746  else
747  {
748  Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_GAMELEFTVIAPLAYERMENU"));
749  ::Network.Clear();
750  }
751  }
752  return true;
753  }
754  // Options
755  if (SEqual2(szCommand,"Options:"))
756  {
757  // Music
758  if (SEqual(szCommand + 8, "Music"))
759  {
761  }
762  // Sound
763  if (SEqual(szCommand + 8, "Sound"))
764  {
765  if (Config.Sound.RXSound)
766  {
768  Config.Sound.RXSound = false;
769  }
770  else
771  {
772  Config.Sound.RXSound = true;
774  { Log(LoadResStr("IDS_PRC_NOSND")); }
775  }
776  }
777  // Reopen with updated options
779  return true;
780  }
781  // Display
782  if (SEqual2(szCommand,"Display:"))
783  {
784  // Upper board
785  if (SEqual(szCommand + 8, "UpperBoard"))
786  {
789  }
790  // FPS
791  if (SEqual(szCommand + 8, "FPS")) Config.General.FPS = !Config.General.FPS;
792  // Player names
793  if (SEqual(szCommand + 8, "PlayerNames")) Config.Graphics.ShowCrewNames = !Config.Graphics.ShowCrewNames;
794  // Clonk names
795  if (SEqual(szCommand + 8, "ClonkNames")) Config.Graphics.ShowCrewCNames = !Config.Graphics.ShowCrewCNames;
796  // Clock
797  if (SEqual(szCommand + 8, "Clock")) Config.Graphics.ShowClock = !Config.Graphics.ShowClock;
798  // Reopen with updated options
800  return true;
801  }
802  // Goal info
803  if (SEqual2(szCommand,"Player:Goal:") || SEqual2(szCommand,"Player:Rule:"))
804  {
805  if (!ValidPlr(Player)) return false; // observers may not look at goal/rule info, because it requires queue activation
806  Close(true);
807  C4Object *pObj; C4ID idItem(szCommand+12); C4Def * pDef = C4Id2Def(idItem);
808  if (pDef && (pObj = ::Objects.Find(pDef)))
810  else
811  return false;
812  return true;
813  }
814  // Team selection
815  if (SEqual2(szCommand, "TeamSel:"))
816  {
817  Close(true);
818  int32_t idTeam = atoi(szCommand+8);
819 
820  // OK, join this team
821  if (pPlr) pPlr->DoTeamSelection(idTeam);
822  return true;
823  }
824  // Team switch
825  if (SEqual2(szCommand, "TeamSwitch:"))
826  {
827  Close(true);
828  int32_t idTeam = atoi(szCommand+11);
829 
830  // check if it's still allowed
831  if (!Game.Teams.IsTeamSwitchAllowed()) return false;
832  // OK, join this team
834  return true;
835  }
836  // Observe
837  if (SEqual2(szCommand, "Observe:"))
838  {
839  const char *szObserverTarget = szCommand+8;
841  if (pVP) // viewport may have closed meanwhile
842  {
843  if (SEqual(szObserverTarget, "Free"))
844  {
845  // free view
846  pVP->Init(NO_OWNER, true);
847  return true;
848  }
849  else
850  {
851  // view following player
852  int32_t iPlr = atoi(szObserverTarget);
853  if (ValidPlr(iPlr))
854  {
855  pVP->Init(iPlr, true);
856  return true;
857  }
858  }
859  }
860  return false;
861  }
862  // No valid command
863  return false;
864 }
865 
866 bool C4MainMenu::ActivateCommand(int32_t iPlayer, const char *szCommand)
867 {
868  // init menu for player and activate with command
869  Player = iPlayer;
870  return MenuCommand(szCommand, false);
871 }
872 
874 {
875  // Safety: Viewport lost?
876  if (!::Viewports.GetViewport(NO_OWNER)) return false;
877  // Menu symbol/init
880  // Players added in Refill
881  Refill();
882  // Go back to main menu on close
883  SetCloseCommand("ActivateMenu:Main");
884  return true;
885 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
const char * getData() const
Definition: StdBuf.h:450
C4SoundSystem SoundSystem
Definition: C4Application.h:42
int32_t GetPlayerCount() const
Definition: C4Teams.h:64
C4Group * pParentGroup
Definition: C4Game.h:90
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
Definition: stub-handle.cpp:67
bool fHost
Definition: TstC4NetIO.cpp:34
bool FileInUse(const char *szFilename) const
const char * GetIconSpec() const
Definition: C4Teams.h:71
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
int32_t GetID() const
Definition: C4Teams.h:66
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
virtual void OnSelectionChanged(int32_t iNewSelection)
Definition: C4MainMenu.cpp:271
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
C4Config Config
Definition: C4Config.cpp:831
bool ActivateNewPlayer(int32_t iPlayer)
Definition: C4MainMenu.cpp:64
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const size_t C4MaxTitle
Definition: C4Constants.h:25
virtual const char * GetName() const
Definition: C4PropList.cpp:267
bool Refill()
Definition: C4Menu.cpp:918
#define GfxR
bool isHost() const
Definition: C4Network2.h:209
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
static C4ControlPlayerAction * ActivateGoalMenu(const C4Player *source)
Definition: C4Control.cpp:590
virtual bool DoRefillInternal(bool &rfRefilled)
Definition: C4MainMenu.cpp:109
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
int32_t FPS
Definition: C4Config.h:47
C4Scenario C4S
Definition: C4Game.h:76
C4ConfigGeneral General
Definition: C4Config.h:252
#define sprintf
Definition: Standard.h:171
Definition: C4Teams.h:30
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
virtual void OnUserEnter(int32_t Player, int32_t iIndex, bool fRight)
Definition: C4MainMenu.cpp:291
void RecalculateViewports()
Definition: C4Viewport.cpp:992
void EvaluateNetwork(NetResult eResult, const char *szResultsString)
bool IsInvisible() const
Definition: C4Player.cpp:1737
uint32_t GetColor() const
Definition: C4Teams.h:70
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:243
bool Replay
Definition: C4Scenario.h:72
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
virtual bool MenuCommand(const char *szCommand, bool fIsCloseCommand)
Definition: C4MainMenu.cpp:654
StdStrBuf GetNameWithParticipants() const
Definition: C4Teams.cpp:210
int32_t RXSound
Definition: C4Config.h:127
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
void Close(bool fOK)
int32_t ShowCrewNames
Definition: C4Config.h:108
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0)
Definition: C4Facet.cpp:213
void Vote(C4ControlVoteType eType, bool fApprove=true, int32_t iData=0)
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)
Definition: C4Gui.cpp:99
virtual void Default()
Definition: C4MainMenu.cpp:44
Definition: C4Menu.h:122
static void EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalList, int32_t iPlayerNumber)
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
static C4ControlPlayerAction * SetHostility(const C4Player *source, const C4Player *target, bool hostile)
Definition: C4Control.cpp:597
bool ActivateObserver()
Definition: C4MainMenu.cpp:873
#define _MAX_PATH
int GetCount() const
const char * GetFilenameOnly(const char *strFilename)
Definition: StdFile.cpp:70
size_t SLen(const char *sptr)
Definition: Standard.h:78
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
void DrawHostility(C4Facet &cgo, int32_t iIndex)
Definition: C4Player.cpp:999
C4GraphicsResource GraphicsResource
void CtrlRemove(const C4Client *pClient, const char *szReason)
Definition: C4Client.cpp:350
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
C4GameParameters & Parameters
Definition: C4Game.h:69
bool ActivateCommand(int32_t iPlayer, const char *szCommand)
Definition: C4MainMenu.cpp:866
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:50
C4Player * GetAtClient(int iClient, int iIndex=0) const
C4TeamList & Teams
Definition: C4Game.h:72
bool ActivateMenuTeamSelection(bool fFromMain)
Definition: C4Player.cpp:1242
bool ActivateRules(int32_t iPlayer)
Definition: C4MainMenu.cpp:351
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t UpperBoard
Definition: C4Config.h:102
void Default()
Definition: C4FacetEx.h:43
uint32_t ColorDw
Definition: C4Player.h:91
C4ConfigGraphics Graphics
Definition: C4Config.h:254
C4Player * Get(int iPlayer) const
static C4ControlPlayerAction * SetTeam(const C4Player *source, int32_t team)
Definition: C4Control.cpp:607
bool LooksLikeInteger(const char *szInt)
Definition: C4MainMenu.cpp:374
bool IsTeamSwitchAllowed() const
Definition: C4Teams.h:166
C4Network2 Network
Definition: C4Globals.cpp:53
void JoinNew(const char *szFilename)
int32_t ShowCrewCNames
Definition: C4Config.h:109
C4Player * GetByIndex(int iIndex) const
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:81
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:55
bool ActivateSavegame(int32_t iPlayer)
Definition: C4MainMenu.cpp:389
bool ActivateDisplay(int32_t iPlayer, int32_t selection=0)
Definition: C4MainMenu.cpp:538
int32_t Player
Definition: C4MainMenu.h:41
const char * GetName() const
Definition: C4Group.cpp:1845
bool ActivateHost(int32_t iPlayer)
Definition: C4MainMenu.cpp:470
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
void ClearItems()
Definition: C4Menu.cpp:898
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
bool QuickSave(const char *strFilename, const char *strTitle, bool fForceSave=false)
Definition: C4Game.cpp:1943
bool ActivateHostility(int32_t iPlayer)
Definition: C4MainMenu.cpp:639
void Take(char *pnData)
Definition: StdBuf.h:465
static bool IsShown()
Definition: C4GameOverDlg.h:92
C4Team * GetTeamByIndex(int32_t iIndex) const
Definition: C4Teams.cpp:405
C4PlayerList Players
bool DoInit(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4Menu.cpp:301
bool HostilityDeclared(int iPlayer1, int iPlayer2) const
int32_t GetItemCount()
Definition: C4Menu.cpp:520
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
C4Player * GetLocalByIndex(int iIndex) const
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:601
bool C4Group_IsGroup(const char *szFilename)
Definition: C4Group.cpp:94
Definition: C4Def.h:100
const int NO_OWNER
Definition: C4Constants.h:138
bool Close()
Definition: C4Group.cpp:755
void Clear()
Definition: C4Network2.cpp:734
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
bool CanQuickSave()
Definition: C4Game.cpp:1934
int32_t GetSelection()
Definition: C4Menu.cpp:602
const int32_t C4D_Rule
Definition: C4Def.h:49
bool isEnabled() const
Definition: C4Network2.h:203
Definition: C4Id.h:28
C4RoundResults & RoundResults
Definition: C4Game.h:75
const int32_t TEAMID_New
Definition: C4Teams.h:27
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:316
virtual void Default()
Definition: C4Menu.cpp:247
Icons
Definition: C4Gui.h:637
bool ActivateOptions(int32_t iPlayer, int32_t selection=0)
Definition: C4MainMenu.cpp:518
void DoTeamSelection(int32_t idTeam)
Definition: C4Player.cpp:1254
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
bool DoInitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4Menu.cpp:308
bool ActivateGoals(int32_t iPlayer, bool fDoActivate)
Definition: C4MainMenu.cpp:305
virtual void OnUserClose()
Definition: C4MainMenu.cpp:299
void Ref(const char *pnData)
Definition: StdBuf.h:463
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:694
C4ID GetListID(int32_t dwCategory, int Index) const
C4Network2ClientList Clients
Definition: C4Network2.h:116
bool Init(int32_t iPlayer, bool fSetTempOnly)
Definition: C4Viewport.cpp:658
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
bool ShowAbortDlg()
const char * GetName() const
Definition: C4Player.h:153
C4Object * Find(C4Def *def, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All)
bool Control(BYTE byCom, int32_t iData)
Definition: C4Menu.cpp:423
C4Client * getClientByID(int32_t iID) const
Definition: C4Client.cpp:217
const int C4SymbolSize
Definition: C4Constants.h:58
bool ActivateClient(int32_t iPlayer)
Definition: C4MainMenu.cpp:491
float Hgt
Definition: C4Facet.h:120
const char * ToString() const
Definition: C4Id.h:62
int32_t GetPlayer()
Definition: C4Viewport.h:67
int32_t ValidPlr(int32_t plr)
static C4ControlPlayerAction * Surrender(const C4Player *source)
Definition: C4Control.cpp:567
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:524
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:384
bool Enter(bool fRight=false)
Definition: C4Menu.cpp:488
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:168
C4ClientList & Clients
Definition: C4Game.h:71
static C4ControlPlayerAction * ActivateGoal(const C4Player *source, const C4Object *target)
Definition: C4Control.cpp:581
void Clear()
Definition: C4Menu.cpp:272
bool isLeague() const
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
virtual void OnUserSelectItem(int32_t Player, int32_t iIndex)
Definition: C4MainMenu.cpp:285
bool ActivateSurrender(int32_t iPlayer)
Definition: C4MainMenu.cpp:505
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:203
C4SHead Head
Definition: C4Scenario.h:230
C4Surface * Surface
Definition: C4Facet.h:119
#define C4CFN_Savegames
Definition: C4Components.h:35
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
const char * GetCommand() const
Definition: C4Menu.h:113
uint32_t DWORD
C4ConfigSound Sound
Definition: C4Config.h:255
C4Client * getClient(const C4Client *pAfter=nullptr) const
Definition: C4Client.h:160
#define DirectorySeparator
int32_t GetNumberOfIDs() const
Definition: C4IDList.cpp:197
float Wdt
Definition: C4Facet.h:120
bool IsHostilityChangeAllowed() const
Definition: C4Teams.h:165
C4Application Application
Definition: C4Globals.cpp:44
static C4Facet GetIconFacet(Icons icoIconIndex)
bool ActivateMain(int32_t iPlayer)
Definition: C4MainMenu.cpp:567
int32_t ShowClock
Definition: C4Config.h:103
int32_t Identification
Definition: C4Menu.h:141
C4GameObjects Objects
Definition: C4Globals.cpp:48
bool DrawTextSpecImage(C4Facet &fctTarget, const char *szSpec, class C4DrawTransform *pTransform, uint32_t dwClr=0xff)
Definition: C4Game.cpp:3741
int32_t RXMusic
Definition: C4Config.h:128
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277
HostilitySet Hostility
Definition: C4Player.h:120
C4PlayerType GetType() const
Definition: C4Player.cpp:1730
C4MusicSystem MusicSystem
Definition: C4Application.h:41