public void SafeWrite <T>(T obj, string path) { #if UNITY_EDITOR Debug.Log($"SafeWrite {obj:GetType()} {path}"); #endif try { var oldPath = path + ".old"; if (File.Exists(path)) { File.Delete(oldPath); // no exception if not exist File.Move(path, oldPath); // exception if exists } using (var fs = File.OpenWrite(path)) // overwrite if needed { Write(obj, fs); // May be interrupted } File.Delete(oldPath); } catch (Exception e) { // If there is some problem with Alert.Show, we need to avoid infinite recursion if (alertOnSafeWriteFail) { alertOnSafeWriteFail = false; Alert.Show(I18n.__("bookmark.save.fail"), e.Message); } throw; } }
public override void Show(Action onFinish) { base.Show(() => { viewManager.dialoguePanel.SetActive(false); viewManager.StopAllAnimations(); gameState.ResetGameState(); if (bgmController != null && !string.IsNullOrEmpty(bgmName)) { bgmController.scriptVolume = bgmVolume; bgmController.Play(bgmName); } var reachedChapterCount = gameState.GetAllStartupNodeNames() .Count(name => checkpointManager.IsReachedForAnyVariables(name, 0) != null); if (reachedChapterCount > 1 && configManager.GetInt(ChapterFirstUnlockedKey) == 0) { Alert.Show(I18n.__("title.first.selectchapter")); configManager.SetInt(ChapterFirstUnlockedKey, 1); } onFinish?.Invoke(); }); }
private void LoadBookmark(int saveId) { alertController.Alert( null, I18n.__("bookmark.load.confirm", SaveIdToDisplayId(saveId)), () => _loadBookmark(saveId) ); }
private void DeleteBookmark(int saveId) { alertController.Alert( null, I18n.__("bookmark.delete.confirm", SaveIdToDisplayId(saveId)), () => _deleteBookmark(saveId) ); }
private void SaveBookmark(int saveId) { alertController.Alert( null, I18n.__("bookmark.overwrite.confirm", SaveIdToDisplayId(saveId)), () => _saveBookmark(saveId) ); }
private DialogueDisplayData GetPreviewDisplayData() { var displayNames = I18n.SupportedLocales.ToDictionary(x => x, x => I18n.__(x, "config.textpreview.name")); var dialogues = I18n.SupportedLocales.ToDictionary(x => x, x => I18n.__(x, TextPreviewKeys[textPreviewIndex])); return(new DialogueDisplayData("Preview", displayNames, dialogues)); }
private void ShowPreviewScreen() { ShowPreview(screenSprite, I18n.__( "bookmark.summary", DateTime.Now.ToString(dateTimeFormat), currentNodeName, currentDialogueText )); }
public static void QuitWithConfirm() { Alert.Show( null, I18n.__("ingame.exit.confirm"), Quit, null, "QuitConfirm" ); }
private void UpdateText() { if (!inited) { return; } contentBox.pageToDisplay = 1; content = I18n.__(displayData.dialogues); characterName = I18n.__(displayData.displayNames); }
private void ShowPreviewBookmark(int saveId) { Bookmark bookmark = checkpointManager[saveId]; ShowPreview(GetThumbnailSprite(saveId), I18n.__( "bookmark.summary", checkpointManager.SaveSlotsMetadata[saveId].ModifiedTime.ToString(dateTimeFormat), bookmark.NodeHistory.Last(), bookmark.Description )); }
private void ResetDefault() { Alert.Show(null, I18n.__("config.alert.resetdefault"), () => { configManager.ResetToDefault(); inputMappingController.ResetDefault(); configManager.Apply(); inputMappingController.Apply(); I18n.CurrentLocale = Application.systemLanguage; }); }
private void UpdateFullScreenStatus(bool to) { if (Application.isMobilePlatform) { return; } // Debug.LogFormat("Full screen status changing from {0} (logical {1}) to {2}", Screen.fullScreen, isLogicalFullScreen, to); if (isLogicalFullScreen == to) { return; } isLogicalFullScreen = to; if (to) { configManager.SetInt(LastWindowedWidthKey, Screen.width); configManager.SetInt(LastWindowedHeightKey, Screen.height); Screen.SetResolution( Screen.currentResolution.width, Screen.currentResolution.height, FullScreenMode.FullScreenWindow ); } else { var targetW = configManager.GetInt(LastWindowedWidthKey); var targetH = configManager.GetInt(LastWindowedHeightKey); if (targetW == 0 || targetH == 0) { if (Screen.resolutions.Length == 0) { targetW = 1280; targetH = 720; } else { var defaultResolution = Screen.resolutions[Screen.resolutions.Length / 2]; targetW = defaultResolution.width; targetH = defaultResolution.height; } } Screen.SetResolution(targetW, targetH, FullScreenMode.Windowed); if (configManager.GetInt(ChangeWindowSizeFirstShownKey) == 0) { Alert.Show(I18n.__("config.changewindowsize")); configManager.SetInt(ChangeWindowSizeFirstShownKey, 1); } } }
protected override void OnActivatedUpdate() { base.OnActivatedUpdate(); if (Utils.GetKeyDownInEditor(KeyCode.LeftShift)) { foreach (var chapter in buttons) { chapter.Value.GetComponent <Button>().enabled = true; chapter.Value.GetComponent <Text>().text = I18n.__(gameState.GetNode(chapter.Key).displayNames); } } }
/// <summary> /// Show log panel /// </summary> public override void Show(Action onFinish) { if (configManager.GetInt(LogViewFirstShownKey) == 0) { Alert.Show(I18n.__("log.first.hint")); configManager.SetInt(LogViewFirstShownKey, 1); } scrollRect.verticalNormalizedPosition = 0.0f; base.Show(onFinish); scrollRect.verticalNormalizedPosition = 0.0f; lastClickedLogIndex = -1; }
private void ResetDefault() { Alert.Show(null, I18n.__("config.alert.resetdefault"), () => { configManager.ResetToDefault(); inputMappingController.ResetDefault(); configManager.Apply(); // error will occur if reset default button is clicked before the InputMappingController starts // as the InputMappingController will reload data from current InputMapping, which will not get // updated unless the apply method get called. inputMappingController.Apply(); }); }
public void QuickLoadBookmark() { if (checkpointManager.SaveSlotsMetadata.Values.Where( m => m.SaveId >= (int)BookmarkType.QuickSave && m.SaveId < (int)BookmarkType.QuickSave + maxSaveEntry ).Any()) { alertController.Alert(null, I18n.__("bookmark.quickload.confirm"), () => _quickLoadBookmark()); } else { alertController.Alert(null, I18n.__("bookmark.quickload.nosave")); } }
public string FormatNameDialogue() { var name = I18n.__(displayNames); var dialogue = I18n.__(dialogues); if (string.IsNullOrEmpty(name)) { return(dialogue); } else { return(string.Format(I18n.__("format.namedialogue"), name, dialogue)); } }
/// <summary> /// Execute the action stored in this dialogue entry /// </summary> public void ExecuteAction() { if (action != null) { try { action.Call(); } catch (LuaException ex) { throw new Exceptions.ScriptActionException( $"Nova: Exception occurred when executing action: {I18n.__(dialogues)}", ex); } } }
/// <summary> /// Execute the action stored in this dialogue entry. /// </summary> public void ExecuteAction(DialogueActionStage stage, bool isRestoring) { if (actions.TryGetValue(stage, out var action)) { LuaRuntime.Instance.UpdateExecutionContext(new ExecutionContext(ExecutionMode.Lazy, stage, isRestoring)); try { action.Call(); } catch (LuaException e) { throw new ScriptActionException( $"Nova: Exception occurred when executing action: {I18n.__(dialogues)}", e); } } }
private void UpdateAllButtons() { foreach (var chapter in buttons) { if (unlockAllChaptersForDebug || checkpointManager.IsReachedForAnyVariables(chapter.Key, 0) != null) { chapter.Value.GetComponent <Button>().enabled = true; chapter.Value.GetComponent <Text>().text = I18nHelper.NodeNames.Get(chapter.Key); } else { chapter.Value.GetComponent <Button>().enabled = false; chapter.Value.GetComponent <Text>().text = I18n.__("title.selectchapter.locked"); } } }
private void UpdateAllButtons() { foreach (var chapter in buttons) { if (IsUnlocked(chapter.Key)) { chapter.Value.GetComponent <Button>().enabled = true; chapter.Value.GetComponent <Text>().text = I18n.__(gameState.GetNode(chapter.Key).displayNames); } else { chapter.Value.GetComponent <Button>().enabled = false; chapter.Value.GetComponent <Text>().text = I18n.__("title.selectchapter.locked"); } } }
private void OnGoBackButtonClicked(string nodeName, int dialogueIndex, int logEntryIndex, string variablesHash) { if (logEntryIndex == lastClickedLogIndex) { Alert.Show( null, I18n.__("log.back.confirm"), () => _onGoBackButtonClicked(nodeName, dialogueIndex, logEntryIndex, variablesHash), null, "LogBack" ); } else { lastClickedLogIndex = logEntryIndex; } }
private void ReturnTitle() { if (fromTitle) { _returnTitle(); } else { Alert.Show( null, I18n.__("ingame.title.confirm"), _returnTitle, null, "ReturnTitle" ); } }
private void OnGoBackButtonClicked(NodeHistoryEntry nodeHistoryEntry, int dialogueIndex, int logEntryIndex) { if (logEntryIndex == lastClickedLogIndex) { Alert.Show( null, I18n.__("log.back.confirm"), () => _onGoBackButtonClicked(nodeHistoryEntry, dialogueIndex), null, "LogBack" ); } else { lastClickedLogIndex = logEntryIndex; } }
private void UpdateText() { string str = I18n.__(inflateTextKey); if (textProxy != null) { textProxy.text = str; } else if (textPro != null) { textPro.text = str; } else { text.text = str; } }
private string GetDescription() { switch (controller.mode) { case MusicListMode.Sequential: return(I18n.__("bgmgallery.mode.seq")); case MusicListMode.SingleLoop: return(I18n.__("bgmgallery.mode.loop")); case MusicListMode.Random: return(I18n.__("bgmgallery.mode.rand")); default: throw new ArgumentOutOfRangeException(); } }
private void UpdateText() { if (displayTexts == null) { text.text = ""; } else { text.text = I18n.__(displayTexts); } if (imageInfo != null) { // TODO: preload image.sprite = AssetLoader.Load <Sprite>(System.IO.Path.Combine(imageFolder, imageInfo.name)); image.SetNativeSize(); } }
private static string AbstractKeyDisplayName(AbstractKey key) => I18n.__($"config.key.{Enum.GetName(typeof(AbstractKey), key)}");
private void ApplyInvalidMusicEntry() { audioSource.clip = null; titleLabel.text = I18n.__("musicgallery.title"); progressBar.interactable = false; }
// Use this for initialization void Awake() { GetComponent <Text>().text = I18n.__(InflateTextKey); }