Esempio n. 1
0
C4StartupAboutDlg::C4StartupAboutDlg() : C4StartupDlg(LoadResStr("IDS_DLG_ABOUT"))
{
	// ctor
	UpdateSize();

	CStdFont &rUseFont = ::GraphicsResource.TextFont;
	C4Rect rcClient = GetContainedClientRect();

	// bottom line buttons and copyright messages
	C4GUI::ComponentAligner caMain(rcClient, 0,0, true);
	C4GUI::ComponentAligner caButtons(caMain.GetFromBottom(caMain.GetHeight()*1/8), 0,0, false);
	C4GUI::CallbackButton<C4StartupAboutDlg> *btn;
#if AUDIO_TK == AUDIO_TK_FMOD
	AddElement(new C4GUI::Label("Using FMOD Sound System, copyright (c) Firelight Technologies Pty, Ltd., 1994-2010.",
		caMain.GetFromBottom(rUseFont.GetLineHeight())));
#endif
	int32_t iButtonWidth = caButtons.GetInnerWidth() / 4;
	AddElement(btn = new C4GUI::CallbackButton<C4StartupAboutDlg>(LoadResStr("IDS_BTN_BACK"), caButtons.GetGridCell(0,3,0,1,iButtonWidth,C4GUI_ButtonHgt,true), &C4StartupAboutDlg::OnBackBtn));
	btn->SetToolTip(LoadResStr("IDS_DLGTIP_BACKMAIN"));
#ifdef WITH_AUTOMATIC_UPDATE
	AddElement(btn = new C4GUI::CallbackButton<C4StartupAboutDlg>(LoadResStr("IDS_BTN_CHECKFORUPDATES"), caButtons.GetGridCell(2,3,0,1,iButtonWidth,C4GUI_ButtonHgt,true), &C4StartupAboutDlg::OnUpdateBtn));
	btn->SetToolTip(LoadResStr("IDS_DESC_CHECKONLINEFORNEWVERSIONS"));
#endif

	AddElement(new C4GUI::Label("'Clonk' is a registered trademark of Matthes Bender.",
		caButtons.GetFromBottom(rUseFont.GetLineHeight())));
}
Esempio n. 2
0
void C4StartupNetListEntry::SetRefQuery(const char *szAddress, enum QueryType eQueryType)
{
	// safety: clear previous
	ClearRef();
	// setup layout
	const_cast<C4Facet &>(reinterpret_cast<const C4Facet &>(pIcon->GetFacet()))
	  = (const C4Facet &) C4Startup::Get()->Graphics.fctNetGetRef;
	pIcon->SetAnimated(true, 1);
	pIcon->SetBounds(rctIconLarge);
	// init a new ref client to query
	sRefClientAddress.Copy(szAddress);
	this->eQueryType = eQueryType;
	pRefClient = new C4Network2RefClient();
	if (!pRefClient->Init() || !pRefClient->SetServer(szAddress))
	{
		// should not happen
		sInfoText[0].Clear();
		SetError(pRefClient->GetError(), TT_RefReqWait);
		return;
	}
	// set info
	sInfoText[0].Format(LoadResStr("IDS_NET_CLIENTONNET"), GetQueryTypeName(eQueryType), pRefClient->getServerName());
	sInfoText[1].Copy(LoadResStr("IDS_NET_INFOQUERY"));
	UpdateSmallState(); UpdateText();
	pRefClient->SetNotify(&Application.InteractiveThread);
	// masterserver: always on top
	if (eQueryType == NRQT_Masterserver)
		iSortOrder = 100;
	// register proc
	C4InteractiveThread &Thread = Application.InteractiveThread;
	Thread.AddProc(pRefClient);
	// start querying!
	QueryReferences();
}
Esempio n. 3
0
void C4StartupNetDlg::DoRefresh()
{
	// check min refresh timer
	time_t tNow = time(nullptr);
	if (tLastRefresh && tNow < tLastRefresh + C4NetMinRefreshInterval)
	{
		// avoid hammering on refresh key
		C4GUI::GUISound("UI::Error");
		return;
	}
	tLastRefresh = tNow;
	// empty list of all old entries
	fUpdatingList = true;
	while (pGameSelList->GetFirst()) delete pGameSelList->GetFirst();
	pMasterserverClient=nullptr;
	// (Re-)Start discovery
	if (!DiscoverClient.StartDiscovery())
	{
		StdCopyStrBuf strNoDiscovery(LoadResStr("IDS_NET_NODISCOVERY"));
		::pGUI->ShowMessageModal(
		  FormatString(LoadResStr("IDS_NET_NODISCOVERY_DESC"), DiscoverClient.GetError()).getData(),
		  strNoDiscovery.getData(),
		  C4GUI::MessageDialog::btnAbort,
		  C4GUI::Ico_Error);
	}
	iGameDiscoverInterval = C4NetGameDiscoveryInterval;
	// restart masterserver query
	UpdateMasterserver();
	// done; update stuff
	fUpdatingList = false;
	UpdateList();
}
Esempio n. 4
0
C4AbortGameDialog::C4AbortGameDialog()
    : fGameHalted(false),
      C4GUI::ConfirmationDialog(
          LoadResStr("IDS_HOLD_ABORT"), LoadResStr("IDS_DLG_ABORT"), NULL,
          MessageDialog::btnYesNo, true, C4GUI::Ico_Exit) {
  is_shown = true;  // assume dlg will be shown, soon
}
void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite)
{
	// get associated resource
	C4Network2Res::Ref pRes = GetRefRes();
	if (!pRes) return;
	const char *szResFile = pRes->getFile();
	StdCopyStrBuf strErrCopyFile(LoadResStr("IDS_NET_ERR_COPYFILE"));
	if (!pRes->isTempFile())
	{
		GetScreen()->ShowMessage(LoadResStr("IDS_NET_ERR_COPYFILE_LOCAL"), strErrCopyFile.getData(), C4GUI::Ico_Error);
		return;
	}
	const char *szFilename = GetFilename(pRes->getCore().getFileName());
	/*  const char *szSpecialPath = "";
	  if (WildcardMatch(C4CFN_PlayerFiles, szFilename))
	    // write players to player path
	    szSpecialPath = Config.General.PlayerPath;
	*/
	const char *szTarget = Config.AtUserDataPath(szFilename);
	if (!fDoOverwrite && ItemExists(szTarget))
	{
		// show a confirmation dlg, asking whether the resource should be overwritten
		GetScreen()->ShowRemoveDlg(new C4GUI::ConfirmationDialog(
		                             FormatString(LoadResStr("IDS_NET_RES_SAVE_OVERWRITE"), GetFilename(szTarget)).getData(), LoadResStr("IDS_NET_RES_SAVE"),
		                             new C4GUI::CallbackHandler<C4Network2ResDlg::ListItem>(this, &C4Network2ResDlg::ListItem::OnButtonSaveConfirm), C4GUI::MessageDialog::btnYesNo));
		return;
	}
	if (!C4Group_CopyItem(szResFile, szTarget))
		GetScreen()->ShowMessage(strErrCopyFile.getData(), strErrCopyFile.getData(), C4GUI::Ico_Error);
	else
	{
		GetScreen()->ShowMessage(FormatString(LoadResStr("IDS_NET_RES_SAVED_DESC"), GetFilename(szTarget)).getData(),
		                         LoadResStr("IDS_NET_RES_SAVED"), C4GUI::Ico_Save);
	}
}
Esempio n. 6
0
void C4StartupMainDlg::UpdateParticipants() {
  // First validate all participants (files must exist)
  StdStrBuf strPlayers, strPlayer;
  strPlayer.SetLength(1024 + 1);
  strPlayers.Copy(Config.General.Participants);
  *Config.General.Participants = 0;
  for (int i = 0; SCopySegment(strPlayers.getData(), i, strPlayer.getMData(),
                               ';', 1024, true);
       i++) {
    const char *szPlayer = strPlayer.getData();
    if (!szPlayer || !*szPlayer) continue;
    if (!FileExists(szPlayer)) continue;
    if (!SEqualNoCase(GetExtension(szPlayer), "c4p"))
      continue;  // additional sanity check to clear strange exe-path-only
                 // entries in player list?
    SAddModule(Config.General.Participants, szPlayer);
  }
  // Draw selected players - we are currently displaying the players stored in
  // Config.General.Participants.
  // Existence of the player files is not validated and player filenames are
  // displayed directly
  // (names are not loaded from the player core).
  strPlayers.Format(LoadResStr("IDS_DESC_PLRS"));
  if (!Config.General.Participants[0])
    strPlayers.Append(LoadResStr("IDS_DLG_NOPLAYERSSELECTED"));
  else
    for (int i = 0; SCopySegment(Config.General.Participants, i,
                                 strPlayer.getMData(), ';', 1024, true);
         i++) {
      if (i > 0) strPlayers.Append(", ");
      strPlayers.Append(C4Language::IconvClonk(
                            GetFilenameOnly(strPlayer.getData())).getData());
    }
  pParticipantsLbl->SetText(strPlayers.getData());
}
Esempio n. 7
0
BOOL SellFromBase(int32_t iPlr, C4Object *pBaseObj, C4ID id, C4Object *pSellObj)
  {
  C4Object *pThing;
  // Valid checks
  if (!ValidPlr(iPlr)) return FALSE;
  if (!pBaseObj || !ValidPlr(pBaseObj->Base)) return FALSE;
	if (~Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_Sell) return FALSE;
  // Base owner eliminated
  if (Game.Players.Get(pBaseObj->Base)->Eliminated)
    {
    StartSoundEffect("Error",false,100,pBaseObj); 
    sprintf(OSTR,LoadResStr("IDS_PLR_ELIMINATED"),Game.Players.Get(pBaseObj->Base)->GetName());
    GameMsgPlayer(OSTR,iPlr); return FALSE;
    }
  // Base owner hostile
  if (Hostile(iPlr,pBaseObj->Base))
    {
    StartSoundEffect("Error",false,100,pBaseObj); 
    sprintf(OSTR,LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBaseObj->Base)->GetName());
    GameMsgPlayer(OSTR,iPlr); return FALSE;
    }
	// check validity of sell object, if specified
	if (pThing = pSellObj)
		if (!pThing->Status || pThing->Contained != pBaseObj)
			pThing = NULL;
  // Get object from home pBaseObj via selected id, if no or an anvalid thing has been specified
	if (!pThing)
		if (!(pThing=pBaseObj->Contents.Find(id))) return FALSE;
	// check definition NoSell
	if (pThing->Def->NoSell) return FALSE;
  // Sell object (pBaseObj owner gets the money)
  return Game.Players.Get(pBaseObj->Base)->Sell2Home(pThing); 
  }
void C4ConsoleQtLocalizeStringDlg::AddLanguagePressed()
{
	bool lang_ok = false;
	QRegExpValidator validator(QRegExp("^[a-zA-Z][a-zA-Z]$"), this);
	QString lang_id;
	while (!lang_ok)
	{
		bool ok; int q = 0;
		lang_id = QInputDialog::getText(this, LoadResStr("IDS_CNS_ADDLANGUAGE"), LoadResStr("IDS_CNS_ADDLANGUAGEID"), QLineEdit::Normal, QString(), &ok);
		if (!ok) return;
		lang_ok = (validator.validate(lang_id, q) == QValidator::Acceptable);
		if (!lang_ok)
		{
			DoError(LoadResStr("IDS_ERR_INVALIDLANGUAGEID"));
		}
	}
	// Either add or just focus existing editor
	QLineEdit *editor = GetEditorByLanguage(lang_id.toUtf8());
	if (!editor)
	{
		editor = AddEditor(lang_id.toUtf8(), nullptr);
		adjustSize();
		setMinimumSize(size());
	}
	editor->setFocus();
}
Esempio n. 9
0
bool C4GameSave::Save(C4Group &hToGroup, bool fKeepGroup)
{
	// close any previous
	Close();
	// set group
	pSaveGroup = &hToGroup; fOwnGroup = fKeepGroup;
	// PreSave-actions (virtual call)
	if (!OnSaving()) return false;
	// always save core
	if (!SaveCore()) { Log(LoadResStr("IDS_ERR_SAVE_CORE")); return false; }
	// cleanup group
	pSaveGroup->Delete(C4CFN_PlayerFiles);
	// remove: Title text, image and icon if specified
	if (!GetKeepTitle())
	{
		pSaveGroup->Delete(FormatString("%s.*",C4CFN_ScenarioTitle).getData());
		pSaveGroup->Delete(C4CFN_ScenarioIcon);
		pSaveGroup->Delete(FormatString(C4CFN_ScenarioDesc,"*").getData());
		pSaveGroup->Delete(C4CFN_Titles);
		pSaveGroup->Delete(C4CFN_Info);
	}
	// save additional runtime data
	if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false;
	// Desc
	if (GetSaveDesc())
		if (!SaveDesc(*pSaveGroup))
			Log(LoadResStr("IDS_ERR_SAVE_DESC"));  /* nofail */
	// save specialized components (virtual call)
	if (!SaveComponents()) return false;
	// done, success
	return true;
}
bool C4DownloadDlg::DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage)
{
	// log it
	LogF(LoadResStr("IDS_PRC_DOWNLOADINGFILE"), szURL);
	// show download dialog
	C4DownloadDlg *pDlg = new C4DownloadDlg(szDLType);
	if (!pDlg->ShowModal(pScreen, szURL, szSaveAsFilename))
	{
		// show an appropriate error
		const char *szError = pDlg->GetError();
		if (!szError || !*szError) szError = LoadResStr("IDS_PRC_UNKOWNERROR");
		StdStrBuf sError;
		sError.Format(LoadResStr("IDS_PRC_DOWNLOADERROR"), GetFilename(szURL), szError);
		// it's a 404: display extended message
		if (SSearch(szError, "404") && szNotFoundMessage)
			{ sError.Append("|"); sError.Append(szNotFoundMessage); }
		// display message
		pScreen->ShowMessageModal(sError.getData(), FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), C4GUI::MessageDialog::btnOK, C4GUI::Ico_Error, NULL);
		delete pDlg;
		return false;
	}
	LogF(LoadResStr("IDS_PRC_DOWNLOADCOMPLETE"), szURL);
	delete pDlg;
	return true;
}
bool C4EditCursor::Init()
{

#ifdef USE_WIN32_WINDOWS
	if (!(hMenu = LoadMenu(Application.GetInstance(),MAKEINTRESOURCE(IDR_CONTEXTMENUS))))
		return false;
#else // _WIN32
#ifdef WITH_DEVELOPER_MODE
	menuContext = gtk_menu_new();

	itemDelete = gtk_menu_item_new_with_label(LoadResStr("IDS_MNU_DELETE"));
	itemDuplicate = gtk_menu_item_new_with_label(LoadResStr("IDS_MNU_DUPLICATE"));
	itemGrabContents = gtk_menu_item_new_with_label(LoadResStr("IDS_MNU_CONTENTS"));

	gtk_menu_shell_append(GTK_MENU_SHELL(menuContext), itemDelete);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuContext), itemDuplicate);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuContext), itemGrabContents);

	g_signal_connect(G_OBJECT(itemDelete), "activate", G_CALLBACK(OnDelete), this);
	g_signal_connect(G_OBJECT(itemDuplicate), "activate", G_CALLBACK(OnDuplicate), this);
	g_signal_connect(G_OBJECT(itemGrabContents), "activate", G_CALLBACK(OnGrabContents), this);

	gtk_widget_show_all(menuContext);
#endif // WITH_DEVELOPER_MODe
#endif // _WIN32
	Console.UpdateModeCtrls(Mode);

	return true;
}
Esempio n. 12
0
void C4StartupMainDlg::UpdateParticipants()
{
	// First validate all participants (files must exist)
	std::string strPlayers(Config.General.Participants);
	std::vector<char> strPlayer(1025);
	*Config.General.Participants=0;
	for (int i = 0; SCopySegment(strPlayers.c_str(), i, &strPlayer[0], ';', strPlayer.size() - 1, true); i++)
	{
		const char *szPlayer = &strPlayer[0];
		std::string strPlayerFile(Config.General.UserDataPath);
		strPlayerFile.append(szPlayer);
		if (!szPlayer || !*szPlayer) continue;
		if (!FileExists(strPlayerFile.c_str())) continue;
		if (!SEqualNoCase(GetExtension(szPlayer), "ocp")) continue; // additional sanity check to clear strange exe-path-only entries in player list?
		SAddModule(Config.General.Participants, szPlayer);
	}
	// Draw selected players - we are currently displaying the players stored in Config.General.Participants.
	// Existence of the player files is not validated and player filenames are displayed directly
	// (names are not loaded from the player core).
	strPlayers = LoadResStr("IDS_DESC_PLRS");
	if (!Config.General.Participants[0])
		strPlayers.append(LoadResStr("IDS_DLG_NOPLAYERSSELECTED"));
	else
		for (int i = 0; SCopySegment(Config.General.Participants, i, &strPlayer[0], ';', 1024, true); i++)
		{
			if (i > 0) strPlayers.append(", ");
			strPlayers.append(GetFilenameOnly(&strPlayer[0]));
		}
	pParticipantsLbl->SetText(strPlayers.c_str());
}
Esempio n. 13
0
bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen)
{
	if(szUpdateURL == NULL || strlen(szUpdateURL) == 0)
	{
		pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"),C4GUI::MessageDialog::btnOK, C4GUI::Ico_Ex_Update);
		RedirectToDownloadPage();
		return true;
	}

	// Determine local filename for update group
	StdCopyStrBuf strLocalFilename(Config.AtTempPath(GetFilename(szUpdateURL)));
	StdCopyStrBuf strRemoteURL(szUpdateURL);
	// cut off http://
	strRemoteURL.Replace("http://","");
	// Download update group
	if (!C4DownloadDlg::DownloadFile(LoadResStr("IDS_TYPE_UPDATE"), pScreen, strRemoteURL.getData(), strLocalFilename.getData(), LoadResStr("IDS_MSG_UPDATENOTAVAILABLE")))
	{
		// Download failed, open browser so the user can download a full package
		RedirectToDownloadPage();
		// return success, because error message has already been shown
		return true;
	}

	// Apply downloaded update
	return ApplyUpdate(strLocalFilename.getData(), true, pScreen);
}
Esempio n. 14
0
bool C4GraphicsResource::LoadFile(C4Surface& sfc, const char *szName, C4GroupSet &rGfxSet, int32_t &ridCurrSfc, int iFlags)
{
	// find
	char FileName[_MAX_FNAME]; int32_t ID = 0;
	C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
	if (!pGrp)
	{
		LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
		return false;
	}
	// check group
	if (ID == ridCurrSfc)
		// already up-to-date
		return true;
	// load
	if (!sfc.Load(*pGrp, FileName, false, false, iFlags))
	{
		LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
		return false;
	}
	ridCurrSfc = ID;
	Game.SetInitProgress(ProgressStart);
	ProgressStart += ProgressIncrement;
	return true;
}
Esempio n. 15
0
bool C4GraphicsResource::LoadFile(C4FacetID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt, int32_t iHgt, bool fNoWarnIfNotFound, int iFlags)
{
	char FileName[_MAX_FNAME]; int32_t ID = 0;
	C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
	if (!pGrp)
	{
		// FIXME: Use LogFatal here
		if (!fNoWarnIfNotFound)
		{
			LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
		}
		return false;
	}
	// check group
	if (fct.idSourceGroup == ID)
		// already up-to-date
		return true;
	// load
	if (!fct.Load(*pGrp, FileName, iWdt, iHgt, false, iFlags))
	{
		LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
		return false;
	}
	fct.idSourceGroup = ID;
	Game.SetInitProgress(ProgressStart);
	ProgressStart += ProgressIncrement;
	return true;
}
Esempio n. 16
0
void C4ComponentHost::InitDialog(HWND hDlg) {
  hDialog = hDlg;
  // Set text
  SetWindowText(hDialog, Name);
  SetDlgItemText(hDialog, IDOK, LoadResStr("IDS_BTN_OK"));
  SetDlgItemText(hDialog, IDCANCEL, LoadResStr("IDS_BTN_CANCEL"));
  if (Data.getLength()) SetDlgItemText(hDialog, IDC_EDITDATA, Data.getData());
}
Esempio n. 17
0
C4DefinitionSelDlg::C4DefinitionSelDlg(C4FileSel_BaseCB *pSelCallback,
                                       const char *szFixedSelection)
    : C4FileSelDlg(Config.AtExePath(Config.General.DefinitionPath),
                   FormatString(LoadResStr("IDS_MSG_SELECT"),
                                LoadResStr("IDS_DLG_DEFINITIONS")).getData(),
                   pSelCallback) {
  if (szFixedSelection) sFixedSelection.Copy(szFixedSelection);
}
void C4GameOptionsList::OptionControlMode::DoDropdownFill(C4GUI::ComboBox_FillCB *pFiller)
{
	// change possible?
	if (!::Control.isNetwork() || !::Control.Network.IsEnabled() || !::Control.isCtrlHost()) return;
	// add possible modes
	pFiller->AddEntry(LoadResStr("IDS_NET_CTRLMODE_CENTRAL"), CNM_Central);
	pFiller->AddEntry(LoadResStr("IDS_NET_CTRLMODE_DECENTRAL"), CNM_Decentral);
}
Esempio n. 19
0
void C4StartupNetDlg::OnBtnUpdate(C4GUI::Control *btn)
{
	// do update
	if (!C4UpdateDlg::DoUpdate(UpdateURL.getData(), GetScreen()))
	{
		GetScreen()->ShowMessage(LoadResStr("IDS_MSG_UPDATEFAILED"), LoadResStr("IDS_TYPE_UPDATE"), C4GUI::Ico_Ex_Update);
	}
}
void C4GameOptionsList::OptionRuntimeJoin::Update()
{
	const char *szText;
	if (Config.Network.NoRuntimeJoin)
		szText = LoadResStr("IDS_NET_RUNTIMEJOINBARRED");
	else
		szText = LoadResStr("IDS_NET_RUNTIMEJOINFREE");
	pDropdownList->SetText(szText);
}
Esempio n. 21
0
void C4Application::OnCommand(const char *szCmd) {
  // Find parameters
  const char *szPar = strchr(szCmd, ' ');
  while (szPar && *szPar == ' ') szPar++;

  if (SEqual(szCmd, "/quit")) {
    Quit();
    return;
  }

  switch (AppState) {
    case C4AS_Startup:

      // Open a new game
      if (SEqual2(szCmd, "/open ")) {
        // Try to start the game with given parameters
        AppState = C4AS_Game;
        Game.ParseCommandLine(szPar);
        UseStartupDialog = true;
        if (!Game.Init()) AppState = C4AS_Startup;
      }

      break;

    case C4AS_Game:

      // Clear running game
      if (SEqual(szCmd, "/close")) {
        Game.Clear();
        Game.Default();
        AppState = C4AS_PreInit;
        UseStartupDialog = true;
        return;
      }

      // Lobby commands
      if (Game.Network.isLobbyActive()) {
        if (SEqual2(szCmd, "/start")) {
          // timeout given?
          int32_t iTimeout = Config.Lobby.CountdownTime;
          if (!Game.Network.isHost())
            Log(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
          else if (szPar && (!sscanf(szPar, "%d", &iTimeout) || iTimeout < 0))
            Log(LoadResStr("IDS_MSG_CMD_START_USAGE"));
          else
            // start new countdown (aborts previous if necessary)
            Game.Network.StartLobbyCountdown(iTimeout);
          break;
        }
      }

      // Normal commands
      Game.MessageInput.ProcessInput(szCmd);
      break;
  }
}
Esempio n. 22
0
const char *C4StartupNetListEntry::GetQueryTypeName(QueryType eQueryType)
{
	switch (eQueryType)
	{
	case NRQT_GameDiscovery: return LoadResStr("IDS_NET_QUERY_LOCALNET");
	case NRQT_Masterserver:  return LoadResStr("IDS_NET_QUERY_MASTERSRV");
	case NRQT_DirectJoin:    return LoadResStr("IDS_NET_QUERY_DIRECTJOIN");
	default: return "";
	};
}
Esempio n. 23
0
StdStrBuf C4TeamList::GetTeamDistName(TeamDist eTeamDist) const
{
	switch (eTeamDist)
	{
	case TEAMDIST_Free:      return(StdStrBuf(LoadResStr("IDS_MSG_TEAMDIST_FREE"), true));
	case TEAMDIST_Host:      return(StdStrBuf(LoadResStr("IDS_MSG_TEAMDIST_HOST"), true));
	case TEAMDIST_None:      return(StdStrBuf(LoadResStr("IDS_MSG_TEAMDIST_NONE"), true));
	case TEAMDIST_Random:    return(StdStrBuf(LoadResStr("IDS_MSG_TEAMDIST_RND"), true));
	case TEAMDIST_RandomInv: return(StdStrBuf(LoadResStr("IDS_MSG_TEAMDIST_RNDINV"), true));
	default: return(FormatString("TEAMDIST_undefined(%d)", (int) eTeamDist));
	}
}
Esempio n. 24
0
bool C4MainMenu::ActivateSurrender(int32_t iPlayer)
{
	C4FacetSurface fctSymbol;
	InitRefSym(C4GUI::Icon::GetIconFacet(C4GUI::Ico_Surrender), LoadResStr("IDS_MENU_SURRENDER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
	SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom);
	fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
	Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Surrender");
	fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
	Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
	SetCloseCommand("ActivateMenu:Main");
	return true;
}
Esempio n. 25
0
C4ChatControl::ChatSheet::ChatSheet(C4ChatControl *pChatControl,
                                    const char *szTitle, const char *szIdent,
                                    SheetType eType)
    : C4GUI::Tabular::Sheet(szTitle, C4Rect(0, 0, 10, 10), C4GUI::Ico_None,
                            true, false),
      iBackBufferIndex(-1),
      eType(eType),
      pNickList(NULL),
      pInputLbl(NULL),
      pChatControl(pChatControl),
      fHasUnread(false) {
  if (szIdent) sIdent.Copy(szIdent);
  // create elements - positioned later
  C4Rect rcDefault(0, 0, 10, 10);
  pChatBox = new C4GUI::TextWindow(rcDefault);
  // pChatBox->SetToolTip(LoadResStr("IDS_DLGTIP_CHATWIN")); tooltip doesn't
  // really help, only makes things unübersichtlich
  pChatBox->SetDecoration(false, false, NULL, false);
  AddElement(pChatBox);
  if (eType == CS_Channel) {
    pNickList = new C4GUI::ListBox(rcDefault);
    pNickList->SetDecoration(false, NULL, true, false);
    pNickList->SetSelectionDblClickFn(
        new C4GUI::CallbackHandler<C4ChatControl::ChatSheet>(
            this, &C4ChatControl::ChatSheet::OnNickDblClick));
    AddElement(pNickList);
  }
  if (eType != CS_Server)
    pInputLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_DLG_CHAT"), rcDefault,
                                       C4GUI_CaptionFontClr,
                                       &C4GUI::GetRes()->TextFont);
  pInputEdit = new C4GUI::CallbackEdit<C4ChatControl::ChatSheet>(
      rcDefault, this, &C4ChatControl::ChatSheet::OnChatInput);
  pInputEdit->SetToolTip(LoadResStr("IDS_DLGTIP_CHAT"));
  if (pInputLbl) {
    pInputLbl->SetToolTip(LoadResStr("IDS_DLGTIP_CHAT"));
    pInputLbl->SetClickFocusControl(pInputEdit);
    AddElement(pInputLbl);
  }
  AddElement(pInputEdit);
  // key bindings
  pKeyHistoryUp = new C4KeyBinding(
      C4KeyCodeEx(K_UP), "ChatHistoryUp", KEYSCOPE_Gui,
      new C4GUI::DlgKeyCBEx<C4ChatControl::ChatSheet, bool>(
          *this, true, &C4ChatControl::ChatSheet::KeyHistoryUpDown),
      C4CustomKey::PRIO_CtrlOverride);
  pKeyHistoryDown = new C4KeyBinding(
      C4KeyCodeEx(K_DOWN), "ChatHistoryDown", KEYSCOPE_Gui,
      new C4GUI::DlgKeyCBEx<C4ChatControl::ChatSheet, bool>(
          *this, false, &C4ChatControl::ChatSheet::KeyHistoryUpDown),
      C4CustomKey::PRIO_CtrlOverride);
}
Esempio n. 26
0
bool C4MainMenu::ActivateClient(int32_t iPlayer)
{
	// Menu symbol/init
	C4FacetSurface fctSymbol;
	InitRefSym(C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), LoadResStr("IDS_MENU_DISCONNECTFROMSERVER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
	SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom);
	fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
	Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Part");
	fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
	Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
	SetCloseCommand("ActivateMenu:Main");
	return true;
}
Esempio n. 27
0
bool C4Extra::LoadDef(C4Group &hGroup, const char *szName)
{
	// check if file exists
	if (!hGroup.FindEntry(szName)) return false;
	// log that extra group is loaded
	LogF(LoadResStr("IDS_PRC_LOADEXTRA"), hGroup.GetName(), szName);
	// open and add group to set
	C4Group *pGrp = new C4Group;
	if (!pGrp->OpenAsChild(&hGroup, szName)) { Log(LoadResStr("IDS_ERR_FAILURE")); delete pGrp; return false; }
	Game.GroupSet.RegisterGroup(*pGrp, true, C4GSPrio_Extra, C4GSCnt_Extra);
	// done, success
	return true;
}
Esempio n. 28
0
C4Network2StartWaitDlg::C4Network2StartWaitDlg()
		: C4GUI::Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_CAPTION"), false)
{
	C4GUI::ComponentAligner caAll(GetContainedClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent);
	C4GUI::ComponentAligner caButtonArea(caAll.GetFromBottom(C4GUI_ButtonAreaHgt), 0,0);
	// create top label
	C4GUI::Label *pLbl;
	AddElement(pLbl = new C4GUI::Label(LoadResStr("IDS_NET_WAITFORSTART"), caAll.GetFromTop(25), ACenter));
	// create client list box
	AddElement(pClientListBox = new C4Network2ClientListBox(caAll.GetAll(), true));
	// place abort button
	C4GUI::Button *pBtnAbort = new C4GUI::CancelButton(caButtonArea.GetCentered(C4GUI_DefButtonWdt, C4GUI_ButtonHgt));
	AddElement(pBtnAbort);
}
Esempio n. 29
0
void C4ChatControl::UserQueryQuit() {
  // still connected? Then confirm first
  if (pIRCClient->IsActive()) {
    if (!GetScreen()->ShowMessageModal(
            LoadResStr("IDS_MSG_DISCONNECTFROMSERVER"),
            LoadResStr("IDS_DLG_CHAT"), C4GUI::MessageDialog::btnOKAbort,
            C4GUI::Ico_Confirm, NULL))
      return;
  }
  // disconnect from server
  pIRCClient->Close();
  // change back to login page
  UpdateShownPage();
}
void C4DownloadDlg::OnIdle()
{
	// continue query process
	if (!HTTPClient.Execute())
	{
		// query aborted
		Close(false);
		return;
	}
	if (!HTTPClient.isBusy())
	{
		// download done or aborted
		Close(HTTPClient.isSuccess());
		return;
	}
	StdStrBuf sStatus; int32_t iProgress = -1;
	StdStrBuf sSize("");
	// download in progress: Update status
	if (!HTTPClient.isConnected())
	{
		// still connecting
		sStatus.Ref(LoadResStr("IDS_DL_STATUSCONNECTING"));
	}
	else
	{
		// header received?
		size_t iSize = HTTPClient.getTotalSize();
		if (!iSize)
		{
			// file size unknown: No header received.
			sStatus.Ref(LoadResStr("IDS_PRC_CONNECTED"));
		}
		else
		{
			// file size known: Download in progress
			sStatus.Ref(LoadResStr("IDS_CTL_DL_PROGRESS"));
			if (iSize <= 1024)
				sSize.Format(" (%ld Bytes)", (long)iSize);
			else if (iSize <= 1024*1024)
				sSize.Format(" (%ld KB)", (long)(iSize/1024));
			else
				sSize.Format(" (%ld MB)", (long)(iSize/1024/1024));
			iProgress = int64_t(100) * HTTPClient.getDownloadedSize() / iSize;
		}
	}
	const char *szStatusString = LoadResStr("IDS_PRC_DOWNLOADINGFILE");
	SetStatus(FormatString(szStatusString, GetFilename(HTTPClient.getRequest())).getData(), iProgress );
}