51 if (!
DoInit(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle))
return false;
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)
58 if (!
DoInitRefSym(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle))
return false;
71 if (
GfxR->fctPlayerClr.Surface)
72 GfxR->fctPlayerClr.Surface->SetClr(0xff);
83 if (!hGroup.
Open(szFilename))
continue;
86 if (!C4P.
Load(hGroup)) { hGroup.
Close();
continue; }
90 sprintf(szCommand,
"JoinPlayer:%s", szFilename);
95 Add(sItemText.
getData(), fctSymbol, szCommand);
144 char szCommand[1000];
147 char szInfoCaption[
C4MaxTitle+1],szFriendly[50],szNot[30]=
"";
148 SCopy(
LoadResStr(isFriendly ?
"IDS_MENU_ATTACKHOSTILE" :
"IDS_MENU_ATTACKFRIENDLY"),szFriendly);
177 else if (fAddNewTeam)
189 const char *szIconSpec = pTeam ? pTeam->
GetIconSpec() :
nullptr;
190 bool fHasIcon =
false;
191 if (szIconSpec && *szIconSpec)
223 if (!pVP)
return false;
224 int32_t iInitialSelection = 0;
254 if (fWasEmpty)
SetSelection(iInitialSelection,
false,
true);
318 C4IDList GoalList, FulfilledGoalList;
325 for (int32_t i=0; i<iNumGoals; ++i)
326 if ((idGoal = GoalList.
GetID(i, &cnt)))
334 pDef->
Draw(fctSymbol);
376 if (!szInt)
return false;
378 if (*szInt ==
'+' || *szInt ==
'-') ++szInt;
380 if (!*szInt)
return false;
383 while ((c = *(szInt++)))
if (!Inside<char>(c,
'0',
'9'))
return false;
405 if (DirPath[strlen(DirPath) - 1] ==
'\\') DirPath[strlen(DirPath) - 1] = 0;
426 SCopy(DirPath, ScenName);
428 char *pScenNameEnd = ScenName+
SLen(ScenName);
429 while (Inside<char>(*--pScenNameEnd,
'0',
'9'))
430 if (pScenNameEnd == ScenName)
433 SCopy(
"dbg_error!", ScenName);
434 pScenNameEnd = ScenName+
SLen(ScenName)-1;
447 StdStrBuf strFilenameIndexed, strCommand, strCaption, strSavePath;
448 for (int32_t i = 1; i <= 10; i++)
458 strCaption =
LoadResStr(
"IDS_MENU_CPSAVEGAME");
478 bool fHost = (pClient->getID() == 0);
480 strText.
Format(
"%s (%s)", pClient->getName(), pClient->getCore().getNick());
481 strCommand.
Format(
"Host:Kick:%d", pClient->getID());
573 GfxR->fctOKCancel.Draw(fctSymbol,
true, 1, 1);
595 GfxR->fctFlagClr.Surface->SetClr(0xff0000);
643 GfxR->fctMenu.GetPhase(7).Draw(fctSymbol);
658 if (
SEqual2(szCommand,
"ActivateMenu:"))
664 if (
SEqual(szCommand+13,
"Goals"))
680 if (
SEqual2(szCommand,
"JoinPlayer:"))
690 if (
SEqual2(szCommand,
"SetHostility:"))
694 int32_t iOpponent; sscanf(szCommand+13,
"%i",&iOpponent);
701 if (
SEqual2(szCommand,
"Abort"))
707 if (
SEqual2(szCommand,
"Surrender"))
713 if (
SEqual2(szCommand,
"Save:Game:"))
722 if (
SEqual2(szCommand,
"Host:Kick:"))
724 int iClientID = atoi(szCommand+10);
754 if (
SEqual2(szCommand,
"Options:"))
757 if (
SEqual(szCommand + 8,
"Music"))
762 if (
SEqual(szCommand + 8,
"Sound"))
781 if (
SEqual2(szCommand,
"Display:"))
784 if (
SEqual(szCommand + 8,
"UpperBoard"))
802 if (
SEqual2(szCommand,
"Player:Goal:") ||
SEqual2(szCommand,
"Player:Rule:"))
814 if (
SEqual2(szCommand,
"TeamSel:"))
817 int32_t idTeam = atoi(szCommand+8);
824 if (
SEqual2(szCommand,
"TeamSwitch:"))
827 int32_t idTeam = atoi(szCommand+11);
836 if (
SEqual2(szCommand,
"Observe:"))
838 const char *szObserverTarget = szCommand+8;
842 if (
SEqual(szObserverTarget,
"Free"))
851 int32_t iPlr = atoi(szObserverTarget);
854 pVP->
Init(iPlr,
true);
C4Def * C4Id2Def(C4ID id)
C4Application Application
C4GraphicsResource GraphicsResource
bool C4Group_IsGroup(const char *filename)
const char * LoadResStr(const char *id)
bool Log(const char *szMessage)
bool LooksLikeInteger(const char *szInt)
int32_t ValidPlr(int32_t plr)
int SCharPos(char cTarget, const char *szInStr, int iIndex)
bool SEqual2(const char *szStr1, const char *szStr2)
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
bool SEqual(const char *szStr1, const char *szStr2)
size_t SLen(const char *sptr)
StdStrBuf FormatString(const char *szFmt,...)
bool DirectoryExists(const char *szFilename)
bool WildcardMatch(const char *szWildcard, const char *szString)
const char * GetFilenameOnly(const char *strFilename)
char * GetFilename(char *szPath)
void RemoveExtension(char *szFilename)
C4MusicSystem MusicSystem
C4SoundSystem SoundSystem
C4Client * getClient(const C4Client *pAfter=nullptr) const
C4Client * getClientByID(int32_t iID) const
void CtrlRemove(const C4Client *pClient, const char *szReason)
char UserDataPath[CFG_MaxString+1]
const char * AtUserDataPath(const char *filename)
C4ConfigGraphics Graphics
static C4ControlPlayerAction * SetHostility(const C4Player *source, const C4Player *target, bool hostile)
static C4ControlPlayerAction * ActivateGoal(const C4Player *source, const C4Object *target)
static C4ControlPlayerAction * SetTeam(const C4Player *source, int32_t team)
static C4ControlPlayerAction * ActivateGoalMenu(const C4Player *source)
static C4ControlPlayerAction * Surrender(const C4Player *source)
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)
void Set(C4Surface &rSfc)
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0)
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
static C4Facet GetIconFacet(Icons icoIconIndex)
C4RoundResults & RoundResults
bool QuickSave(const char *filename, const char *title, bool force_save=false)
char ScenarioFilename[_MAX_PATH_LEN]
bool DrawTextSpecImage(C4Facet &target, const char *spec, class C4DrawTransform *transform, uint32_t color=0xff)
C4GameParameters & Parameters
StdCopyStrBuf ScenarioTitle
const char * GetName() const
bool Open(const char *group_name, bool do_create=false)
const char * ToString() const
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
int32_t GetNumberOfIDs() const
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
bool ActivateDisplay(int32_t iPlayer, int32_t selection=0)
bool ActivateHost(int32_t iPlayer)
void OnUserClose() override
bool DoRefillInternal(bool &rfRefilled) override
void OnUserEnter(int32_t Player, int32_t iIndex, bool fRight) override
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)
bool ActivateHostility(int32_t iPlayer)
bool ActivateMain(int32_t iPlayer)
bool ActivateOptions(int32_t iPlayer, int32_t selection=0)
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)
bool ActivateClient(int32_t iPlayer)
bool ActivateNewPlayer(int32_t iPlayer)
void OnSelectionChanged(int32_t iNewSelection) override
bool ActivateCommand(int32_t iPlayer, const char *szCommand)
bool ActivateGoals(int32_t iPlayer, bool fDoActivate)
bool ActivateRules(int32_t iPlayer)
bool MenuCommand(const char *szCommand, bool fIsCloseCommand) override
void OnUserSelectItem(int32_t Player, int32_t iIndex) override
bool ActivateSavegame(int32_t iPlayer)
bool ActivateSurrender(int32_t iPlayer)
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void Vote(C4ControlVoteType eType, bool fApprove=true, int32_t iData=0)
C4Network2ClientList Clients
C4ID GetListID(int32_t dwCategory, int index) const
C4Object * Find(C4Def *def, int owner=ANY_OWNER, DWORD dwOCF=OCF_All)
void DoTeamSelection(int32_t idTeam)
const char * GetName() const
C4PlayerType GetType() const
void DrawHostility(C4Facet &cgo, int32_t iIndex)
bool ActivateMenuTeamSelection(bool fFromMain)
bool Load(C4Group &hGroup)
char PrefName[C4MaxName+1]
C4Player * GetAtClient(int iClient, int iIndex=0) const
C4Player * GetByIndex(int iIndex) const
C4Player * Get(int iPlayer) const
bool FileInUse(const char *szFilename) const
void JoinNew(const char *szFilename)
C4Player * GetLocalByIndex(int iIndex) const
bool HostilityDeclared(int iPlayer1, int iPlayer2) const
const char * GetName() const override
void EvaluateNetwork(NetResult eResult, const char *szResultsString)
static void EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalList, int32_t iPlayerNumber)
StdStrBuf GetNameWithParticipants() const
uint32_t GetColor() const
const char * GetIconSpec() const
int32_t GetPlayerCount() const
C4Team * GetTeamByIndex(int32_t iIndex) const
bool IsHostilityChangeAllowed() const
bool IsAutoGenerateTeams() const
bool IsTeamSwitchAllowed() const
bool Init(int32_t for_player, bool set_temporary_only)
void RecalculateViewports()
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)
void Ref(const char *pnData)
const char * getData() const
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)