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