Exemple #1
0
ObjectMetadata::ObjectMetadata(const std::string & extensionNamespace_,
                   const std::string & name_,
                   const std::string & fullname_,
                   const std::string & informations_,
                   const std::string & icon24x24,
                   CreateFunPtr createFunPtrP,
                   DestroyFunPtr destroyFunPtrP) :
    extensionNamespace(extensionNamespace_)
{
    name = name_;
#if defined(GD_IDE_ONLY)
    SetFullName(std::string(fullname_));
    SetDescription(std::string(informations_));
#if !defined(GD_NO_WX_GUI)
    if ( gd::SkinHelper::IconExists(icon24x24, 24) )
        SetBitmapIcon(gd::SkinHelper::GetIcon(icon24x24, 24));
    else if ( wxFile::Exists(icon24x24) )
        SetBitmapIcon(wxBitmap(icon24x24, wxBITMAP_TYPE_ANY));
    else {
        std::cout << "Warning: The icon file for object \"" << name_
            << " was not found in the current skin icons"
            << " and the specified name is not an existing filename.";
        SetBitmapIcon(wxBitmap(24,24));
    }
#endif
#endif
    createFunPtr = createFunPtrP;
    destroyFunPtr = destroyFunPtrP;
}
Exemple #2
0
void CRoomTemplate::LoadFromKeyValues( const char *pRoomName, KeyValues *pKeyValues )
{
    m_nTilesX = pKeyValues->GetInt( "TilesX", 1 );
    m_nTilesY = pKeyValues->GetInt( "TilesY", 1 );
    SetSpawnWeight( pKeyValues->GetInt( "SpawnWeight", MIN_SPAWN_WEIGHT ) );

    SetFullName( pRoomName );

    Q_strncpy( m_Description, pKeyValues->GetString( "RoomTemplateDescription", "" ), m_nMaxDescriptionLength );
    Q_strncpy( m_Soundscape, pKeyValues->GetString( "Soundscape", "" ), m_nMaxSoundscapeLength );

    SetTileType( pKeyValues->GetInt( "TileType", ASW_TILETYPE_UNKNOWN ) );

    m_Tags.RemoveAll();

    // search through all the exit subsections
    KeyValues *pkvSubSection = pKeyValues->GetFirstSubKey();
    bool bClearedExits = false;
    while ( pkvSubSection )
    {
        // mission details
        if ( Q_stricmp(pkvSubSection->GetName(), "EXIT")==0 )
        {
            if ( !bClearedExits )
            {
                // if we haven't cleared previous exits yet then do so now
                m_Exits.PurgeAndDeleteElements();
                bClearedExits = true;
            }
            CRoomTemplateExit *pExit = new CRoomTemplateExit();
            pExit->m_iXPos = pkvSubSection->GetInt("XPos");
            pExit->m_iYPos = pkvSubSection->GetInt("YPos");
            pExit->m_ExitDirection = (ExitDirection_t) pkvSubSection->GetInt("ExitDirection");
            pExit->m_iZChange = pkvSubSection->GetInt("ZChange");
            Q_strncpy( pExit->m_szExitTag, pkvSubSection->GetString( "ExitTag" ), sizeof( pExit->m_szExitTag ) );
            pExit->m_bChokepointGrowSource = !!pkvSubSection->GetInt("ChokeGrow", 0);

            // discard exits outside the room bounds
            if ( pExit->m_iXPos < 0 || pExit->m_iYPos < 0 || pExit->m_iXPos >= m_nTilesX || pExit->m_iYPos >= m_nTilesY )
            {
                delete pExit;
            }
            else
            {
                m_Exits.AddToTail(pExit);
            }
        }
        else if ( Q_stricmp(pkvSubSection->GetName(), "Tags")==0 && TagList() )
        {
            for ( KeyValues *sub = pkvSubSection->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
            {
                if ( !Q_stricmp( sub->GetName(), "tag" ) )
                {
                    AddTag( sub->GetString() );
                }
            }
        }
        pkvSubSection = pkvSubSection->GetNextKey();
    }
}
bool HearthLogApp::OnInit()
{
	// Build the path for a log file
	auto file = Helper::GetUserDataDir();
	file.SetFullName("log.txt");

	// Create the containing directory if needed
	if (!file.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
		wxLogError("error creating save directory: %s", file.GetPath());
		return false;
	}

	// Open a file for logging
	fout.open(file.GetFullPath().c_str().AsChar(), std::ofstream::out);

	// Setup the log file
	auto logFile = new wxLogStream(&fout);
	wxLog::SetActiveTarget(logFile);

	// Wrap the log file with a GUI window
	auto logWindow = new wxLogWindow(NULL, _("Log"), false, true);
	logWindow->GetFrame()->SetSize(1024, 300);
	wxLog::SetActiveTarget(logWindow);

	// Start logging
	wxLog::SetVerbose();
	wxLogMessage(_("Hearth Log %s"), Helper::AppVersion());

	// Setup config from file
	wxConfig::Set(new wxFileConfig("", "", "config.ini", "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_SUBDIR));

	// Locate the Hearthstone directory
	while (!Helper::GetHearthstoneVersion()) {
		auto dir = wxDirSelector(_("Hearth Log: Please locate your Hearthstone directory (Usually C:\\Program Files (x86)\\Hearthstone)"));
		if (dir.empty()) {
			return false;
		}
		Helper::WriteConfig("HearthstoneDir", dir);
	}

	// Create the GUI bits
	icon = new TaskBarIcon();

	// Setup a packet parsing stack
	PacketCapture::Start("tcp port 3724 or tcp port 1119", 
	//PacketCapture::Start("tcp port 1119", "C:\\Users\\Chip\\Documents\\Network Monitor 3\\Captures\\Hearthstone2.pcap", 
		[]() -> PacketCapture::Callback::Ptr {
			return std::make_unique<tcp::Parser>(
				[](int64_t nanotime, tcp::Stream *stream) -> tcp::Parser::Callback::Ptr {
					return std::make_unique<GameLogger>(nanotime, stream);
				});
		});

	// Try to upload any logs that haven't been uploaded yet
	icon->UploadAll();

	return true;
}
Exemple #4
0
	~Log()
	{
		if (_messages.size() <= 1) {
			return;
		}

		// Build the file name for storing this game
		auto file = Helper::GetUserDataDir();
		file.SetFullName(wxString::Format("%i.hsl", int(_messages[0].first / int(1e9))));
		file.AppendDir("Logged");
		auto filename = file.GetFullPath();
		wxLogVerbose("saving %d messages to %s", _messages.size() - 1, filename);

		// Create the containing directory if needed
		if (!file.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
			wxLogError("error creating save directory: %s", filename);
			return;
		}

		// This should't happen, but check and log just in case
		if (file.Exists()) {
			wxLogWarning("overwriting existing game: %s", filename);
		}

		// Open the file
		wxFileOutputStream fout(file.GetFullPath());
		if (!fout.Ok()) {
			wxLogError("error opening file: %s", filename);
			return;
		}

		// Zip the data while saving it to save some bandwidth later when the file is uploaded
		wxZlibOutputStream zout(fout, wxZ_BEST_COMPRESSION, wxZLIB_NO_HEADER);

		// Add header info
		// <nanotime>
		// 48 53 4C 48 09 00 00 00 
		// 09 XX XX XX XX XX XX XX XX
		auto version = Helper::GetHearthstoneVersion();
		zout.Write(&_messages[0].first, 8)
			.Write("HSLH\t\0\0\0\t", 9) // HSLH 09000000 09
			.Write(&version, 8);

		// Add the rest of the data
		auto size = 25;
		for (auto i = 1u; i < _messages.size(); i++) {
			auto time = _messages[i].first;
			auto msg = _messages[i].second;

			size += 8 + msg.size();
			zout.Write(&time, 8).Write(msg.data(), msg.size());
		}
		zout.Close();
		wxLogVerbose("saved %d messages from %s (%d bytes, %lld compressed)", _messages.size() - 1, _name, size, fout.GetLength());

		// Notify the app that it can upload the log file
		HearthLogApp::UploadLog(filename);
	}
void PHPEntityNamespace::FromResultSet(wxSQLite3ResultSet& res)
{
    SetDbId(res.GetInt64("ID"));
    SetFullName(res.GetString("FULLNAME"));
    SetShortName(res.GetString("NAME"));
    SetFilename(res.GetString("FILE_NAME"));
    SetLine(res.GetInt("LINE_NUMBER"));
    SetFlags(0);
}
void PHPEntityFunctionAlias::FromResultSet(wxSQLite3ResultSet& res)
{
    SetDbId(res.GetInt("ID"));
    SetShortName(res.GetString("NAME"));
    SetRealname(res.GetString("REALNAME"));
    SetLine(res.GetInt("LINE_NUMBER"));
    SetFilename(res.GetString("FILE_NAME"));
    SetFullName(res.GetString("FULLNAME"));
    SetScope(res.GetString("SCOPE"));
}
void PHPEntityVariable::FromResultSet(wxSQLite3ResultSet& res)
{
    SetDbId(res.GetInt("ID"));
    SetFullName(res.GetString("FULLNAME"));
    SetShortName(res.GetString("NAME"));
    SetTypeHint(res.GetString("TYPEHINT"));
    SetFlags(res.GetInt("FLAGS"));
    SetDocComment(res.GetString("DOC_COMMENT"));
    SetLine(res.GetInt("LINE_NUMBER"));
    SetFilename(res.GetString("FILE_NAME"));
}
void PHPEntityClass::FromResultSet(wxSQLite3ResultSet& res)
{
    SetDbId(res.GetInt("ID"));
    SetFullName(res.GetString("FULLNAME"));
    SetShortName(res.GetString("NAME"));
    SetExtends(res.GetString("EXTENDS"));
    SetImplements(::wxStringTokenize(res.GetString("IMPLEMENTS"), ";", wxTOKEN_STRTOK));
    SetTraits(::wxStringTokenize(res.GetString("USING_TRAITS"), ";", wxTOKEN_STRTOK));
    SetDocComment(res.GetString("DOC_COMMENT"));
    SetLine(res.GetInt("LINE_NUMBER"));
    SetFilename(res.GetString("FILE_NAME"));
    SetFlags(res.GetInt("FLAGS"));
}
Exemple #9
0
wxString FileException::ErrorMessage() const
{
   wxString format;
   switch (cause) {
      case Cause::Open:
         format = _("Audacity failed to open a file in %s.");
         break;
      case Cause::Read:
         format = _("Audacity failed to read from a file in %s.");
         break;
      case Cause::Write:
         format =
_("Audacity failed to write to a file.\n"
  "Perhaps %s is not writable or the disk is full.");
         break;
      case Cause::Rename:
         format =
_("Audacity successfully wrote a file in %s but failed to rename it as %s.");
      default:
         break;
   }
   wxString target;

#ifdef __WXMSW__

   // Drive letter plus colon
   target = fileName.GetVolume() + wxT(":");

#else

   // Shorten the path, arbitrarily to 3 components
   auto path = fileName;
   path.SetFullName(wxString{});
   while(path.GetDirCount() > 3)
      path.RemoveLastDir();
   target = path.GetFullPath();

#endif

   return wxString::Format(
      format, target, renameTarget.GetFullName() );
}
Exemple #10
0
void TaskBarIcon::UploadAll()
{
	auto path = Helper::GetUserDataDir();
	path.AppendDir("Logged");
	if (!path.DirExists())
		return;

	wxDir dir(path.GetFullPath());
	if (!dir.IsOpened())
		return;

	wxCommandEvent evt(HSL_LOG_AVAILABLE_EVENT);
	wxString filename;
	auto cont = dir.GetFirst(&filename, "*.hsl", wxDIR_FILES);
	while (cont) {
		path.SetFullName(filename);
		evt.SetString(path.GetFullPath());
		wxPostEvent(this, evt);

		cont = dir.GetNext(&filename);
	}
}
Exemple #11
0
BehaviorMetadata::BehaviorMetadata(const gd::String & extensionNamespace_,
                       const gd::String & name_,
                       const gd::String & fullname_,
                       const gd::String & defaultName_,
                       const gd::String & description_,
                       const gd::String & group_,
                       const gd::String & icon24x24,
                       const gd::String & className_,
                       std::shared_ptr<gd::Behavior> instance_,
                       std::shared_ptr<gd::BehaviorsSharedData> sharedDatasInstance_) :
    extensionNamespace(extensionNamespace_),
    instance(instance_),
    sharedDatasInstance(sharedDatasInstance_)
{
#if defined(GD_IDE_ONLY)
    SetFullName(gd::String(fullname_));
    SetDescription(gd::String(description_));
    SetDefaultName(gd::String(defaultName_));
    SetGroup(group_);
    className = className_;
    iconFilename = icon24x24;
#if !defined(GD_NO_WX_GUI)
    if ( gd::SkinHelper::IconExists(iconFilename, 24) )
        SetBitmapIcon(gd::SkinHelper::GetIcon(iconFilename, 24));
    else if ( wxFile::Exists(iconFilename) )
        SetBitmapIcon(wxBitmap(iconFilename, wxBITMAP_TYPE_ANY));
    else {
        std::cout << "Warning: The icon file for behavior \"" << name_
            << " was not found in the current skin icons"
            << " and the specified name is not an existing filename.";
        SetBitmapIcon(wxBitmap(24,24));
    }
#endif
#endif

    if ( instance ) instance->SetTypeName(name_);
    if ( sharedDatasInstance ) sharedDatasInstance->SetTypeName(name_);
}