private void OnDropDownLegendItemSelected(int index) { if (!Dropdown.Popup.IsItemCheckable(index)) { return; } var result = chart.UpdateDataSetVisibility( Dropdown.Popup.GetItemText(index), !Dropdown.Popup.IsItemChecked(index)); switch (result) { case DataSetVisibilityUpdateResult.MaxVisibleLimitReached: ToolTipManager.Instance.ShowPopup(string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate( "MAX_VISIBLE_DATASET_WARNING"), chart.MaxDisplayedDataSet), 1f); break; case DataSetVisibilityUpdateResult.MinVisibleLimitReached: ToolTipManager.Instance.ShowPopup(string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate( "MIN_VISIBLE_DATASET_WARNING"), chart.MinDisplayedDataSet), 1f); break; } }
public static void WebStart(HttpConfiguration config) { SignumServer.Start(config, typeof(Global).Assembly); AuthServer.Start(config, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!"); CacheServer.Start(config); FilesServer.Start(config); UserQueryServer.Start(config); DashboardServer.Start(config); WordServer.Start(config); ExcelServer.Start(config); ChartServer.Start(config); MapServer.Start(config); TranslationServer.Start(config, new AlreadyTranslatedTranslator(new BingTranslator())); SchedulerServer.Start(config); ProcessServer.Start(config); DisconnectedServer.Start(config); MailingServer.Start(config); ProfilerServer.Start(config); DiffLogServer.Start(config); OmniboxServer.Start(config, new EntityOmniboxResultGenenerator(), new DynamicQueryOmniboxResultGenerator(), new ChartOmniboxResultGenerator(), new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete), new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete), new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete), new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()), new ReactSpecialOmniboxGenerator() //new HelpModuleOmniboxResultGenerator(), ); //Omnibox }
/// <summary> /// Checks that all the new info in the upload form is good /// </summary> /// <returns>True if good, false if not good (also sets the general error message)</returns> private bool ValidateForm() { if (string.IsNullOrWhiteSpace(editedTitle.Text)) { SetError(TranslationServer.Translate("MISSING_TITLE")); return(false); } if (string.IsNullOrWhiteSpace(editedDescription.Text)) { SetError(TranslationServer.Translate("MISSING_DESCRIPTION")); return(false); } // TODO: would be nice to somehow get the Steam constants in here... if (editedDescription.Text.Length > 8000) { SetError(TranslationServer.Translate("DESCRIPTION_TOO_LONG")); return(false); } if (changeNotes.Text.Length > 8000) { SetError(TranslationServer.Translate("CHANGE_DESCRIPTION_IS_TOO_LONG")); return(false); } if (editedTags.Text is { Length : > 0 })
private static CultureInfo GetCulture(ActionContext context) { // 1 cookie (temporary) var lang = TranslationServer.ReadLanguageCookie(context); if (lang != null) { return(CultureInfo.GetCultureInfo(lang)); } // 2 user preference if (UserEntity.Current?.CultureInfo != null) { return(UserEntity.Current.CultureInfo !.ToCultureInfo()); } //3 requestCulture or default CultureInfo?ciRequest = TranslationServer.GetCultureRequest(context); if (ciRequest != null) { return(ciRequest); } return(DefaultCulture); //Translation }
/// <summary> /// Truncates large numbers with suffix added (e.g. M for million). /// Adapted from https://stackoverflow.com/a/30181106 to allow negatives and translation. /// </summary> public static string FormatNumber(this double number, bool withSuffix = true) { if (number is >= 1000000000 or <= -1000000000) { return(withSuffix ? string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate("BILLION_ABBREVIATION"), number.ToString("0,,,.###", CultureInfo.CurrentCulture)) : number.ToString("0,,,.###", CultureInfo.CurrentCulture)); } if (number is >= 1000000 or <= -1000000) { return(withSuffix ? string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate("MILLION_ABBREVIATION"), number.ToString("0,,.##", CultureInfo.CurrentCulture)) : number.ToString("0,,.##", CultureInfo.CurrentCulture)); } if (number is >= 1000 or <= -1000) { return(withSuffix ? string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate("KILO_ABBREVIATION"), number.ToString("0,.#", CultureInfo.CurrentCulture)) : number.ToString("0,.#", CultureInfo.CurrentCulture)); } return(number.ToString("0.#", CultureInfo.CurrentCulture)); }
private static void PerformSave(InProgressSave inProgress, Save save) { try { save.SaveToFile(); inProgress.ReportStatus(true, TranslationServer.Translate("SAVING_SUCCEEDED")); } catch (Exception e) { // ReSharper disable HeuristicUnreachableCode ConditionIsAlwaysTrueOrFalse if (!Constants.CATCH_SAVE_ERRORS) #pragma warning disable 162 { throw; } #pragma warning restore 162 inProgress.ReportStatus(false, TranslationServer.Translate("SAVING_FAILED"), e.ToString()); return; } if (inProgress.Type == SaveInformation.SaveType.AutoSave) { QueueRemoveExcessAutoSaves(); } if (inProgress.Type == SaveInformation.SaveType.QuickSave) { QueueRemoveExcessQuickSaves(); } }
private void _on_OptionButton_item_selected(int index) { string lang = (string)languages[index]; GD.Print("Select: " + index); TranslationServer.SetLocale(lang); }
public static void WebStart(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime) { SignumServer.Start(app, env, typeof(Startup).Assembly); AuthServer.Start(app, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM AtTest. CHANGE THIS STRING!!!"); CacheServer.Start(app); FilesServer.Start(app); UserQueryServer.Start(app); DashboardServer.Start(app); WordServer.Start(app); ExcelServer.Start(app); ChartServer.Start(app); MapServer.Start(app); ToolbarServer.Start(app); TranslationServer.Start(app, new AlreadyTranslatedTranslator(new AzureTranslator("Your API Key for Azure Translate"))); SchedulerServer.Start(app, lifetime); ProcessServer.Start(app); MailingServer.Start(app); ProfilerServer.Start(app); DiffLogServer.Start(app); PredictorServer.Start(app); OmniboxServer.Start(app, new EntityOmniboxResultGenenerator(), new DynamicQueryOmniboxResultGenerator(), new ChartOmniboxResultGenerator(), new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete), new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete), new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete), new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()), new ReactSpecialOmniboxGenerator() //new HelpModuleOmniboxResultGenerator(), ); //Omnibox SignumCultureSelectorFilter.GetCurrentCulture = (ctx) => GetCulture(ctx); }
/// <summary> /// Loads the help screen with texts from the json file /// and turn it into help boxes /// </summary> private void BuildHelpTexts(string category) { var helpTexts = SimulationParameters.Instance.GetHelpTexts(category); foreach (var text in helpTexts.Messages) { var message = TranslationServer.Translate(text.Message); var helpBox = HelpBoxScene.Instance(); helpBox.GetNode <CustomRichTextLabel>("MarginContainer/CustomRichTextLabel").ExtendedBbcode = message; if (text.Column == HelpText.TextColumn.Left) { leftColumn.AddChild(helpBox); } else if (text.Column == HelpText.TextColumn.Right) { rightColumn.AddChild(helpBox); } else { GD.PrintErr("Help text doesn't have a column set, couldn't be added into the container"); // Queued as otherwise help text's ExtendedBbcode would be applied on a disposed object Invoke.Instance.Queue(helpBox.DetachAndQueueFree); } } }
public override void _Notification(int what) { if (what == NotificationTranslationChanged) { HUD.UpdatePatchInfo(TranslationServer.Translate(CurrentGame.GameWorld.Map.CurrentPatch.Name)); } }
/// <summary> /// Combines artwork title, artist name and extended description into one structured string. /// </summary> /// <param name="extended"> /// Includes the extended description if true (and it's not empty). /// </param> public string BuildDescription(bool extended) { var result = string.Empty; if (!string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Artist)) { result += string.Format( CultureInfo.CurrentCulture, TranslationServer.Translate("ARTWORK_TITLE"), Title, Artist); } else if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Artist)) { result += string.Format(CultureInfo.CurrentCulture, TranslationServer.Translate("ART_BY"), Artist); } else if (!string.IsNullOrEmpty(Title) && string.IsNullOrEmpty(Artist)) { result += Title; } if (extended && !string.IsNullOrEmpty(Description)) { result += $"\n{Description}"; } return(result); }
/// <summary> /// Switches to the editor /// </summary> public void MoveToEditor() { // Increase the population by the constant for the player reproducing var playerSpecies = GameWorld.PlayerSpecies; GameWorld.AlterSpeciesPopulation( playerSpecies, Constants.PLAYER_REPRODUCTION_POPULATION_GAIN_CONSTANT, TranslationServer.Translate("PLAYER_REPRODUCED"), false, Constants.PLAYER_REPRODUCTION_POPULATION_GAIN_COEFFICIENT); var scene = SceneManager.Instance.LoadScene(MainGameState.MicrobeEditor); var editor = (MicrobeEditor)scene.Instance(); editor.CurrentGame = CurrentGame; editor.ReturnToStage = this; // We don't free this here as the editor will return to this scene if (SceneManager.Instance.SwitchToScene(editor, true) != this) { throw new Exception("failed to keep the current scene root"); } MovingToEditor = false; }
public void SubmitWorkshopItemUpdate(ulong updateHandle, string changeNotes, Action <WorkshopResult> callback) { if (workshopUpdateCallback != null) { throw new InvalidOperationException("Workshop update is already in-progress"); } workshopUpdateCallback = callback ?? throw new ArgumentException("callback is required"); // Steam docs say this constant is unused, but at least currently it seems to be the same value as the document // description max length if (changeNotes?.Length > Steam.PublishedDocumentChangeDescriptionMax) { callback.Invoke(new WorkshopResult() { Success = false, TranslatedError = TranslationServer.Translate("CHANGE_DESCRIPTION_IS_TOO_LONG"), }); return; } GD.Print("Submitting workshop update with handle: ", updateHandle); Steam.SubmitItemUpdate(updateHandle, changeNotes); }
public void Init() { if (initStarted) { throw new InvalidOperationException("Can't initialize Steam more than once"); } initStarted = true; GD.Print("Starting Steam load"); var stats = Steam.SteamInit(true); if (!stats.Contains("status") || stats["status"] as int? != 1) { GD.Print("Steam load failed with code:", stats["status"]); GD.PrintErr("Verbal status: ", stats["verbal"]); SetError(TranslationServer.Translate("STEAM_CLIENT_INIT_FAILED"), stats["verbal"] as string); return; } GD.Print("Steam load finished"); IsLoaded = true; RefreshCurrentUserInfo(); if (IsOwned == true) { GD.Print("Game is owned by current Steam user"); } // TODO: remove this cast once GodotSteam is updated AppId = (uint)Steam.GetAppID(); GD.Print("Our app id is: ", AppId); }
private StartupActions() { // Print game version // TODO: for devbuilds it would be nice to print the hash here GD.Print("This is Thrive version: ", Constants.Version); GD.Print("Startup C# locale is: ", CultureInfo.CurrentCulture, " Godot locale is: ", TranslationServer.GetLocale()); var userDir = Constants.UserFolderAsNativePath; GD.Print("user:// directory is: ", userDir); // Print the logs folder to see in the output where they are stored GD.Print("Game logs are written to: ", Path.Combine(userDir, Constants.LOGS_FOLDER_NAME), " latest log is 'log.txt'"); // Load settings here, to make sure locales etc. are applied to the main loaded and autoloaded scenes try { // We just want to do something to ensure settings instance is fine // ReSharper disable once UnusedVariable var hashCode = Settings.Instance.GetHashCode(); } catch (Exception e) { GD.PrintErr("Failed to initialize settings: ", e); } }
private string GetTranslatedHeading(string team) { switch (team) { case ProgrammingTeamName: return(TranslationServer.Translate("PROGRAMMING_TEAM")); case TheoryTeamName: return(TranslationServer.Translate("THEORY_TEAM")); case GraphicsTeamName: return(TranslationServer.Translate("GRAPHICS_TEAM")); case SoundTeamName: return(TranslationServer.Translate("SOUND_TEAM")); case OutreachTeamName: return(TranslationServer.Translate("OUTREACH_TEAM")); case GameDesignTeamName: return(TranslationServer.Translate("GAME_DESIGN_TEAM")); case TestingTeamName: return(TranslationServer.Translate("TESTING_TEAM")); case ProjectManagementTeamName: return(TranslationServer.Translate("PROJECT_MANAGEMENT_TEAM")); case "Pull Requests / Programming": return(TranslationServer.Translate("PULL_REQUESTS_PROGRAMMING")); case "VIP_PATRONS": return(TranslationServer.Translate("VIP_PATRONS")); case "DEV_BUILD_PATRONS": return(TranslationServer.Translate("DEV_BUILD_PATRONS")); case "SUPPORTER_PATRONS": return(TranslationServer.Translate("SUPPORTER_PATRONS")); case "January": return(TranslationServer.Translate("JANUARY")); case "February": return(TranslationServer.Translate("FEBRUARY")); case "March": return(TranslationServer.Translate("MARCH")); case "April": return(TranslationServer.Translate("APRIL")); case "May": return(TranslationServer.Translate("MAY")); case "June": return(TranslationServer.Translate("JUNE")); case "July": return(TranslationServer.Translate("JULY")); case "August": return(TranslationServer.Translate("AUGUST")); case "September": return(TranslationServer.Translate("SEPTEMBER")); case "October": return(TranslationServer.Translate("OCTOBER")); case "November": return(TranslationServer.Translate("NOVEMBER")); case "December": return(TranslationServer.Translate("DECEMBER")); default: GD.Print( $"unknown heading '{team}' needs to be added to " + $"{nameof(CreditsScroll)}.{nameof(GetTranslatedHeading)}"); return(team); } }
private void LoadEndRemarks() { int offset = GetNextDynamicSectionOffset() + OffsetBeforeNextDynamicPart; CreateDynamicPart(offset, TranslationServer.Translate("THANKS_FOR_PLAYING")); // This is the last section so when these items have all scrolled off the credits trigger the end signal }
public void _on_locale_chosen(int langI) { string locale = (string)((TranslationServer.GetLoadedLocales())[langI]); TranslationServer.SetLocale(locale); updateComments(); EmitSignal("comments_changed"); }
private void ShowOverwriteConfirm(string name) { // The chosen filename ({0}) already exists. Overwrite? overwriteConfirm.DialogText = string.Format(CultureInfo.CurrentCulture, TranslationServer.Translate("THE_CHOSEN_FILENAME_ALREADY_EXISTS"), name); overwriteConfirm.PopupCenteredShrink(); }
private static string GetTranslatedText(Type type, object instance, object[] attributes) { var data = (TranslateFromAttribute)attributes[0]; var source = GetTargetField(type, data); return(TranslationServer.Translate((string)source.GetValue(instance))); }
private void OnRebindButtonPressed() { WaitingForInput = true; button.Text = TranslationServer.Translate("PRESS_KEY_DOT_DOT_DOT"); xButton.Visible = true; // Notify InputManager that input rebinding has started and it should not react to input InputManager.PerformingRebind = true; }
public static string Get(string key) { // wrapper for the Godot's Tr system if (TranslationServer.Translate(key) != string.Empty) { return(TranslationServer.Translate(key)); } return(key); }
private void Step() { switch (state) { case State.Initial: // On this frame a pause menu might still be open, wait until next frame for it to close before // taking a screenshot state = State.Screenshot; break; case State.Screenshot: { save = createSaveData.Invoke(this); SaveStatusOverlay.Instance.ShowMessage(TranslationServer.Translate("SAVING"), Mathf.Inf); state = State.SaveData; break; } case State.SaveData: { save.Name = saveNameTask.Result; GD.Print("Creating a save with name: ", save.Name); performSave.Invoke(this, save); state = State.Finished; break; } case State.Finished: { stopwatch.Stop(); GD.Print("save finished, success: ", success, " message: ", message, " elapsed: ", stopwatch.Elapsed); if (success) { SaveStatusOverlay.Instance.ShowMessage(message); currentGameRoot.Invoke().GetTree().Paused = returnToPauseState; } else { SaveStatusOverlay.Instance.ShowMessage(TranslationServer.Translate("SAVE_FAILED")); SaveStatusOverlay.Instance.ShowError(TranslationServer.Translate("ERROR_SAVING"), message, exception); } return; } default: throw new InvalidOperationException(); } Invoke.Instance.Queue(Step); }
private void UpdatePatchSettings(bool isLoading) { patchManager.ApplyChangedPatchSettingsIfNeeded(GameWorld.Map.CurrentPatch, !isLoading); HUD.UpdatePatchInfo(TranslationServer.Translate(GameWorld.Map.CurrentPatch.Name)); HUD.UpdateEnvironmentalBars(GameWorld.Map.CurrentPatch.Biome); UpdateBackground(); }
private void OnRebindButtonPressed() { WaitingForInput = true; button.Text = TranslationServer.Translate("PRESS_KEY_DOT_DOT_DOT"); xButton.Visible = true; // Signal to the input manager that a rebinding has started // and it should ignore input untill the rebind is finished InputManager.RebindingIsActive = true; }
private void SetError(string?message) { if (message == null) { ClearError(); } errorDisplay.Text = string.Format(CultureInfo.CurrentCulture, TranslationServer.Translate("FORM_ERROR_MESSAGE"), message); }
private void LoadLanguages(OptionButton optionButton) { languages = TranslationServer.GetLoadedLocales().Cast <string>().OrderBy(i => i, StringComparer.InvariantCulture) .ToList(); foreach (var locale in languages) { optionButton.AddItem(locale); } }
public string ToString(string format, IFormatProvider formatProvider) { if (formatStringArgs == null || formatStringArgs.Length == 0) { return(format ?? TranslationServer.Translate(translationKey)); } return(string.Format(formatProvider ?? CultureInfo.CurrentCulture, format ?? TranslationServer.Translate(translationKey), formatStringArgs)); }
private void OnSaveNameTextEntered(string newName) { if (IsSaveNameValid(newName)) { SaveButtonPressed(); } else { ToolTipManager.Instance.ShowPopup(TranslationServer.Translate("INVALID_SAVE_NAME_POPUP"), 2.5f); } }
internal static string Translate(string format, params string[] pp) { var tranFormat = TranslationServer.Translate(format); if (pp.Count() == 0) { return(tranFormat); } return(String.Format(tranFormat, pp)); }