示例#1
0
文件: ptm.cpp 项目: Dragios/Citra
static void WriteGameCoinData(GameCoin gamecoin_data) {
    std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
    FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true);

    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = extdata_archive_factory.Open(archive_path);
    std::unique_ptr<FileSys::ArchiveBackend> archive;

    FileSys::Path gamecoin_path("/gamecoin.dat");
    // If the archive didn't exist, create the files inside
    if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
        // Format the archive to create the directories
        extdata_archive_factory.Format(archive_path, FileSys::ArchiveFormatInfo());
        // Open it again to get a valid archive now that the folder exists
        archive = extdata_archive_factory.Open(archive_path).Unwrap();
        // Create the game coin file
        archive->CreateFile(gamecoin_path, sizeof(GameCoin));
    } else {
        ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
        archive = std::move(archive_result).Unwrap();
    }

    FileSys::Mode open_mode = {};
    open_mode.write_flag.Assign(1);
    // Open the file and write the default gamecoin information
    auto gamecoin_result = archive->OpenFile(gamecoin_path, open_mode);
    if (gamecoin_result.Succeeded()) {
        auto gamecoin = std::move(gamecoin_result).Unwrap();
        gamecoin->Write(0, sizeof(GameCoin), true, reinterpret_cast<const u8*>(&gamecoin_data));
        gamecoin->Close();
    }
}
示例#2
0
文件: ptm.cpp 项目: Dragios/Citra
static GameCoin ReadGameCoinData() {
    std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
    FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true);

    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = extdata_archive_factory.Open(archive_path);
    if (!archive_result.Succeeded()) {
        LOG_ERROR(Service_PTM, "Could not open the PTM SharedExtSaveData archive!");
        return default_game_coin;
    }

    FileSys::Path gamecoin_path("/gamecoin.dat");
    FileSys::Mode open_mode = {};
    open_mode.read_flag.Assign(1);

    auto gamecoin_result = (*archive_result)->OpenFile(gamecoin_path, open_mode);
    if (!gamecoin_result.Succeeded()) {
        LOG_ERROR(Service_PTM, "Could not open the game coin data file!");
        return default_game_coin;
    }
    u16 result;
    auto gamecoin = std::move(gamecoin_result).Unwrap();
    GameCoin gamecoin_data;
    gamecoin->Read(0, sizeof(GameCoin), reinterpret_cast<u8*>(&gamecoin_data));
    gamecoin->Close();
    return gamecoin_data;
}
示例#3
0
文件: ptm.cpp 项目: ChibiDenDen/citra
void Init() {
    AddService(new PTM_Play_Interface);
    AddService(new PTM_Sysm_Interface);
    AddService(new PTM_U_Interface);

    shell_open = true;
    battery_is_charging = true;

    // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist
    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
    // If the archive didn't exist, create the files inside
    if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
        // Format the archive to create the directories
        Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
        // Open it again to get a valid archive now that the folder exists
        archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
        ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");

        FileSys::Path gamecoin_path("gamecoin.dat");
        FileSys::Mode open_mode = {};
        open_mode.write_flag = 1;
        open_mode.create_flag = 1;
        // Open the file and write the default gamecoin information
        auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
        if (gamecoin_result.Succeeded()) {
            auto gamecoin = gamecoin_result.MoveFrom();
            gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
            gamecoin->backend->Close();
        }
    }
}
示例#4
0
APGGameMode::APGGameMode() :
    PowerToWinFactor{ 2.f },
	DecayRate{ 0.05f },
	CurrentGameState{ EPGPlayState::EUnknown }
{

	UWorld* World = GetWorld();
	UGameInstance* GameInstance = (World != nullptr) ? World->GetGameInstance() : nullptr;
	UPGGameInstance* PGGameInstance = Cast<UPGGameInstance>(GameInstance);

	if (PGGameInstance && PGGameInstance->PlayerCharacterClass)
	{
		DefaultPawnClass = PGGameInstance->PlayerCharacterClass;
	}
	else
	{
		DefaultPawnClass = ARobotCharacter::StaticClass();
	}
	check(DefaultPawnClass);

	PlayerControllerClass = APGPlayerController::StaticClass();

	static auto HUDBlueprintClassName = TEXT("WidgetBlueprint'/Game/Blueprints/BatteryHUD.BatteryHUD_C'");
	static auto HUDFinder = ConstructorHelpers::FClassFinder<UUserWidget>(HUDBlueprintClassName);
	if (HUDFinder.Succeeded())
	{
		HUDWidgetClass = HUDFinder.Class;
	}
}
示例#5
0
ABatteryPickup::ABatteryPickup()
{
	Power = 750.0f;

	// Assign a static mesh
	static auto StaticMeshName = TEXT("StaticMesh'/Game/Props/Battery/Meshes/SM_Battery_Medium.SM_Battery_Medium'");
	static auto MeshFinder = ConstructorHelpers::FObjectFinder<UStaticMesh>(StaticMeshName);
	if (MeshFinder.Succeeded())
	{
		GetMeshComponent()->SetStaticMesh(MeshFinder.Object);
	}
	GetMeshComponent()->SetSimulatePhysics(true);
}
示例#6
0
void ARobotCharacter::ConfigureMeshAndAnimation()
{
	// Configure the skeletal mesh and animation blueprints
	static auto SkeletalMeshName = TEXT("SkeletalMesh'/Game/Characters/Mannequin/Mesh/SK_Mannequin.SK_Mannequin'");
	static auto SkeletalMeshFinder = ConstructorHelpers::FObjectFinder<USkeletalMesh>(SkeletalMeshName);
	if (SkeletalMeshFinder.Succeeded())
	{
		auto MeshComponent = GetMesh();
		MeshComponent->SetSkeletalMesh(SkeletalMeshFinder.Object);
		MeshComponent->SetRelativeLocation(FVector(0.f, 0.f, -95.f));
		MeshComponent->SetRelativeRotation(FRotator(0.f, 270.f, 0.f));

		ConfigureMeshCollision();

	}

	static auto AnimBlueprintName = TEXT("AnimBlueprint'/Game/Characters/Mannequin/Animations/ThirdPerson_AnimBP.ThirdPerson_AnimBP_C'");
	static auto AnimBlueprintFinder = ConstructorHelpers::FObjectFinder<UAnimBlueprintGeneratedClass>(AnimBlueprintName);
	if (AnimBlueprintFinder.Succeeded())
	{
		GetMesh()->SetAnimInstanceClass(AnimBlueprintFinder.Object);
	}
}
示例#7
0
	void RunThinkPart()
	{
		if (!success_ && !failure_)
			return;

		if (Succeeded() && success_)
		{
			if (CallSuccess())
				return;
		}

		if (!Succeeded() && failure_)
		{
			HandleSecurity sec(ident_, g_pCoreIdent);

			ke::AutoArray<cell_t> data(new cell_t[results_.length()]);
			for (size_t i = 0; i < txn_->entries.length(); i++)
				data[i] = txn_->entries[i].data;

			Handle_t dbh = CreateLocalHandle(g_DBMan.GetDatabaseType(), db_, &sec);
			if (dbh != BAD_HANDLE)
			{
				// Add an extra refcount for the handle.
				db_->AddRef();
			}

			failure_->PushCell(dbh);
			failure_->PushCell(data_);
			failure_->PushCell(txn_->entries.length());
			failure_->PushString(error_.chars());
			failure_->PushCell(failIndex_);
			failure_->PushArray(data, txn_->entries.length());
			failure_->Execute(NULL);

			handlesys->FreeHandle(dbh, &sec);
		}
	}
示例#8
0
void OgreScriptEditor::SetScriptAsset(const AssetPtr &scriptAsset)
{
    asset = scriptAsset;
    assert(asset.lock());
    AssetPtr assetPtr = asset.lock();
    if (!assetPtr)
        LogError("OgreScriptEditor: null asset given.");
    if (assetPtr->Type() != "OgreMaterial" && assetPtr->Type() != "OgreParticle")
        LogWarning("Created OgreScriptEditor for non-supported asset type " + assetPtr->Type() + ".");

    lineEditName->setText((assetPtr?assetPtr->Name():QString()));
    setWindowTitle(tr("OGRE Script Editor:") + (assetPtr?assetPtr->Name():QString()));

    if (assetPtr && !assetPtr->IsLoaded())
    {
        AssetTransferPtr transfer = framework->Asset()->RequestAsset(assetPtr->Name(), assetPtr->Type(), true);
        connect(transfer.get(), SIGNAL(Succeeded(AssetPtr)), this, SLOT(OnAssetTransferSucceeded(AssetPtr)));
        connect(transfer.get(), SIGNAL(Failed(IAssetTransfer *, QString)), SLOT(OnAssetTransferFailed(IAssetTransfer *, QString)));
    }
示例#9
0
bool
lcpp::LispFunction_UserDefined::checkArgumentCount(Ptr<LispObject> pArgs)
{
    if(isNil(pArgs))
    {
        // No args are given, but 1 or more are expected.
        if(m_numArgs > 0)
        {
            ezStringBuilder message;
            message.AppendFormat("Invalid number of arguments: expected %u, got none.", m_numArgs);
            throw exceptions::InvalidInput(message.GetData());
        }
        return false;
    }

    // From here on out we know that pArgs MUST be a cons.
    EZ_ASSERT(pArgs->is<LispCons>(), "pArgs must be a cons if it is not nil!");
    auto pArgList = pArgs.cast<LispCons>();

    // pArgs is not nil, which means it's a cons, so we count the args
    ezUInt32 numElements = 0;
    auto res = count(pArgList, numElements);
    EZ_ASSERT(res.Succeeded(), "pArgList is not a regular list!");

    // pArgs is not nil but we don't expect any arguments
    if(m_numArgs == 0)
    {
        ezStringBuilder message;
        message.AppendFormat("Invalid number of arguments: expected no arguments, got %u", numElements);
        throw exceptions::InvalidInput(message.GetData());
    }

    if(numElements != m_numArgs)
    {
        ezStringBuilder message;
        message.AppendFormat("Invalid number of arguments: Expected %u arguments, got %u", m_numArgs, numElements);
        throw exceptions::InvalidInput(message.GetData());
    }

    return true;
}
bool
CompositorD3D11::VerifyBufferSize()
{
  DXGI_SWAP_CHAIN_DESC swapDesc;
  HRESULT hr;

  hr = mSwapChain->GetDesc(&swapDesc);
  if (Failed(hr)) {
    return false;
  }

  if ((swapDesc.BufferDesc.Width == mSize.width &&
       swapDesc.BufferDesc.Height == mSize.height) ||
      mSize.width <= 0 || mSize.height <= 0) {
    return true;
  }

  if (mDefaultRT) {
    // Make sure the texture, which belongs to the swapchain, is destroyed
    // before resizing the swapchain.
    if (mCurrentRT == mDefaultRT) {
      mCurrentRT = nullptr;
    }
    MOZ_ASSERT(mDefaultRT->hasOneRef());
    mDefaultRT = nullptr;
  }

  if (IsRunningInWindowsMetro()) {
    hr = mSwapChain->ResizeBuffers(2, mSize.width, mSize.height,
                                   DXGI_FORMAT_B8G8R8A8_UNORM,
                                   0);
    mDisableSequenceForNextFrame = true;
  } else {
    hr = mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
                                   DXGI_FORMAT_B8G8R8A8_UNORM,
                                   0);
  }

  return Succeeded(hr);
}
	bool Initialize( HINSTANCE i_hInstance, int i_CmdShow, const char * i_pWindowName, int i_IconID, unsigned int i_WindowWidth, unsigned int i_WindowHeight )
	{
		g_hInstance = i_hInstance;

#ifdef  UNICODE
		const size_t		lenWindowName = 128;
		wchar_t				WindowName[lenWindowName];
		
		MultiByteToWideChar( CP_ACP, 0, ( i_pWindowName ) ? i_pWindowName : "GLib Render", -1, WindowName, lenWindowName );

		LPCTSTR pWindowName = WindowName;
#else
		LPCTSTR pWindowName = ( i_pWindowName ) ? i_pWindowName : "GLib Render";
#endif // UNICODE

		g_hWnd = _CreateWindow( WndProc, g_hInstance, i_IconID, pWindowName, i_WindowWidth, i_WindowHeight );
		if( g_hWnd == nullptr )
		{
			DEBUG_PRINT( "_CreateWindow() failed.\n" );
			return NULL;
		}

		HRESULT hResult = CreateDevice( g_hWnd );
		if( !Succeeded( hResult ) )
		{
			DEBUG_PRINT( "_CreateDevice() failed. HRESULT = %d.\n", hResult );
			return false;
		}

		ShowWindow( g_hWnd, i_CmdShow );

		Input::Initialize();
		Sprites::Initialize();
		
		return true;
	}
示例#12
0
lcpp::Ptr<lcpp::LispObject>
lcpp::Reader::parseAtom(ezStringIterator& input)
{
    // Special case for + and - characters, since the ezEngine parses (+ 1) as +1...
    auto ch = input.GetCharacter();

    if (ch == '+' || ch == '-')
    {
        auto copy = input;

        ezStringBuilder symbol;
        symbol.Append(ch);

        ++copy;
        ch = copy.GetCharacter();
        while(true)
        {
            if(isSeparator(ch) || contains("()", char(ch)) || !copy.IsValid())
            {
                // The + or - characters stand alone, which means they're meant to be a symbol.
                while(input.GetData() != copy.GetData())
                {
                    advance(input);
                }
                return create<LispSymbol>(symbol);
            }
            if (isDigit(ch))
            {
                // The +'s or -'s are sign changers of the digit we just encountered.
                // Abort reading as symbol.
                break;
            }
            symbol.Append(ch);
            ++copy;
            if(copy.IsValid())
            {
                ch = copy.GetCharacter();
            }
        }
    }

    // Try parsing for an integer first, then a number, then a symbol
    const char* lastPos = nullptr;
    LispInteger::Number_t integer;
    auto result = to(input, integer, &lastPos);

    // The string contains a number, but it is a floating point number; reparse.
    if (result.Succeeded())
    {
        LCPP_SCOPE_EXIT{
            while(input.GetData() != lastPos)
            {
                advance(input);
            }
        };

        if(lastPos[0] == '.')
        {
            LispNumber::Number_t number;
            auto result = to(input, number, &lastPos);
            EZ_ASSERT(result.Succeeded(), "An integer of the form '123.' should be parsed as float!");
            return create<LispNumber>(number);
        }

        return create<LispInteger>(integer);
    }
示例#13
0
	void CancelThinkPart()
	{
		if (Succeeded())
			error_ = "Driver is unloading";
		RunThinkPart();
	}