예제 #1
0
파일: C4Log.cpp 프로젝트: ev1313/yaC
bool GetLogSection(size_t iStart, size_t iLength, StdStrBuf &rsOut) {
  if (!iLength) {
    rsOut.Clear();
    return true;
  }
  // read section from log file
  CStdFile LogFileRead;
  char *szBuf, *szBufOrig;
  size_t iSize;  // size exclusing terminator
  if (!LogFileRead.Load(sLogFileName.getData(), (BYTE **)&szBuf, (int *)&iSize,
                        1))
    return false;
  szBufOrig = szBuf;
  // reduce to desired buffer section
  if (iStart > iSize) iStart = iSize;
  if (iStart + iLength > iSize) iLength = iSize - iStart;
  szBuf += iStart;
  szBuf[iLength] = '\0';
  // strip timestamps; convert linebreaks to Clonk-linebreaks '|'
  char *szPosWrite = szBuf;
  const char *szPosRead = szBuf;
  while (*szPosRead) {
    // skip timestamp
    if (*szPosRead == '[')
      while (*szPosRead && *szPosRead != ']') {
        --iSize;
        ++szPosRead;
      }
    // skip whitespace behind timestamp
    if (!*szPosRead) break;
    szPosRead++;
    // copy data until linebreak
    size_t iLen = 0;
    while (*szPosRead && *szPosRead != 0x0d && *szPosRead != 0x0a) {
      ++szPosRead;
      ++iLen;
    }
    if (iLen && szPosRead - iLen != szPosWrite)
      memmove(szPosWrite, szPosRead - iLen, iLen);
    szPosWrite += iLen;
    // skip additional linebreaks
    while (*szPosRead == 0x0d || *szPosRead == 0x0a) ++szPosRead;
    // write a Clonk-linebreak
    if (*szPosRead) *szPosWrite++ = '|';
  }
  // done; create string buffer from data
  rsOut.Copy(szBuf, szPosWrite - szBuf);
  // old buf no longer used
  delete[] szBufOrig;
  // done, success
  return true;
}
예제 #2
0
void C4GraphicsSystem::DrawHelp()
	{
	if (!ShowHelp) return;
	if (!Application.isFullScreen) return;
	int32_t iX = ViewportArea.X, iY = ViewportArea.Y;
	int32_t iWdt = ViewportArea.Wdt;
	StdStrBuf strText;
	// left coloumn
	strText.AppendFormat("[%s]\n\n", LoadResStr("IDS_CTL_GAMEFUNCTIONS"));
	// main functions
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("ToggleShowHelp").getData(), LoadResStr("IDS_CON_HELP"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("MusicToggle").getData(), LoadResStr("IDS_CTL_MUSIC"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("NetClientListDlgToggle").getData(), LoadResStr("IDS_DLG_NETWORK"));
	// messages
	StdCopyStrBuf strAltChatKey(GetKeyboardInputName("ChatOpen", false, 0));
	strText.AppendFormat("\n<c ffff00>%s/%s</c> - %s\n", GetKeyboardInputName("ChatOpen", false, 1).getData(), strAltChatKey.getData(), LoadResStr("IDS_CTL_SENDMESSAGE"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("MsgBoardScrollUp").getData(), LoadResStr("IDS_CTL_MESSAGEBOARDBACK"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("MsgBoardScrollDown").getData(), LoadResStr("IDS_CTL_MESSAGEBOARDFORWARD"));
	// irc chat
	strText.AppendFormat("\n<c ffff00>%s</c> - %s\n", GetKeyboardInputName("ToggleChat").getData(), LoadResStr("IDS_CTL_IRCCHAT"));
	// scoreboard
	strText.AppendFormat("\n<c ffff00>%s</c> - %s\n", GetKeyboardInputName("ScoreboardToggle").getData(), LoadResStr("IDS_CTL_SCOREBOARD"));
	// screenshots
	strText.AppendFormat("\n<c ffff00>%s</c> - %s\n", GetKeyboardInputName("Screenshot").getData(), LoadResStr("IDS_CTL_SCREENSHOT"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("ScreenshotEx").getData(), LoadResStr("IDS_CTL_SCREENSHOTEX"));

	Application.DDraw->TextOut(strText.getData(), Game.GraphicsResource.FontRegular, 1.0, Application.DDraw->lpBack,
														 iX + 128, iY + 64, CStdDDraw::DEFAULT_MESSAGE_COLOR, ALeft);

	// right coloumn
	strText.Clear();
	// game speed
	strText.AppendFormat("\n\n<c ffff00>%s</c> - %s\n", GetKeyboardInputName("GameSpeedUp").getData(), LoadResStr("IDS_CTL_GAMESPEEDUP"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("GameSlowDown").getData(), LoadResStr("IDS_CTL_GAMESPEEDDOWN"));
	// debug
	strText.AppendFormat("\n\n[%s]\n\n", "Debug");
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("DbgModeToggle").getData(), LoadResStr("IDS_CTL_DEBUGMODE"));
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("DbgShowVtxToggle").getData(), "Entrance+Vertices");
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("DbgShowActionToggle").getData(), "Actions/Commands/Pathfinder");
	strText.AppendFormat("<c ffff00>%s</c> - %s\n", GetKeyboardInputName("DbgShowSolidMaskToggle").getData(), "SolidMasks");
	Application.DDraw->TextOut(strText.getData(), Game.GraphicsResource.FontRegular, 1.0, Application.DDraw->lpBack,
														 iX + iWdt/2 + 64, iY + 64, CStdDDraw::DEFAULT_MESSAGE_COLOR, ALeft);
	}
예제 #3
0
파일: C4Def.cpp 프로젝트: farad91/openclonk
bool C4Def::LoadDefCore(C4Group &hGroup)
{
	StdStrBuf Source;
	if (hGroup.LoadEntryString(C4CFN_DefCore,&Source))
	{
		StdStrBuf Name = hGroup.GetFullName() + (const StdStrBuf &)FormatString("%cDefCore.txt", DirectorySeparator);
		if (!Compile(Source.getData(), Name.getData()))
			return false;
		Source.Clear();

		// Check mass
		if (Mass < 0)
		{
			DebugLogF("WARNING: Def %s (%s) at %s has invalid mass!", GetName(), id.ToString(), hGroup.GetFullName().getData());
			Mass = 0;
		}

		return true;
	}
	return false;
}
예제 #4
0
StdStrBuf C4KeyCodeEx::ToString(bool fHumanReadable, bool fShort) const
{
    static StdStrBuf sResult;
    sResult.Clear();
    // Add shift
    for (DWORD dwShiftCheck = KEYS_First; dwShiftCheck <= KEYS_Max; dwShiftCheck <<= 1)
        if (dwShiftCheck & dwShift)
        {
            sResult.Append(KeyShift2String((C4KeyShiftState) dwShiftCheck));
            sResult.AppendChar('+');
        }
    // Add key
    if (sResult.getLength())
    {
        sResult.Append(KeyCode2String(Key, fHumanReadable, fShort));
        return sResult;
    }
    else
    {
        return KeyCode2String(Key, fHumanReadable, fShort);
    }
}
예제 #5
0
void ResetFatalError()
{
	sFatalError.Clear();
}