public void SaveImage(Texture2D image, string name, ImageFormat format = ImageFormat.JPG, Action <string> callback = null) { callback = callback == null ? null : RuntimeHelper.ToMainThread(callback); if (image == null) { if (callback != null) { callback("Can't save a null image."); } return; } byte[] rawImage = TextureUtilities.EncodeAsByteArray(image, format); NSData data = NSData.DataWithBytesNoCopy(rawImage, (uint)rawImage.Length); UIImage uiImage = UIImage.ImageWithData(data); UIFunctions.UIImageWriteToSavedPhotosAlbum(uiImage, (savedImage, nsError) => { if (callback != null) { callback(nsError != null ? nsError.LocalizedDescription : null); } }); }
public void LoadImage(MediaResult result, Action <string, Texture2D> callback, int maxSize = -1) { Util.NullArgumentTest(result); Util.NullArgumentTest(callback); callback = RuntimeHelper.ToMainThread(callback); if (string.IsNullOrEmpty(result.Uri)) { callback("Invalid image URL.", null); return; } var uiImage = LoadImageAtPath(result.Uri, maxSize); if (uiImage == null) { callback("The image couldn't be loaded.", null); return; } Texture2D image = TextureUtilities.Decode(UIFunctions.UIImagePNGRepresentation(uiImage.NormalizedImage).ToBytes()); image = Resize(image, maxSize); callback(null, image); }
void Start() { uiFunctions = GameObject.FindGameObjectWithTag("GameManager").GetComponent <UIFunctions> (); scoreText = GameObject.Find("ScoreText"); //restartButton = GameObject.Find ("RestartButton"); //homeButton = GameObject.Find ("HomeButton"); myRB = GetComponent <Rigidbody> (); }
private void Language_OnCheckedChanged(object sender, CheckedChangedEventArgs e) { if (e.Value && sender is RadioButton button) { UIFunctions.SetLocale((string)button.Value); SetupButton.Text = AppResources.SetupButton; SelectLanguageLabel.Text = AppResources.SelectLanguage; } }
void Start() { myRB = GetComponent <Rigidbody> (); uiFunctions = GameObject.FindGameObjectWithTag("GameManager").GetComponent <UIFunctions> (); Physics.gravity = gravity; lastPos = transform.position; vel = Vector3.zero; }
void Awake() { async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); ui = FindObjectOfType <UIFunctions>(); if (gm == null) { gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); } }
private void ShowButtonByTag(int buttonTag) { // TODO: gdTop should be replaced on this Button element = UIFunctions.FindControlByTag <Button>(gdTop, buttonTag.ToString()); if (element != null) { element.Visibility = Visibility.Visible; } }
public void Exec(float axis) { if (control == false) { return; } currentValue += (axis == -1) ? -1 : 1; currentValue = UIFunctions.RevisionValue(currentValue, max); }
private void HideButtonByTag(int buttonTag) { // TODO: gdTop should be replaced on this var z = UIFunctions.FindControl <WrapPanel>(this.gdTop); Button element = UIFunctions.FindControlByTag <Button>(z, buttonTag.ToString()); if (element != null) { element.Visibility = Visibility.Collapsed; } }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } }
// Update is called once per frame void Update() { timer -= Time.deltaTime; if (timer < 0) { currentNum++; currentNum = UIFunctions.RevisionValue(currentNum, textures.Length - 1, UIFunctions.RevisionMode.Loop); rawImage.texture = textures[currentNum]; timer = interval; } }
public static void Postfix(UIFunctions __instance) { Debug.Log("UIFunctions_Awake"); if (__instance.levelloadmanager.nationSprites.Length == 4) { nationsPatch.nations = Traverse.Create(__instance.levelloadmanager).Field("nations").GetValue <string[]>().ToList <string>(); nationsPatch.nationSprites = Traverse.Create(__instance.levelloadmanager).Field("nationSprites").GetValue <Sprite[]>().ToList <Sprite>(); nationsPatch.LoadNewFlags(); Traverse.Create(UIFunctions.globaluifunctions.levelloadmanager).Field("nations").SetValue(nationsPatch.nations.ToArray()); Traverse.Create(UIFunctions.globaluifunctions.levelloadmanager).Field("nationSprites").SetValue(nationsPatch.nationSprites.ToArray()); Debug.Log("\tNations Patched"); } }
// ------------入力-------------- public void OnSelect(InputValue value) { var a = value.Get <Vector2> (); if (a.x != 0) { currentSelect += (a.x == -1) ? -1 : 1; currentSelect = UIFunctions.RevisionValue(currentSelect, stars.Length - 1); UpdateStarUI(currentSelect); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; } DontDestroyOnLoad(this); }
// -------------------入力------------------- public void OnSelect(InputValue value) { var a = value.Get <Vector2> (); if (popup.gameObject.activeSelf == true) { if (a.x != 0) { popup.CurrentSelect += (a.x == -1) ? -1 : 1; popup.CurrentSelect = UIFunctions.RevisionValue(popup.CurrentSelect, 2); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); popup.UpdateUI(); } } }
// ----------------入力-------------------- public void OnSelect(InputValue value) { var a = value.Get <Vector2> (); if (a.y != 0) { if (showMenu == true) { currentSelect += (a.y == -1) ? 1 : -1; currentSelect = UIFunctions.RevisionValue(currentSelect, menus.Length - 1); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); UpdateUI(); } } }
// -------------入力---------------------- public void OnSelect(InputValue value) { var a = value.Get <Vector2> (); if (a.y != 0) { currentSelect += (a.y == -1) ? 1 : -1; currentSelect = UIFunctions.RevisionValue(currentSelect, sliders.Length - 1); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); ChangeItem(); } else if (a.x != 0) { sliders[currentSelect].Exec(a.x); SoundManager.Instance.PlaySE(SoundManager.SE.Gauge); UpdateSetting(); } }
public void WeatherComparator() { try { //webpage to fetch temperature Dictionary <string, string> prop = Utility.readProperties(); Temperature tempUI = new Temperature(); tempUI.setCity(prop["CityName"]); UIFunctions uifunc = new UIFunctions(driver); uifunc.Launch(prop); uifunc.navigateToWeatherPage(); uifunc.explicitWait(); uifunc.searchCity(prop); float uiTemp = uifunc.readCityWeatherDetails(prop); tempUI.setTemp(uiTemp); uifunc.closeDriver(); //REST API to fetch temperature Temperature tempAPI = new Temperature(); tempAPI.setCity(prop["CityName"]); //Create Client URL connection RestAPIFunctions apifunc = new RestAPIFunctions(); apifunc.passClient(prop); //Create REST API Request apifunc.createRequest(prop); //Fetch response float apiTemp = apifunc.fetchResponse(prop); tempAPI.setTemp(apiTemp); Utility utilCompare = new Utility(); Dictionary <string, string> prop2 = Utility.variance(); utilCompare.Comparator(tempAPI.getTemp(), tempUI.getTemp(), prop2); } catch (Exception ex) { } }
// -------------------入力------------------- public void OnSelect(InputValue value) { var a = value.Get <Vector2> (); if (exitPopup.gameObject.activeSelf == true) { if (a.x != 0) { exitPopup.CurrentSelect += (a.x == -1) ? -1 : 1; exitPopup.CurrentSelect = UIFunctions.RevisionValue(exitPopup.CurrentSelect, 2); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); exitPopup.UpdateUI(); } } else if (a.y != 0) { currentSelect += (a.y == -1) ? 1 : -1; currentSelect = UIFunctions.RevisionValue(currentSelect, screens.Length - 1); SoundManager.Instance.PlaySE(SoundManager.SE.Cursor); UpdateMenuUI(currentSelect); } }
// Use this for initialization void Start() { perlinshake = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PerlinShake>(); UIFunction = GameObject.FindGameObjectWithTag("UIManager").GetComponent <UIFunctions>(); }
void Awake() { UIController = FindObjectOfType <UIFunctions>(); }
private void Awake() { _currentAmount = 100f; _uiFunctions = FindObjectOfType <UIFunctions>(); EndGamePanel.SetActive(value: false); }
/// <summary> /// Creates the UI for an album. /// </summary> /// <param name="album">Album</param> private void CreateAlbumUI(Album album) { ObservableCollection <SongTable> albumSongsList = new ObservableCollection <SongTable>(); album.FetchSongs(() => { albumSongsList.Clear(); foreach (Song albumSong in album.Songs) { albumSongsList.Add(new SongTable { Album = album, Song = albumSong, Title = albumSong.Title, Genre = albumSong.Genre, Duration = albumSong.Duration, ArtistsNames = albumSong.GetArtistsNames() }); } }, (errorResponse) => { MessageBox.Show(errorResponse.Message); }, () => { MessageBox.Show("Ocurrió un error al cargar el artista."); }); StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; StackPanel albumHeaderStackPanel = new StackPanel(); albumHeaderStackPanel.Orientation = Orientation.Horizontal; Image albumImage = new Image(); albumImage.Source = album.FetchImage(); albumImage.Margin = new Thickness(35, 30, 0, 0); albumImage.Width = 110; albumImage.Height = 110; albumHeaderStackPanel.Children.Add(albumImage); StackPanel albumDataStackPanel = new StackPanel(); albumDataStackPanel.Margin = new Thickness(12, 35, 0, 0); albumDataStackPanel.Orientation = Orientation.Vertical; TextBlock albumTypeTextBlock = new TextBlock(); albumTypeTextBlock.Text = album.Type; albumTypeTextBlock.FontSize = 10; albumTypeTextBlock.FontWeight = FontWeights.Bold; albumDataStackPanel.Children.Add(albumTypeTextBlock); TextBlock albumNameTextBlock = new TextBlock(); albumNameTextBlock.Text = album.Name; albumNameTextBlock.FontSize = 20; albumNameTextBlock.FontWeight = FontWeights.Bold; albumDataStackPanel.Children.Add(albumNameTextBlock); TextBlock albumLaunchYearTextBlock = new TextBlock(); albumLaunchYearTextBlock.Text = album.LaunchYear.ToString(); albumLaunchYearTextBlock.FontSize = 12; albumDataStackPanel.Children.Add(albumLaunchYearTextBlock); TextBlock albumDiscographyTextBlock = new TextBlock(); albumDiscographyTextBlock.Text = album.Discography; albumDiscographyTextBlock.FontSize = 11; albumDataStackPanel.Children.Add(albumDiscographyTextBlock); albumHeaderStackPanel.Children.Add(albumDataStackPanel); stackPanel.Children.Add(albumHeaderStackPanel); DataGrid albumSongsDataGrid = new DataGrid { Margin = new Thickness(34, 0, 34, 0), ItemsSource = albumSongsList, CanUserSortColumns = true, CanUserAddRows = false, CanUserReorderColumns = false, AutoGenerateColumns = false, IsReadOnly = true, SelectionMode = DataGridSelectionMode.Single }; albumSongsDataGrid.MouseDoubleClick += (sender, e) => { UIFunctions.SongTable_OnDoubleClick(sender, e); Session.HistoryIndex = Session.SongsIdPlayHistory.Count - 1; Session.SongsIdSongList.Clear(); for (int i = albumSongsDataGrid.SelectedIndex + 1; i < albumSongsList.Count; i++) { Session.SongsIdSongList.Add(albumSongsList.ElementAt(i).Song.SongId); } }; albumSongsDataGrid.SelectionChanged += (sender, e) => { foreach (var dataGrid in albumSongsDataGrids) { if (dataGrid == sender) { continue; } dataGrid.SelectedIndex = -1; } if (e.AddedItems.Count > 0) { selectedSong = ((SongTable)e.AddedItems[0]).Song; } }; Dictionary <string, string> columns = new Dictionary <string, string>() { { "Title", "Title" }, { "ArtistsNames", "Artista" }, { "Genre", "Género" }, { "Duration", "Duración" } }; foreach (var column in columns) { albumSongsDataGrid.Columns.Add(new System.Windows.Controls.DataGridTextColumn { Binding = new Binding(column.Key), Header = column.Value }); } albumSongsDataGrids.Add(albumSongsDataGrid); stackPanel.Children.Add(albumSongsDataGrid); albumsStackPanel.Children.Add(stackPanel); }
public async Task <ScriptInstallStatus> InstallScript(ContentType contentType, FGORegion region, List <string> installPaths, string baseInstallPath, int installId, string assetStorageCheck = null, ObservableCollection <InstallerPage.TranslationGUIObject> translationGuiObjects = null) { _cm.ClearCache(); var gui = translationGuiObjects != null; var guiObject = gui ? translationGuiObjects.First(w => w.BundleID == installId) : null; if (guiObject != null) { guiObject.Status = UIFunctions.GetResourceString("InstallingFetchingHandshake"); guiObject.ButtonInstallText = UIFunctions.GetResourceString("InstallingText"); guiObject.TextColor = Color.Chocolate; } // fetch new translation list to ensure it is up to date var restful = new RestfulAPI(); var translationList = await restful.GetHandshakeApiResponse(region, assetStorageCheck); if (!translationList.IsSuccessful || translationList.Data.Status != 200) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = String.Format(UIFunctions.GetResourceString("InstallHandshakeFailure"), translationList.StatusCode, translationList.Data?.Message) }); } if (assetStorageCheck != null) { switch (translationList.Data.Response.AssetStatus) { case HandshakeAssetStatus.UpdateRequired: return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = String.Format("AssetStorage.txt out of date, skipping update.") }); default: break; } } // download required scripts var groupToInstall = translationList.Data.Response.Translations.FirstOrDefault(w => w.Group == installId); if (groupToInstall?.Scripts == null) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = String.Format(UIFunctions.GetResourceString("InstallMissingScriptFailure"), installId) }); } if (!gui && groupToInstall.Hidden) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = String.Format(UIFunctions.GetResourceString("InstallHiddenScriptFailure"), installId) }); } var totalScripts = groupToInstall.Scripts.Count; if (guiObject != null) { guiObject.Status = String.Format(UIFunctions.GetResourceString("InstallDownloadingScripts"), 1, totalScripts); } ConcurrentDictionary <string, byte[]> scriptDictionary = new ConcurrentDictionary <string, byte[]>(); object lockObj = new Object(); try { await groupToInstall.Scripts.ParallelForEachAsync(async script => { var name = script.Key; var downloadUrl = script.Value.DownloadURL; var downloadResponse = await restful.GetScript(downloadUrl); var downloadedScript = downloadResponse.RawBytes; if (!downloadResponse.IsSuccessful) { throw new EndEarlyException(String.Format(UIFunctions.GetResourceString("InstallScriptDownloadFailure"), installId, downloadUrl, downloadResponse.ErrorMessage)); } if (downloadedScript == null) { throw new EndEarlyException(String.Format(UIFunctions.GetResourceString("InstallEmptyFileFailure"), installId, downloadUrl)); } var scriptSha = ScriptUtil.Sha1(downloadedScript); if (scriptSha != script.Value.TranslatedSHA1) { throw new EndEarlyException(String.Format(UIFunctions.GetResourceString("InstallChecksumFailure"), installId, downloadedScript.Length, downloadUrl)); } scriptDictionary.TryAdd(name, downloadedScript); lock (lockObj) { if (guiObject != null) { guiObject.Status = String.Format(UIFunctions.GetResourceString("InstallDownloadingScripts"), Math.Min(scriptDictionary.Count, totalScripts), totalScripts); } } }, maxDegreeOfParallelism : 4); } catch (EndEarlyException ex) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = ex.ToString() }); } if (guiObject != null) { guiObject.Status = String.Format(UIFunctions.GetResourceString("InstallDownloadNewAssetStorage")); } Dictionary <string, byte[]> newAssetStorages = new Dictionary <string, byte[]>(); // get new assetstorage.txt foreach (var game in installPaths) { var assetStoragePath = contentType != ContentType.DirectAccess ? $"data/{game}/files/data/d713/{InstallerPage._assetList}" : $"{game}/files/data/d713/{InstallerPage._assetList}"; var fileContents = await _cm.GetFileContents(contentType, assetStoragePath, baseInstallPath); if (!fileContents.Successful || fileContents.FileContents.Length == 0) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = String.Format(UIFunctions.GetResourceString("InstallEmptyAssetStorage"), installId, assetStoragePath, fileContents.Error) }); } // remove bom var base64 = ""; await using var inputStream = new MemoryStream(fileContents.FileContents); using (var reader = new StreamReader(inputStream, Encoding.ASCII)) { base64 = await reader.ReadToEndAsync(); } var newAssetList = await restful.SendAssetList(base64, installId, region); if (!newAssetList.IsSuccessful) { return(new ScriptInstallStatus() { IsSuccessful = false, ErrorMessage = string.Format(UIFunctions.GetResourceString("InstallAssetStorageAPIFailure"), installId, newAssetList.StatusCode, newAssetList.Data?.Message) }); } // add bom await using var outputStream = new MemoryStream(); await using (var writer = new StreamWriter(outputStream, Encoding.ASCII)) { await writer.WriteAsync(newAssetList.Data.Response["data"]); } newAssetStorages.Add(assetStoragePath, outputStream.ToArray()); } // prepare files Dictionary <string, byte[]> filesToWrite = newAssetStorages; foreach (var game in installPaths) { foreach (var asset in scriptDictionary) { var assetInstallPath = contentType != ContentType.DirectAccess ? $"data/{game}/files/data/d713/{asset.Key}" : $"{game}/files/data/d713/{asset.Key}"; filesToWrite.Add(assetInstallPath, asset.Value); } } // write files int j = 1; int tot = filesToWrite.Count; foreach (var file in filesToWrite) { if (file.Key.EndsWith(".bin")) { await _cm.RemoveFileIfExists(contentType, file.Key, baseInstallPath); } } _cm.ClearCache(); foreach (var file in filesToWrite) { if (guiObject != null) { guiObject.Status = String.Format(UIFunctions.GetResourceString("InstallWriteFile"), j, tot); } await _cm.WriteFileContents(contentType, file.Key, baseInstallPath, file.Value); j += 1; } if (guiObject != null) { guiObject.Status = String.Format(UIFunctions.GetResourceString("InstallFinished")); guiObject.TextColor = Color.LimeGreen; } Preferences.Set($"InstalledScript_{region}", JsonConvert.SerializeObject(groupToInstall)); return(new ScriptInstallStatus() { IsSuccessful = true, ErrorMessage = "" }); }
protected override async void OnActivityResult(int requestCode, Result resultCode, Intent intent) { base.OnActivityResult(requestCode, resultCode, intent); Log.Info("TranslateFGO", $"ActivityResult Code: {resultCode}, Result: {resultCode}, Data: {intent?.DataString}"); if (resultCode == Result.Ok && requestCode == (int)RequestCodes.FolderIntentRequestCode) { var service = new ContentManager(); var uri = intent.Data; var selectedFolder = DocumentsContract.GetTreeDocumentId(uri); if (selectedFolder == null || !selectedFolder.EndsWith("Android")) { var folderSplit = selectedFolder?.Split(":").Last(); var infoText = UIFunctions.GetResourceString("AndroidFolderNotSelected"); var errorMessage = String.Format(infoText, !string.IsNullOrEmpty(folderSplit) ? folderSplit : "none"); Toast.MakeText(this.Context, errorMessage, ToastLength.Long)?.Show(); return; } service.ClearCache(); var dataChildren = service.GetFolderChildren(uri, "data/"); // Get list of children to find FGO folders if (dataChildren.Count == 0) { var infoText = UIFunctions.GetResourceString("AndroidDataFolderEmpty"); Toast.MakeText(this.Context, infoText, ToastLength.Long)?.Show(); return; } var appNamesList = ContentManager.ValidAppNames.ToList(); bool found = false; foreach (var folder in dataChildren) { if (appNamesList.Contains(folder.Path.Split("/").Last())) { found = true; } } if (!found) { var infoText = UIFunctions.GetResourceString("NoFGOInstallationFoundToast"); Toast.MakeText(this.Context, infoText, ToastLength.Long)?.Show(); return; } // Save URL try { this.ContentResolver.TakePersistableUriPermission(uri, intent.Flags & (ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission)); } catch (Exception ex) { Log.Error("BetterFGO", $"Error thrown while persisting uri: {ex}"); var errorText = UIFunctions.GetResourceString("UnknownError"); var errorMessage = String.Format(errorText, ex.ToString()); Toast.MakeText(this.Context, errorMessage, ToastLength.Long)?.Show(); } // If we got this far, all is well var successText = UIFunctions.GetResourceString("Android11SetupSuccessful"); Toast.MakeText(this.Context, successText, ToastLength.Long)?.Show(); Log.Info("BetterFGO", $"Saving URI: {uri?.ToString()}"); Preferences.Set("StorageType", (int)ContentType.StorageFramework); Preferences.Set("StorageLocation", uri?.ToString()); MessagingCenter.Send(Xamarin.Forms.Application.Current, "return_to_main_page"); } }
void Start() { playerController = FindObjectOfType <PlayerController>(); UIController = FindObjectOfType <UIFunctions>(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { UIFunctions.CenterObject(this); }
// Use this for initialization void Start() { uiFunctions = GameObject.FindGameObjectWithTag("GameManager").GetComponent <UIFunctions>(); canSpawn = true; }
private MediaResult CreateResult(PickerOperation operation, NSDictionary <NSString, iOSObjectProxy> info) { if (info == null) { return(null); } switch (Operation) { case PickerOperation.PickGallery: // User can either pick an image or a video NSURL pickedURL = null; if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerImageURL, out pickedURL)) { return(new MediaResult(MediaType.Image, null, pickedURL.AbsoluteString.UTF8String)); } else if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerMediaURL, out pickedURL)) { return(new MediaResult(MediaType.Video, null, pickedURL.AbsoluteString.UTF8String)); } else { return(null); } case PickerOperation.TakePicture: // Get the newly taken image, save it into the into user temporary folder and return the URL. // The image name will be "IMG_" + timestamp and format is JPG. UIImage picture = (UIImage)info.ValueForKey(UIImagePickerController.UIImagePickerControllerOriginalImage, ptr => PInvokeUtil.IsNull(ptr) ? null : new UIImage(ptr)); if (picture == null) { Debug.LogError("Couldn't get the taken picture."); return(null); } // Save the image into user temporary folder and return the URL. NSString tempDir = NSFileManager.NSTemporaryDirectory(); if (tempDir == null) { Debug.LogError("Couldn't find the path of user's temporary directory."); return(null); } // The image name is "IMG_" + timestamp and format is JPG. NSString pictureName = NSString.StringWithUTF8String("IMG_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg"); NSURL pictureURL = NSURL.FileURLWithPath(tempDir).URLByAppendingPathComponent(pictureName); if (pictureURL != null) { NSData imageData = UIFunctions.UIImageJPEGRepresentation(picture, 1f); NSFileManager.DefaultManager.CreateFileAtPath(pictureURL.Path, imageData, null); return(new MediaResult(MediaType.Image, null, pictureURL.AbsoluteString.UTF8String)); } else { return(null); } case PickerOperation.RecordVideo: NSURL videoURL = null; if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerMediaURL, out videoURL)) { return(new MediaResult(MediaType.Video, null, videoURL.AbsoluteString.UTF8String)); } else { return(null); } default: return(null); } }