コード例 #1
0
void C4GameOptionsList::SetParameters(C4ScenarioParameterDefs *param_defs, C4ScenarioParameters *params)
{
	// update to new parameter set
	ClearOptions();
	this->param_defs = param_defs;
	this->params = params;
	InitOptions();
}
コード例 #2
0
ファイル: voting.cpp プロジェクト: Ace-teeworlds/Collect-mod
CVoting::CVoting()
{
	ClearOptions();
	
	m_Closetime = 0;
	m_aDescription[0] = 0;
	m_aReason[0] = 0;
	m_Yes = m_No = m_Pass = m_Total = 0;
	m_Voted = 0;
}
コード例 #3
0
CompilerOptions& CompilerOptions::operator=(const CompilerOptions& other)
{
    ClearOptions();
	for (unsigned int i = 0; i < other.m_Options.GetCount(); ++i)
	{
        CompOption* coption = new CompOption(*(other.m_Options[i]));
        AddOption(coption);
	}
	return *this;
}
コード例 #4
0
WidgetDropDown::~WidgetDropDown()
{
	ClearOptions();

	parent_element->RemoveEventListener("click", this, true);
	parent_element->RemoveEventListener("blur", this);

	button_element->RemoveReference();
	selection_element->RemoveReference();
	value_element->RemoveReference();
}
コード例 #5
0
bool CSentencesCollection::CreateOptions(MorphLanguageEnum langua)
{
	try
	{
		ClearOptions();
		m_pSyntaxOptions = NewOptions(langua);
		assert (m_pSyntaxOptions);
	}
	catch(...)
	{
		return false;
	}
	return true;
}
コード例 #6
0
ファイル: vfecontrol.cpp プロジェクト: UberPOV/UberPOV
// Sets the options to be used on the next render. Accepts a vfeRenderOptions
// instance as its only parameter, and returns any one of a number of possible
// error codes (and sets m_LastError), as documented below:
//
//   vfeFailedToInitObject           - this is an internal error
//   vfeFailedToSetMaxThreads        - self-explanatory
//   vfeFailedToParseINI             - an INI file specified could not be parsed
//   vfeFailedToSetSource            - the source file specified could not be set
//   vfeFailedToParseCommand         - a command-line option was invalid
//   vfeNoInputFile                  - no input file specified either directly or via INI
//   vfeRenderBlockSizeTooSmall      - self-explanatory
//   vfeFailedToWriteINI             - a request to write the render options to an INI file failed
//   vfeUnsupportedOptionCombination - unsupported option combination
//
// If vfeRenderOptions explicitly specifies a source file, it will override
// any set via a parsed INI file. Furthermore, any source file set via a
// command-line option overrides both of the above.
//
// Note that it is your responsibility to add any default INI files that should
// be processed to the INI file list; neither SetOptions() nor any other part
// of the VFE or POV-Ray code will do that for you. This includes non-platform
// specific files such as a potential povray.ini in the CWD.
int vfeSession::SetOptions (vfeRenderOptions& opts)
{
  int                     err;
  UCS2                    str [MAX_PATH];
  POVMSObject             obj;
  vfeProcessRenderOptions options(this);

  m_OutputToFileSet = false;
  m_UsingAlpha = false;
  m_RenderingAnimation = false;
  m_RealTimeRaytracing = false;
  m_ClocklessAnimation = false;
  m_RenderWidth = m_RenderHeight = 0;
  ClearOptions();

  if ((err = POVMSObject_New (&obj, kPOVObjectClass_RenderOptions)) != kNoErr)
    return (m_LastError = vfeFailedToInitObject) ;

  if ((err = POVMSUtil_SetInt (&obj, kPOVAttrib_MaxRenderThreads, opts.m_ThreadCount)) != kNoErr)
    return (m_LastError = vfeFailedToSetMaxThreads) ;

  // we set this here for potential use by the IO permissions path checking code
  m_InputFilename = opts.m_SourceFile;

  // most likely povray.ini will be the first INI file processed here (as it's included by default)
  for (vector<UCS2String>::iterator i = opts.m_IniFiles.begin(); i != opts.m_IniFiles.end(); i++)
  {
    // we call TestAccessAllowed() here, even though ParseFile() will do it also, since if
    // access is denied, the reason will not be obvious (ParseFile() just returns kCannotOpenFileErr).
    if (!TestAccessAllowed (Path(*i), false))
      return (m_LastError = vfeIORestrictionDeny);

    if ((err = options.ParseFile (UCS2toASCIIString(*i).c_str(), &obj)) != kNoErr)
      return (m_LastError = vfeFailedToParseINI) ;

    // we keep this up to date since the IO permissions feature will use the current input
    // filename to determine the path for default read/write permission in the scene dir.
    int n = sizeof (str) ;
    if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_InputFile, str, &n)) == kNoErr)
      if (m_InputFilename != str)
        m_InputFilename = str;
  }

  // m_SourceFile overrides any source file set by the INI files
  if (opts.m_SourceFile.empty() == false)
  {
    m_InputFilename = opts.m_SourceFile;
    if ((err = POVMSUtil_SetUCS2String (&obj, kPOVAttrib_InputFile, opts.m_SourceFile.c_str())) != kNoErr)
      return (m_LastError = vfeFailedToSetSource);
  }

  // any source file set on the command-line overrides a source file set another way
  for (vector<string>::iterator i = opts.m_Commands.begin(); i != opts.m_Commands.end(); i++)
  {
    if ((err = options.ParseString (i->c_str(), &obj)) != kNoErr)
      return (m_LastError = vfeFailedToParseCommand) ;
    int n = sizeof (str) ;
    if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_InputFile, str, &n)) == kNoErr)
      if (m_InputFilename != str)
        m_InputFilename = str;
  }

  int n = sizeof (str) ;
  if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_InputFile, str, &n)) != kNoErr)
    return (m_LastError = vfeNoInputFile);
  m_InputFilename = str;

  POVMSUtil_GetInt (&obj, kPOVAttrib_Width, &m_RenderWidth) ;
  POVMSUtil_GetInt (&obj, kPOVAttrib_Height, &m_RenderHeight) ;

  std::list<Path> libpaths;
  POVMS_Object ropts (obj) ;
  if (ropts.Exist (kPOVAttrib_LibraryPath))
  {
    POVMS_List pathlist;
    ropts.Get (kPOVAttrib_LibraryPath, pathlist) ;

    // we take the opportunity to remove any duplicates that are in the path list.
    // it's cleaner to do that here, rather than in the INI parser, since it's table-
    // driven and doesn't have an explicit function for adding library paths per se.
    //
    // we use the Path equivalence operator rather than a string compare since
    // using Path should handle platform-specific issues like case-sensitivity (or,
    // rather, lack thereof). note that at the time of writing, the Path class did
    // not yet implement case-insensitive comparisions.
    //
    // NB while it would of course be more efficient to sort the list so searches are
    // faster, we'd have to make a copy of it to do that, as we can't change the order
    // of existing entries (that would change the include path search order). it's not
    // common to have a lot of include paths, so we just use linear searches.
    for (int i = 1; i <= pathlist.GetListSize(); i++)
    {
      POVMS_Attribute lp;

      pathlist.GetNth(i, lp);
      Path path(lp.GetUCS2String());
      if (find(libpaths.begin(), libpaths.end(), path) == libpaths.end())
        libpaths.push_back(path);
    }
  }

  if (opts.m_LibraryPaths.empty() == false)
  {
    for (vector<UCS2String>::const_iterator i = opts.m_LibraryPaths.begin(); i != opts.m_LibraryPaths.end(); i++)
    {
      Path path(*i);

      if (find(libpaths.begin(), libpaths.end(), path) == libpaths.end())
        libpaths.push_back(path);
    }
  }

  if (libpaths.empty() == false)
  {
    POVMS_List pathlist;
    for (list<Path>::iterator i = libpaths.begin(); i != libpaths.end(); i++)
    {
      POVMS_Attribute attr((*i)().c_str());
      pathlist.Append(attr);
    }
    ropts.Set (kPOVAttrib_LibraryPath, pathlist) ;
  }

  if (ropts.TryGetBool(kPOVAttrib_RealTimeRaytracing, false) == true)
    ropts.SetBool(kPOVAttrib_OutputToFile, false);

  m_OutputToFileSet = ropts.TryGetBool(kPOVAttrib_OutputToFile, true);

  // this is a bit messy: Grayscale_Output or OutputAlpha may be specified
  // in an INI file or elsewhere prior to the output file type being set.
  // so we can't check to see if it is supported with that file type
  // until all options have been parsed.
  if (m_OutputToFileSet)
  {
    int oft = ropts.TryGetInt(kPOVAttrib_OutputFileType, DEFAULT_OUTPUT_FORMAT);
    bool has16BitGrayscale = false;
    bool hasAlpha = false;
    for (int i = 0; FileTypeTable[i].internalId != 0; i ++)
    {
      if (oft == FileTypeTable[i].internalId)
      {
        has16BitGrayscale = FileTypeTable[i].has16BitGrayscale;
        hasAlpha          = FileTypeTable[i].hasAlpha;
        break;
      }
    }
    if (ropts.TryGetBool(kPOVAttrib_GrayscaleOutput, false) && !has16BitGrayscale)
    {
      AppendStatusMessage ("Grayscale output not currently supported with selected output file type.");
      AppendErrorMessage ("Grayscale output not currently supported with selected output file type.") ;
      return (m_LastError = vfeUnsupportedOptionCombination);
    }
    if (ropts.TryGetBool(kPOVAttrib_OutputAlpha, false) && !hasAlpha)
    {
      AppendWarningMessage ("Warning: Alpha channel output currently not (or not officially) supported with selected output file type.") ;
    }
  }

  if (ropts.TryGetInt(kPOVAttrib_RenderBlockSize, 32) < 4)
    return (m_LastError = vfeRenderBlockSizeTooSmall);

  if ((ropts.TryGetInt(kPOVAttrib_DisplayGammaType, DEFAULT_DISPLAY_GAMMA_TYPE) == kPOVList_GammaType_PowerLaw) &&
      (ropts.TryGetFloat(kPOVAttrib_DisplayGamma, DEFAULT_DISPLAY_GAMMA) < 0.001f))
    return (m_LastError = vfeDisplayGammaTooSmall);
  if ((ropts.TryGetInt(kPOVAttrib_FileGammaType, DEFAULT_FILE_GAMMA_TYPE) == kPOVList_GammaType_PowerLaw) &&
      (ropts.TryGetFloat(kPOVAttrib_FileGamma, DEFAULT_FILE_GAMMA) < 0.001f))
    return (m_LastError = vfeFileGammaTooSmall);

  n = sizeof (str) ;
  if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_CreateIni, str, &n)) == kNoErr && str [0] != 0)
    if ((err = options.WriteFile (UCS2toASCIIString(str).c_str(), &obj)) != kNoErr)
      return (m_LastError = vfeFailedToWriteINI);

  opts.m_Options = ropts;
  m_RenderOptions = opts ;
  m_OptionsSet = true;

  return (m_LastError = vfeNoError) ;
}
コード例 #7
0
ファイル: voting.cpp プロジェクト: Ace-teeworlds/Collect-mod
void CVoting::OnMessage(int MsgType, void *pRawMsg)
{
	if(MsgType == NETMSGTYPE_SV_VOTESET)
	{
		CNetMsg_Sv_VoteSet *pMsg = (CNetMsg_Sv_VoteSet *)pRawMsg;
		if(pMsg->m_Timeout)
		{
			OnReset();
			str_copy(m_aDescription, pMsg->m_pDescription, sizeof(m_aDescription));
			str_copy(m_aReason, pMsg->m_pReason, sizeof(m_aReason));
			m_Closetime = time_get() + time_freq() * pMsg->m_Timeout;
		}
		else
			OnReset();
	}
	else if(MsgType == NETMSGTYPE_SV_VOTESTATUS)
	{
		CNetMsg_Sv_VoteStatus *pMsg = (CNetMsg_Sv_VoteStatus *)pRawMsg;
		m_Yes = pMsg->m_Yes;
		m_No = pMsg->m_No;
		m_Pass = pMsg->m_Pass;
		m_Total = pMsg->m_Total;
	}
	else if(MsgType == NETMSGTYPE_SV_VOTECLEAROPTIONS)
	{
		ClearOptions();
	}
	else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONLISTADD)
	{
		CNetMsg_Sv_VoteOptionListAdd *pMsg = (CNetMsg_Sv_VoteOptionListAdd *)pRawMsg;
		int NumOptions = pMsg->m_NumOptions;
		for(int i = 0; i < NumOptions; ++i)
		{
			switch(i)
			{
			case 0: AddOption(pMsg->m_pDescription0); break;
			case 1: AddOption(pMsg->m_pDescription1); break;
			case 2: AddOption(pMsg->m_pDescription2); break;
			case 3: AddOption(pMsg->m_pDescription3); break;
			case 4: AddOption(pMsg->m_pDescription4); break;
			case 5: AddOption(pMsg->m_pDescription5); break;
			case 6: AddOption(pMsg->m_pDescription6); break;
			case 7: AddOption(pMsg->m_pDescription7); break;
			case 8: AddOption(pMsg->m_pDescription8); break;
			case 9: AddOption(pMsg->m_pDescription9); break;
			case 10: AddOption(pMsg->m_pDescription10); break;
			case 11: AddOption(pMsg->m_pDescription11); break;
			case 12: AddOption(pMsg->m_pDescription12); break;
			case 13: AddOption(pMsg->m_pDescription13); break;
			case 14: AddOption(pMsg->m_pDescription14);
			}
		}
	}
	else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONADD)
	{
		CNetMsg_Sv_VoteOptionAdd *pMsg = (CNetMsg_Sv_VoteOptionAdd *)pRawMsg;
		AddOption(pMsg->m_pDescription);
	}
	else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONREMOVE)
	{
		CNetMsg_Sv_VoteOptionRemove *pMsg = (CNetMsg_Sv_VoteOptionRemove *)pRawMsg;

		for(CVoteOptionClient *pOption = m_pFirst; pOption; pOption = pOption->m_pNext)
		{
			if(str_comp(pOption->m_aDescription, pMsg->m_pDescription) == 0)
			{
				// remove it from the list
				if(m_pFirst == pOption)
					m_pFirst = m_pFirst->m_pNext;
				if(m_pLast == pOption)
					m_pLast = m_pLast->m_pPrev;
				if(pOption->m_pPrev)
					pOption->m_pPrev->m_pNext = pOption->m_pNext;
				if(pOption->m_pNext)
					pOption->m_pNext->m_pPrev = pOption->m_pPrev;
				--m_NumVoteOptions;

				// add it to recycle list
				pOption->m_pNext = 0;
				pOption->m_pPrev = m_pRecycleLast;
				if(pOption->m_pPrev)
					pOption->m_pPrev->m_pNext = pOption;
				m_pRecycleLast = pOption;
				if(!m_pRecycleFirst)
					m_pRecycleLast = pOption;

				break;
			}
		}
	}
}
コード例 #8
0
CSentencesCollection::~CSentencesCollection()
{	
	ClearSentences();
	ClearOptions();
}
コード例 #9
0
ファイル: voting.cpp プロジェクト: BotoX/teeworlds
CVoting::CVoting()
{
	ClearOptions();
	Clear();
}
コード例 #10
0
ファイル: voting.cpp プロジェクト: BotoX/teeworlds
void CVoting::OnMessage(int MsgType, void *pRawMsg)
{
	if(MsgType == NETMSGTYPE_SV_VOTESET)
	{
		CNetMsg_Sv_VoteSet *pMsg = (CNetMsg_Sv_VoteSet *)pRawMsg;
		int BlockTick = m_CallvoteBlockTick;
		char aBuf[128];
		if(pMsg->m_Timeout)
		{
			OnReset();
			str_copy(m_aReason, pMsg->m_pReason, sizeof(m_aReason));
			m_Closetime = time_get() + time_freq() * pMsg->m_Timeout;
			if(pMsg->m_ClientID != -1)
			{
				char aLabel[64];
				CGameClient::GetPlayerLabel(aLabel, sizeof(aLabel), pMsg->m_ClientID, m_pClient->m_aClients[pMsg->m_ClientID].m_aName);
				switch(pMsg->m_Type)
				{
				case VOTE_START_OP:
					str_format(aBuf, sizeof(aBuf), Localize("'%s' called vote to change server option '%s' (%s)"), aLabel, pMsg->m_pDescription, pMsg->m_pReason);
					str_copy(m_aDescription, pMsg->m_pDescription, sizeof(m_aDescription));
					m_pClient->m_pChat->AddLine(-1, 0, aBuf);
					break;
				case VOTE_START_KICK:
					{
						char aName[4];
						if(!g_Config.m_ClShowsocial)
							str_copy(aName, pMsg->m_pDescription, sizeof(aName));
						str_format(aBuf, sizeof(aBuf), Localize("'%s' called for vote to kick '%s' (%s)"), aLabel, g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
						str_format(m_aDescription, sizeof(m_aDescription), "Kick '%s'", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
						m_pClient->m_pChat->AddLine(-1, 0, aBuf);
						break;
					}
				case VOTE_START_SPEC:
					{
						char aName[4];
						if(!g_Config.m_ClShowsocial)
							str_copy(aName, pMsg->m_pDescription, sizeof(aName));
						str_format(aBuf, sizeof(aBuf), Localize("'%s' called for vote to move '%s' to spectators (%s)"), aLabel, g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
						str_format(m_aDescription, sizeof(m_aDescription), "Move '%s' to spectators", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
						m_pClient->m_pChat->AddLine(-1, 0, aBuf);
					}
				}
				if(pMsg->m_ClientID == m_pClient->m_LocalClientID)
					m_CallvoteBlockTick = Client()->GameTick()+Client()->GameTickSpeed()*VOTE_COOLDOWN;
			}
		}
		else
		{
			switch(pMsg->m_Type)
			{
			case VOTE_START_OP:
				str_format(aBuf, sizeof(aBuf), Localize("Admin forced server option '%s' (%s)"), pMsg->m_pDescription, pMsg->m_pReason);
				m_pClient->m_pChat->AddLine(-1, 0, aBuf);
				break;
			case VOTE_START_SPEC:
				str_format(aBuf, sizeof(aBuf), Localize("Admin moved '%s' to spectator (%s)"), pMsg->m_pDescription, pMsg->m_pReason);
				m_pClient->m_pChat->AddLine(-1, 0, aBuf);
				break;
			case VOTE_END_ABORT:
				OnReset();
				m_pClient->m_pChat->AddLine(-1, 0, Localize("Vote aborted"));
				break;
			case VOTE_END_PASS:
				OnReset();
				if(pMsg->m_ClientID == -1)
					m_pClient->m_pChat->AddLine(-1, 0, Localize("Admin forced vote yes"));
				else
					m_pClient->m_pChat->AddLine(-1, 0, Localize("Vote passed"));
				break;
			case  VOTE_END_FAIL:
				OnReset();
				if(pMsg->m_ClientID == -1)
					m_pClient->m_pChat->AddLine(-1, 0, Localize("Admin forced vote no"));
				else
					m_pClient->m_pChat->AddLine(-1, 0, Localize("Vote failed"));
				m_CallvoteBlockTick = BlockTick;
			}
		}
	}
	else if(MsgType == NETMSGTYPE_SV_VOTESTATUS)
	{
		CNetMsg_Sv_VoteStatus *pMsg = (CNetMsg_Sv_VoteStatus *)pRawMsg;
		m_Yes = pMsg->m_Yes;
		m_No = pMsg->m_No;
		m_Pass = pMsg->m_Pass;
		m_Total = pMsg->m_Total;
	}
	else if(MsgType == NETMSGTYPE_SV_VOTECLEAROPTIONS)
	{
		ClearOptions();
	}
	else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONADD)
	{
		CNetMsg_Sv_VoteOptionAdd *pMsg = (CNetMsg_Sv_VoteOptionAdd *)pRawMsg;
		AddOption(pMsg->m_pDescription);
	}
	else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONREMOVE)
	{
		CNetMsg_Sv_VoteOptionRemove *pMsg = (CNetMsg_Sv_VoteOptionRemove *)pRawMsg;

		for(CVoteOptionClient *pOption = m_pFirst; pOption; pOption = pOption->m_pNext)
		{
			if(str_comp(pOption->m_aDescription, pMsg->m_pDescription) == 0)
			{
				// remove it from the list
				if(m_pFirst == pOption)
					m_pFirst = m_pFirst->m_pNext;
				if(m_pLast == pOption)
					m_pLast = m_pLast->m_pPrev;
				if(pOption->m_pPrev)
					pOption->m_pPrev->m_pNext = pOption->m_pNext;
				if(pOption->m_pNext)
					pOption->m_pNext->m_pPrev = pOption->m_pPrev;
				--m_NumVoteOptions;

				// add it to recycle list
				pOption->m_pNext = 0;
				pOption->m_pPrev = m_pRecycleLast;
				if(pOption->m_pPrev)
					pOption->m_pPrev->m_pNext = pOption;
				m_pRecycleLast = pOption;
				if(!m_pRecycleFirst)
					m_pRecycleLast = pOption;

				break;
			}
		}
	}
}
コード例 #11
0
CompilerOptions::~CompilerOptions()
{
	ClearOptions();
}