PyObject *py_ue_find_actor_by_label(ue_PyUObject * self, PyObject * args) { ue_py_check(self); char *name; if (!PyArg_ParseTuple(args, "s:find_actor_by_label", &name)) { return NULL; } UWorld *world = ue_get_uworld(self); if (!world) return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); UObject *u_object = nullptr; for (TActorIterator<AActor> Itr(world); Itr; ++Itr) { AActor *u_obj = *Itr; if (u_obj->GetActorLabel().Equals(UTF8_TO_TCHAR(name))) { u_object = u_obj; break; } } if (u_object) { Py_RETURN_UOBJECT(u_object); } Py_RETURN_NONE; }
PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * args) { ue_py_check(self); PyObject *obj; char *name; if (!PyArg_ParseTuple(args, "Os:actor_create_default_subobject", &obj, &name)) { return NULL; } AActor *actor = ue_py_check_type<AActor>(self); if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); UClass *u_class = ue_py_check_type<UClass>(obj); if (!u_class) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); if (!FUObjectThreadContext::Get().TopInitializer()) return PyErr_Format(PyExc_Exception, "CreateDefaultSubobject() can be called only in a constructor"); UObject *ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true); if (!ret_obj) return PyErr_Format(PyExc_Exception, "unable to create component"); Py_RETURN_UOBJECT(ret_obj); }
/** * ** INTERNAL ** * Called by an async task after completing an achievement read. * * @param PlayerId - id of a player we were making read for * @param bReadSuccessfully - whether the read completed successfully */ void FOnlineAchievementsSteam::UpdateAchievementsForUser(const FUniqueNetIdSteam& PlayerId, bool bReadSuccessfully) { // shouldn't get this far if no achievements are configured check(bHaveConfiguredAchievements); ISteamUserStats* SteamUserStatsPtr = SteamUserStats(); check(SteamUserStatsPtr); CSteamID SteamUserId = PlayerId; // new array TArray<FOnlineAchievement> AchievementsForPlayer; const int32 AchNum = Achievements.Num(); for (int32 AchIdx = 0; AchIdx < AchNum; ++AchIdx) { // get the info bool bUnlocked; uint32 UnlockUnixTime; if (!SteamUserStatsPtr->GetAchievementAndUnlockTime(TCHAR_TO_UTF8(*Achievements[AchIdx].Id), &bUnlocked, &UnlockUnixTime)) { UE_LOG_ONLINE(Warning, TEXT("GetAchievementAndUnlockTime() failed for achievement '%s'"), *Achievements[AchIdx].Id); // skip this achievement continue; } FOnlineAchievementSteam NewAch = Achievements[ AchIdx ]; NewAch.bReadFromSteam = true; NewAch.Progress = bUnlocked ? 100.0 : 0.0; // TODO: we may want to support more fine-grained progress based on associated stat and min/max, // although we can only map it one-way (i.e. when reading, but not when writing) NewAch.UnlockTime = FDateTime::FromUnixTimestamp(UnlockUnixTime); NewAch.Title = FText::FromString( UTF8_TO_TCHAR( SteamUserStatsPtr->GetAchievementDisplayAttribute(TCHAR_TO_UTF8(*Achievements[AchIdx].Id), "name") ) ); NewAch.LockedDesc = FText::FromString( UTF8_TO_TCHAR( SteamUserStatsPtr->GetAchievementDisplayAttribute(TCHAR_TO_UTF8(*Achievements[AchIdx].Id), "desc") ) ); NewAch.UnlockedDesc = NewAch.LockedDesc; NewAch.bIsHidden = FCString::Atoi( UTF8_TO_TCHAR( SteamUserStatsPtr->GetAchievementDisplayAttribute(TCHAR_TO_UTF8(*Achievements[AchIdx].Id), "desc") ) ) != 0; UE_LOG_ONLINE(Verbose, TEXT("Read achievement %d: %s"), AchIdx, *NewAch.ToDebugString()); AchievementsForPlayer.Add( NewAch ); // add mapping (should replace any existing one) AchievementDescriptions.Add(NewAch.Id, NewAch); } // should replace any already existing values PlayerAchievements.Add(PlayerId, AchievementsForPlayer); }
void FXmppPresenceJingle::ConvertToPresence(FXmppUserPresence& OutPresence, const buzz::PresenceStatus& InStatus, const FXmppUserJid& InJid) { OutPresence.UserJid = InJid; OutPresence.bIsAvailable = InStatus.available(); OutPresence.StatusStr = UTF8_TO_TCHAR(InStatus.status().c_str()); if (!InStatus.sent_time().empty()) { //@todo samz - fix legacy time usage FString SentTime = UTF8_TO_TCHAR(InStatus.sent_time().c_str()); // convert from "20141115T19:43:17" time to "2014-11-15T19:43:17" Iso8601 compatible format if (!SentTime.Contains(TEXT("-")) && SentTime.Len() >= 8) { SentTime.InsertAt(6, TEXT("-")); SentTime.InsertAt(4, TEXT("-")); } FDateTime::ParseIso8601(*SentTime, OutPresence.SentTime); } OutPresence.Status = EXmppPresenceStatus::Offline; if (InStatus.available()) { switch (InStatus.show()) { case buzz::PresenceStatus::SHOW_ONLINE: OutPresence.Status = EXmppPresenceStatus::Online; break; case buzz::PresenceStatus::SHOW_NONE: case buzz::PresenceStatus::SHOW_OFFLINE: OutPresence.Status = EXmppPresenceStatus::Offline; break; case buzz::PresenceStatus::SHOW_AWAY: OutPresence.Status = EXmppPresenceStatus::Away; break; case buzz::PresenceStatus::SHOW_XA: OutPresence.Status = EXmppPresenceStatus::ExtendedAway; break; case buzz::PresenceStatus::SHOW_DND: OutPresence.Status = EXmppPresenceStatus::DoNotDisturb; break; case buzz::PresenceStatus::SHOW_CHAT: OutPresence.Status = EXmppPresenceStatus::Chat; break; } } InJid.ParseResource(OutPresence.AppId, OutPresence.Platform); }
PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) { ue_py_check(self); char *name; int parent_index; PyObject *py_transform; if (!PyArg_ParseTuple(args, "siO:skeleton_add_bone", &name, &parent_index, &py_transform)) return nullptr; USkeleton *skeleton = ue_py_check_type<USkeleton>(self); if (!skeleton) return PyErr_Format(PyExc_Exception, "uobject is not a USkeleton"); ue_PyFTransform *transform = py_ue_is_ftransform(py_transform); if (!transform) return PyErr_Format(PyExc_Exception, "argument is not a FTransform"); if (skeleton->GetReferenceSkeleton().FindBoneIndex(FName(UTF8_TO_TCHAR(name))) > -1) { return PyErr_Format(PyExc_Exception, "bone %s already exists", name); } #if WITH_EDITOR skeleton->PreEditChange(nullptr); #endif { const FReferenceSkeleton &ref = skeleton->GetReferenceSkeleton(); // horrible hack to modify the skeleton in place FReferenceSkeletonModifier modifier((FReferenceSkeleton &)ref, skeleton); TCHAR *bone_name = UTF8_TO_TCHAR(name); modifier.Add(FMeshBoneInfo(FName(bone_name), FString(bone_name), parent_index), transform->transform); } #if WITH_EDITOR skeleton->PostEditChange(); #endif skeleton->MarkPackageDirty(); return PyLong_FromLong(skeleton->GetReferenceSkeleton().FindBoneIndex(FName(UTF8_TO_TCHAR(name)))); }
void UWebsocketClient_impl::OnMessageReceived(FWebsocketConnectionHandle connectionHandle, FWebsocketClientMessagePtr msg) { if (msg->get_payload().size() > 0) { auto msgStr = msg->get_payload().c_str(); m_IncomingMessages.Add( FString(UTF8_TO_TCHAR(msg->get_payload().c_str())) ); } }
FString FOnlineIdentitySteam::GetPlayerNickname(const FUniqueNetId& UserId) const { if (SteamFriendsPtr != NULL) { const char* PersonaName = SteamFriendsPtr->GetPersonaName(); return FString(UTF8_TO_TCHAR(PersonaName)); } return FString(TEXT("")); }
bool FOnlineUserCloudOculus::ReadUserFile(const FUniqueNetId& UserId, const FString& FileName) { auto LoggedInPlayerId = OculusSubsystem.GetIdentityInterface()->GetUniquePlayerId(0); if (!LoggedInPlayerId.IsValid() || UserId != *LoggedInPlayerId) { UE_LOG_ONLINE(Warning, TEXT("Can only read data for logged in player")); return false; } FString BucketName; FString Key; if (!(FileName.Split(SEPARATOR, &BucketName, &Key))) { BucketName = DefaultBucket; Key = FileName; } OculusSubsystem.AddRequestDelegate( ovr_CloudStorage_Load(TCHAR_TO_UTF8(*BucketName), TCHAR_TO_UTF8(*Key)), FOculusMessageOnCompleteDelegate::CreateLambda([this, BucketName, Key, LoggedInPlayerId, FileName](ovrMessageHandle Message, bool bIsError) { ovrCloudStorageDataHandle response = ovr_Message_GetCloudStorageData(Message); check(BucketName == UTF8_TO_TCHAR(ovr_CloudStorageData_GetBucket(response))); check(Key == UTF8_TO_TCHAR(ovr_CloudStorageData_GetKey(response))); if (bIsError) { UE_LOG_ONLINE(Warning, TEXT("Failed to Load: %s%s%s"), *BucketName, *SEPARATOR, *Key); } else { int64 BlobSize = ovr_CloudStorageData_GetDataSize(response); const void* RawBlob = ovr_CloudStorageData_GetData(response); TArray<uint8> Blob; Blob.Insert(static_cast<const uint8 *>(RawBlob), BlobSize, 0); ReadCache.Add(FileName, MoveTemp(Blob)); } TriggerOnReadUserFileCompleteDelegates(!bIsError, *LoggedInPlayerId, FileName); })); return true; }
/** * Reads the player's nick name from the online service * * @param LocalUserNum the controller number of the associated user * * @return a string containing the players nick name */ FString FOnlineIdentitySteam::GetPlayerNickname(int32 LocalUserNum) const { if (LocalUserNum < MAX_LOCAL_PLAYERS && SteamFriendsPtr != NULL) { const char* PersonaName = SteamFriendsPtr->GetPersonaName(); return FString(UTF8_TO_TCHAR(PersonaName)); } return FString(TEXT("")); }
void FOnlineAsyncTaskSteamEnumerateUserFiles::Tick() { bIsComplete = true; bWasSuccessful = false; if (SteamRemoteStorage()) { CSteamID SteamId(*(uint64*)UserId.GetBytes()); if (SteamUser()->BLoggedOn() && SteamUser()->GetSteamID() == SteamId) { //SteamSubsystem->GetUserCloudInterface()->DumpCloudState(UserId); FScopeLock ScopeLock(&Subsystem->UserCloudDataLock); // Get or create the user metadata entry and empty it FSteamUserCloudData* UserMetadata = Subsystem->GetUserCloudEntry(UserId); UserMetadata->CloudMetadata.Empty(); // Fill in the metadata entries const int32 FileCount = (int32) SteamRemoteStorage()->GetFileCount(); for (int32 FileIdx = 0; FileIdx < FileCount; FileIdx++) { int32 FileSize = 0; const char *FileName = SteamRemoteStorage()->GetFileNameAndSize(FileIdx, &FileSize); new (UserMetadata->CloudMetadata) FCloudFileHeader(UTF8_TO_TCHAR(FileName), UTF8_TO_TCHAR(FileName), int32(FileSize)); //SteamSubsystem->GetUserCloudInterface()->DumpCloudFileState(UserId, FileName); } bWasSuccessful = true; } else { UE_LOG_ONLINE(Warning, TEXT("Can only enumerate cloud files for logged in user.")); } } else { UE_LOG_ONLINE(Warning, TEXT("Steam remote storage API disabled.")); } }
FJavaClassMethod FJavaClassObject::GetClassMethod(const char* MethodName, const char* FuncSig) { JNIEnv* JEnv = FAndroidApplication::GetJavaEnv(); FJavaClassMethod Method; Method.Method = JEnv->GetMethodID(Class, MethodName, FuncSig); Method.Name = MethodName; Method.Signature = FuncSig; // Is method valid? checkf(Method.Method, TEXT("Unable to find Java Method %s with Signature %s"), UTF8_TO_TCHAR(MethodName), UTF8_TO_TCHAR(FuncSig)); return Method; }
/** * Callback function into Steam error messaging system * @param Severity - error level * @param Message - message from Steam */ static void __cdecl SteamworksWarningMessageHook(int Severity, const char *Message) { const TCHAR *MessageType; switch (Severity) { case 0: MessageType = TEXT("message"); break; case 1: MessageType = TEXT("warning"); break; default: MessageType = TEXT("notification"); break; // Unknown severity; new SDK? } UE_LOG_ONLINE(Warning, TEXT("Steamworks SDK %s: %s"), MessageType, UTF8_TO_TCHAR(Message)); }
static PyObject *py_ue_ftab_spawner_entry_set_display_name(ue_PyFTabSpawnerEntry *self, PyObject * args) { char *name; if (!PyArg_ParseTuple(args, "s:set_display_name", &name)) return NULL; self->spawner_entry->SetDisplayName(FText::FromString(UTF8_TO_TCHAR(name))); Py_INCREF(self); return (PyObject *)self; }
static PyObject *py_ue_ftab_spawner_entry_set_tooltip_text(ue_PyFTabSpawnerEntry *self, PyObject * args) { char *tooltip; if (!PyArg_ParseTuple(args, "s:set_tooltip_text", &tooltip)) return NULL; self->spawner_entry->SetTooltipText(FText::FromString(UTF8_TO_TCHAR(tooltip))); Py_INCREF(self); return (PyObject *)self; }
static int py_ue_edgraphpin_set_default_text_value(ue_PyEdGraphPin *self, PyObject *value, void *closure) { if (value && PyUnicode_Check(value)) { char *str = PyUnicode_AsUTF8(value); self->pin->DefaultTextValue = FText::FromString(UTF8_TO_TCHAR(str)); return 0; } PyErr_SetString(PyExc_TypeError, "value is not a string"); return -1; }
void UnFbx::FFbxImporter::FillAndVerifyBoneNames(USkeleton* Skeleton, TArray<FbxNode*>& SortedLinks, TArray<FName>& OutRawBoneNames, FString Filename) { int32 TrackNum = SortedLinks.Num(); OutRawBoneNames.AddUninitialized(TrackNum); // copy to the data for (int32 BoneIndex = 0; BoneIndex < TrackNum; BoneIndex++) { OutRawBoneNames[BoneIndex] = FName(*FSkeletalMeshImportData::FixupBoneName( UTF8_TO_TCHAR(MakeName(SortedLinks[BoneIndex]->GetName())) )); } const FReferenceSkeleton& RefSkeleton = Skeleton->GetReferenceSkeleton(); const USkeleton::FBoneTreeType& BoneTree = Skeleton->GetBoneTree(); // make sure at least root bone matches if ( OutRawBoneNames[0] != RefSkeleton.GetBoneName(0) ) { AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("FBXImport_RootMatchFail", "Root bone name does not match (FBX: {0} | Skeleton: {1})"), FText::FromName(OutRawBoneNames[0]), FText::FromName(RefSkeleton.GetBoneName(0)))), FFbxErrors::Animation_RootTrackMismatch); return; } // ensure there are no duplicated names for (int32 I = 0; I < TrackNum; I++) { for ( int32 J = I+1; J < TrackNum; J++ ) { if (OutRawBoneNames[I] == OutRawBoneNames[J]) { FString RawBoneName = OutRawBoneNames[J].ToString(); AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Warning, FText::Format(LOCTEXT("FBXImport_DupeBone", "Could not import {0}.\nDuplicate bone name found ('{1}'). Each bone must have a unique name."), FText::FromString(Filename), FText::FromString(RawBoneName))), FFbxErrors::Animation_DuplicatedBone); } } } // make sure all bone names are included, if not warn user FString BoneNames; for (int32 I = 0; I < TrackNum; ++I) { FName RawBoneName = OutRawBoneNames[I]; if ( RefSkeleton.FindBoneIndex(RawBoneName) == INDEX_NONE) { BoneNames += RawBoneName.ToString(); BoneNames += TEXT(" \n"); } } if (BoneNames.IsEmpty() == false) { // warn user AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Warning, FText::Format(LOCTEXT("FBXImport_MissingBone", "The following bones exist in the imported animation, but not in the Skeleton asset {0}. Any animation on these bones will not be imported: \n\n {1}"), FText::FromString(Skeleton->GetName()), FText::FromString(BoneNames) )), FFbxErrors::Animation_MissingBones); } }
static PyObject *py_ue_swidget_set_tooltip_text(ue_PySWidget *self, PyObject * args) { char *text; if (!PyArg_ParseTuple(args, "s:set_tooltip_text", &text)) { return NULL; } self->Widget->SetToolTipText(FText::FromString(UTF8_TO_TCHAR(text))); Py_RETURN_SLATE_SELF; }
bool FOnlineUserCloudOculus::WriteUserFile(const FUniqueNetId& UserId, const FString& FileName, TArray<uint8>& FileContents) { auto LoggedInPlayerId = OculusSubsystem.GetIdentityInterface()->GetUniquePlayerId(0); if (!LoggedInPlayerId.IsValid() || UserId != *LoggedInPlayerId) { UE_LOG_ONLINE(Warning, TEXT("Can only save data for logged in player")); return false; } FString BucketName; FString Key; if (!(FileName.Split(SEPARATOR, &BucketName, &Key))) { BucketName = DefaultBucket; Key = FileName; } // store the save data in a temporary buffer until the Oculus Platform threadpool can process the request TArray<uint8> *TmpBuffer = new TArray<uint8>(MoveTemp(FileContents)); auto DelegateLambda = FOculusMessageOnCompleteDelegate::CreateLambda([this, BucketName, Key, LoggedInPlayerId, FileName, TmpBuffer](ovrMessageHandle Message, bool bIsError) { check(BucketName == UTF8_TO_TCHAR(ovr_CloudStorageUpdateResponse_GetBucket(ovr_Message_GetCloudStorageUpdateResponse(Message)))); check(Key == UTF8_TO_TCHAR(ovr_CloudStorageUpdateResponse_GetKey(ovr_Message_GetCloudStorageUpdateResponse(Message)))); if (bIsError) { UE_LOG_ONLINE(Warning, TEXT("Failed to Save: %s%s%s"), *BucketName, *SEPARATOR, *Key); } delete TmpBuffer; TriggerOnWriteUserFileCompleteDelegates(!bIsError, *LoggedInPlayerId, FileName); }); OculusSubsystem.AddRequestDelegate( ovr_CloudStorage_Save(TCHAR_TO_UTF8(*BucketName), TCHAR_TO_UTF8(*Key), TmpBuffer->GetData(), TmpBuffer->Num(), 0, nullptr), std::move(DelegateLambda)); return true; }
void CloudyWebAPIImpl::GetSaveFileUrl(int32 GameId, FString Username, int32 PlayerControllerId) { CURLcode ret; CURL *hnd; struct curl_slist *slist1; slist1 = NULL; std::string readBuffer; // Make authorization token header FString AuthHeader = "Authorization: Token " + Token; std::string AuthHeaderCString(TCHAR_TO_UTF8(*AuthHeader)); // Make URL for GET request FString SaveFileUrl = BaseUrl + SaveDataUrl + "?user="******"&game=" + FString::FromInt(GameId); std::string SaveFileUrlCString(TCHAR_TO_UTF8(*SaveFileUrl)); MakeRequest(SaveFileUrl, "GET"); slist1 = curl_slist_append(slist1, AuthHeaderCString.c_str()); hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_URL, SaveFileUrlCString.c_str()); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); /* Set up string to write response into */ curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &readBuffer); // Make the GET request ret = curl_easy_perform(hnd); // Cleanup curl_easy_cleanup(hnd); hnd = NULL; curl_slist_free_all(slist1); slist1 = NULL; UE_LOG(CloudyWebAPILog, Warning, TEXT("Response data: %s"), UTF8_TO_TCHAR(readBuffer.c_str())); ReadAndStoreSaveFileURL(UTF8_TO_TCHAR(readBuffer.c_str()), PlayerControllerId); }
PyObject *py_ue_get_actor_components_by_type(ue_PyUObject * self, PyObject * args) { ue_py_check(self); PyObject *obj; if (!PyArg_ParseTuple(args, "O:get_actor_components_by_type", &obj)) { return NULL; } ue_PyUObject *py_obj = nullptr; if (ue_is_pyuobject(obj)) { py_obj = (ue_PyUObject *)obj; } // shortcut for finding class by string else if (PyUnicodeOrString_Check(obj)) { char *class_name = PyUnicode_AsUTF8(obj); UClass *u_class = FindObject<UClass>(ANY_PACKAGE, UTF8_TO_TCHAR(class_name)); if (u_class) { py_obj = ue_get_python_uobject(u_class); } } if (!py_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); if (!py_obj->ue_object->IsA<UClass>()) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); PyObject *components = PyList_New(0); for (UActorComponent *component : actor->GetComponentsByClass((UClass *)py_obj->ue_object)) { ue_PyUObject *item = ue_get_python_uobject(component); if (item) PyList_Append(components, (PyObject *)item); } return components; }
static PyObject *py_ue_ihttp_request_set_verb(ue_PyIHttpRequest *self, PyObject * args) { char *verb; if (!PyArg_ParseTuple(args, "s:set_verb", &verb)) { return NULL; } self->http_request->SetVerb(UTF8_TO_TCHAR(verb)); Py_INCREF(Py_None); return Py_None; }
static int ue_py_ihttp_request_init(ue_PyIHttpRequest *self, PyObject *args, PyObject *kwargs) { char *verb = nullptr; char* url = nullptr; if (!PyArg_ParseTuple(args, "|ss:__init__", &verb, &url)) { return -1; } new(&self->http_request) TSharedRef<IHttpRequest>(FHttpModule::Get().CreateRequest()); self->py_dict = PyDict_New(); if (verb) { self->http_request->SetVerb(UTF8_TO_TCHAR(verb)); } if (url) { self->http_request->SetURL(UTF8_TO_TCHAR(url)); } self->base.http_base = &self->http_request.Get(); return 0; }
static PyObject *py_ue_ihttp_request_set_url(ue_PyIHttpRequest *self, PyObject * args) { char *url; if (!PyArg_ParseTuple(args, "s:set_url", &url)) { return NULL; } self->http_request->SetURL(UTF8_TO_TCHAR(url)); Py_INCREF(Py_None); return Py_None; }
FString FJavaClassObject::CallMethod<FString>(FJavaClassMethod Method, ...) { JNIEnv* JEnv = FAndroidApplication::GetJavaEnv(); va_list Params; va_start(Params, Method); jstring RetVal = static_cast<jstring>( JEnv->CallObjectMethodV(Object, Method.Method, Params)); va_end(Params); VerifyException(); const char * UTFString = JEnv->GetStringUTFChars(RetVal, nullptr); FString Result(UTF8_TO_TCHAR(UTFString)); JEnv->ReleaseStringUTFChars(RetVal, UTFString); return Result; }
void USpineAtlasAssetFactory::LoadAtlas (USpineAtlasAsset* Asset, const FString& CurrentSourcePath, const FString& LongPackagePath) { spAtlas* atlas = Asset->GetAtlas(true); Asset->atlasPages.Empty(); const FString targetTexturePath = LongPackagePath / TEXT("Textures"); spAtlasPage* page = atlas->pages; while (page) { const FString sourceTextureFilename = FPaths::Combine(*CurrentSourcePath, UTF8_TO_TCHAR(page->name)); UTexture2D* texture = resolveTexture(Asset, sourceTextureFilename, targetTexturePath); page = page->next; Asset->atlasPages.Add(texture); } }
static PyObject *py_ue_uscriptstruct_get_field_array_dim(ue_PyUScriptStruct *self, PyObject * args) { char *name; if (!PyArg_ParseTuple(args, "s:get_field_array_dim", &name)) { return nullptr; } UProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", name); return PyLong_FromLongLong(u_property->ArrayDim); }
PyObject *py_ue_bind_key(ue_PyUObject *self, PyObject * args) { ue_py_check(self); char *key_name; int key; PyObject *py_callable; if (!PyArg_ParseTuple(args, "siO:bind_key", &key_name, &key, &py_callable)) { return NULL; } if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "object is not a callable"); } UInputComponent *input = nullptr; if (self->ue_object->IsA<AActor>()) { input = ((AActor *)self->ue_object)->InputComponent; } else if (self->ue_object->IsA<UActorComponent>()) { UActorComponent *component = (UActorComponent *)self->ue_object; if (!component->GetOwner()) return PyErr_Format(PyExc_Exception, "component is still not mapped to an Actor"); input = component->GetOwner()->InputComponent; } else { return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); } if (!input) { return PyErr_Format(PyExc_Exception, "no input manager for this uobject"); } UPythonDelegate *py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(input, py_callable, nullptr); FInputKeyBinding input_key_binding(FKey(UTF8_TO_TCHAR(key_name)), (const EInputEvent)key); input_key_binding.KeyDelegate.BindDelegate(py_delegate, &UPythonDelegate::PyInputHandler); input->KeyBindings.Add(input_key_binding); Py_RETURN_NONE; }
spSkeletonData* USpineSkeletonDataAsset::GetSkeletonData (spAtlas* Atlas, bool ForceReload) { if (!skeletonData || ForceReload) { if (skeletonData) { spSkeletonData_dispose(skeletonData); skeletonData = nullptr; } int dataLen = rawData.Num(); if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) { spSkeletonJson* json = spSkeletonJson_create(Atlas); this->skeletonData = spSkeletonJson_readSkeletonData(json, (const char*)rawData.GetData()); if (!skeletonData) { #if WITH_EDITORONLY_DATA FMessageDialog::Debugf(FText::FromString(UTF8_TO_TCHAR(json->error))); #endif UE_LOG(SpineLog, Error, TEXT("Couldn't load skeleton data and atlas: %s"), UTF8_TO_TCHAR(json->error)); } spSkeletonJson_dispose(json); } else { spSkeletonBinary* binary = spSkeletonBinary_create(Atlas); this->skeletonData = spSkeletonBinary_readSkeletonData(binary, (const unsigned char*)rawData.GetData(), (int)rawData.Num()); if (!skeletonData) { #if WITH_EDITORONLY_DATA FMessageDialog::Debugf(FText::FromString(UTF8_TO_TCHAR(binary->error))); #endif UE_LOG(SpineLog, Error, TEXT("Couldn't load skeleton data and atlas: %s"), UTF8_TO_TCHAR(binary->error)); } spSkeletonBinary_dispose(binary); } if (animationStateData) { spAnimationStateData_dispose(animationStateData); GetAnimationStateData(Atlas); } lastAtlas = Atlas; } return this->skeletonData; }
extern "C" void Java_com_epicgames_ue4_GooglePlayStoreHelper_nativePurchaseComplete(JNIEnv* jenv, jobject thiz, jboolean bSuccess, jstring productId, jstring receiptData) { FString ProductId, ReceiptData; if (bSuccess) { const char* charsId = jenv->GetStringUTFChars(productId, 0); ProductId = FString(UTF8_TO_TCHAR(charsId)); jenv->ReleaseStringUTFChars(productId, charsId); const char* charsReceipt = jenv->GetStringUTFChars(receiptData, 0); ReceiptData = FString(UTF8_TO_TCHAR(charsReceipt)); jenv->ReleaseStringUTFChars(receiptData, charsReceipt); } FPlatformMisc::LowLevelOutputDebugStringf(TEXT("1... ProductId: %s, ReceiptData: %s\n"), *ProductId, *ReceiptData ); DECLARE_CYCLE_STAT(TEXT("FSimpleDelegateGraphTask.ProcessIapResult"), STAT_FSimpleDelegateGraphTask_ProcessIapResult, STATGROUP_TaskGraphTasks); FSimpleDelegateGraphTask::CreateAndDispatchWhenReady( FSimpleDelegateGraphTask::FDelegate::CreateLambda([=](){ FPlatformMisc::LowLevelOutputDebugStringf(TEXT("In-App Purchase was completed %s\n"), bSuccess ? TEXT("successfully") : TEXT("unsuccessfully")); if (IOnlineSubsystem* const OnlineSub = IOnlineSubsystem::Get()) { FPlatformMisc::LowLevelOutputDebugStringf(TEXT("2... ProductId: %s, ReceiptData: %s\n"), *ProductId, *ReceiptData); // call store implementation to process query results. if (FOnlineStoreGooglePlay* StoreInterface = (FOnlineStoreGooglePlay*)OnlineSub->GetStoreInterface().Get()) { StoreInterface->ProcessPurchaseResult(bSuccess, ProductId, ReceiptData); } } }), GET_STATID(STAT_FSimpleDelegateGraphTask_ProcessIapResult), nullptr, ENamedThreads::GameThread ); }
PyObject *py_ue_add_anim_composite_section(ue_PyUObject * self, PyObject * args) { ue_py_check(self); char *name; float time; if (!PyArg_ParseTuple(args, "sf:add_anim_composite_section", &name, &time)) return nullptr; UAnimMontage *anim = ue_py_check_type<UAnimMontage>(self); if (!anim) return PyErr_Format(PyExc_Exception, "UObject is not a UAnimMontage."); return PyLong_FromLong(anim->AddAnimCompositeSection(FName(UTF8_TO_TCHAR(name)), time)); }