Example #1
0
 public void SetLanguage(int value)
 {
     LanguageLoader.LoadInternalLanguages(LocaleManager.instance);
     LanguageLoader.LoadExternalLanguages(LocaleManager.instance);
     LocaleManager.instance.PrepareInit += AfterLangChange;
     LocaleManager.SelectLocale(false);
 }
Example #2
0
    void OnUpdateInfo(SongInfo?newInfo)
    {
        bool hasInfo = newInfo.HasValue;

        songInfo = newInfo.GetValueOrDefault();
        if (!songInfo.banner && songInfo.background)
        {
            songInfo.banner = songInfo.background;
        }
        background.SetTexture(songInfo.background);
        background.gameObject.SetActive(songInfo.background);
        banner.SetTexture(songInfo.banner);
        bannerParent.gameObject.SetActive(songInfo.banner);
        songDetails.text = hasInfo ? string.Format(
            LanguageLoader.GetText(1),
            songInfo.name,
            songInfo.level,
            songInfo.artist,
            songInfo.subArtist,
            songInfo.genre,
            songInfo.bpm,
            songInfo.notes,
            songInfo.LayoutName,
            songInfo.comments
            ) : string.Empty;
        ReloadRecord();
    }
Example #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // Before we clear the popup list, let's quickly store the current key in case we
        // need to do a lookup (on language change).
        var lastKey = availableKeys[currentIndex.intValue];

        RefreshCurrentLanguage();

        // If we switcharooed the language, let's try to find the same key that we had selected
        // before. Otherwise, reset to 0.
        var newIndex = availableKeys.FindIndex(str => str.Equals(lastKey));

        currentIndex.intValue = newIndex >= 0 ? newIndex : 0;

        // Display the current language that is chosen.
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Current language:");
        EditorGUILayout.LabelField(currentLangName, EditorStyles.boldLabel);
        GUILayout.EndHorizontal();

        // Display a popup for the user to select a valid string in the current language.
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Localized key to use: ");
        currentIndex.intValue = EditorGUILayout.Popup(currentIndex.intValue, availableKeys.ToArray());
        GUILayout.EndHorizontal();

        // Set the string value of the text component to the localized string.
        text.stringValue = LanguageLoader.GetLocalizedString(availableKeys[currentIndex.intValue]);

        serializedObject.ApplyModifiedProperties();
    }
Example #4
0
        public Language FindBestLanguage(string languageName)
        {
            if (string.IsNullOrEmpty(languageName))
            {
                languageName = "en";
            }

            try
            {
                var cultureInfo = new CultureInfo(languageName);
                return(LanguageLoader.FindBestLanguage(cultureInfo));
            }
            catch (CultureNotFoundException)
            {
            }

            var language = LanguageLoader.GetAvailableLanguages().FirstOrDefault(x => x.Iso2 == languageName);

            if (language != null)
            {
                return(language);
            }

            return(LanguageLoader.FindBestLanguage(new CultureInfo("en")));
        }
 public NewOverlayDialog()
 {
     InitializeComponent();
     if (!DesignMode)
     {
         LanguageLoader.LanguagePatch(this);
     }
 }
Example #6
0
 public static void SetCurrentLanguage(string culture)
 {
     LanguageLoader.FlushCache();
     Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);
     TranslationManager.Instance.OnLanguageChanged();
     FontFamilyManager.Instance.OnFontFamilyChanged();
     FontSizeManager.Instance.OnFontSizeChanged();
 }
Example #7
0
 void ValueChanged(int index)
 {
     if (index < 0)
     {
         return;
     }
     LanguageLoader.LoadLang(availableLanguages[index].path);
 }
Example #8
0
 private static void RegisterNavigation()
 {
     Messenger.Default.Register <NotificationMessage>(_sender, message =>
     {
         if (message.Notification == UIMessageType.Navigation_ManageCameraEvent)
         {
             // 设备管理
             MakeSingleView(ViewType.DeviceConfiguration, ViewMaker.MakeDeviceConfigurationView);
         }
         else if (message.Notification == UIMessageType.Navigation_ShowLiveVideoCameraListEvent)
         {
             // 实时视频摄像机列表
             MakeSingleView(ViewType.LiveVideoCameraList, ViewMaker.MakeLiveVideoCameraListView);
         }
         else if (message.Notification == UIMessageType.Navigation_PublishMediaEvent)
         {
             // 媒体发布
             MakeSingleView(ViewType.PublishMedia, ViewMaker.MakePublishMediaView);
         }
         else if (message.Notification == UIMessageType.Navigation_UpdateSkinEvent)
         {
             // 皮肤
             MakeSingleView(ViewType.SkinConfiguration, ViewMaker.MakeSkinConfigurationView);
         }
         else if (message.Notification == UIMessageType.Navigation_ChangeLanguage_zh_CN_Event)
         {
             LanguageLoader.LoadLanguageResource(CultureHelper.Component, @"zh-CN");
             NavigationMenu.LoadNavigationMenu();
             UpdateViewLanguageResource();
         }
         else if (message.Notification == UIMessageType.Navigation_ChangeLanguage_en_US_Event)
         {
             LanguageLoader.LoadLanguageResource(CultureHelper.Component, @"en-US");
             NavigationMenu.LoadNavigationMenu();
             UpdateViewLanguageResource();
         }
         else if (message.Notification == UIMessageType.Navigation_HelpOnlineEvent)
         {
             Process.Start(new ProcessStartInfo(@"http://weibo.com/gaochundong"));
         }
         else if (message.Notification == UIMessageType.Navigation_CheckUpdateEvent)
         {
             Process.Start(new ProcessStartInfo(@"http://weibo.com/gaochundong"));
         }
         else if (message.Notification == UIMessageType.Navigation_ReportBugEvent)
         {
             Process.Start(new ProcessStartInfo(@"http://weibo.com/gaochundong"));
         }
         else if (message.Notification == UIMessageType.Navigation_SeeAboutEvent)
         {
             MakeSingleView(ViewType.Abort, ViewMaker.MakeAboutView);
         }
     });
 }
Example #9
0
    public void SetText(int langId)
    {
        var text = LanguageLoader.GetText(langId).Split('\n');

        for (int i = 0, c = Mathf.Min(text.Length, options.Count); i < c; i++)
        {
            options[i].text = text[i];
        }
        if (value >= 0 && value < options.Count)
        {
            captionText.text = options[value].text;
        }
    }
        /// <summary>
        ///     Initialize the Translator for later use in the application
        /// </summary>
        /// <param name="languageName">Language to use for initialization</param>
        public void InitTranslator(string languageName)
        {
            LanguageLoader = BuildLanguageLoader();

            if (string.IsNullOrEmpty(languageName))
            {
                languageName = "english";
            }

            var translationFile = LanguageLoader.GetTranslationFile(languageName);

            var translator = BuildLanguageTranslator(translationFile);
            var fallback   = BuildLanguageTranslator(Path.Combine(LanguageLoader.TranslationFolder, "english.ini"));

            _translationProxy.Translator = new FallbackTranslator(translator, fallback);
        }
Example #11
0
        public void LoadLocale()
        {
            LanguageLoader.LoadInternalLanguages(instance);
            LanguageLoader.LoadExternalLanguages(instance);

            if (PlayerPrefs.HasKey("locale") && PlayerPrefs.GetInt("locale") < Locales.Count)
            {
                SetLocale(PlayerPrefs.GetInt("locale"));
            }
            else
            {
                SelectLocale(true);
                PlayerPrefs.SetInt("locale", CurrentIndex);
                PlayerPrefs.Save();
            }
        }
Example #12
0
        private void AddScripts()
        {
            Dictionary <Text, bool> .KeyCollection allKeys = textToMapButton.Keys;
            foreach (Text key in allKeys)
            {
                if (textToMapButton[key])
                {
                    LanguageLoader loader = key.gameObject.AddComponent <LanguageLoader>();
                    loader.textKey = GetName(key.gameObject);
                    EditorUtility.SetDirty(key.gameObject);
                }
            }
            var scene = SceneManager.GetActiveScene();

            EditorSceneManager.MarkSceneDirty(scene);
        }
Example #13
0
    public static string GetFormattedRankString(RankControl rankControl, float score)
    {
        if (Loader.judgeMode == 2)
        {
            return(LanguageLoader.GetText(score > 500000 ? 33 : 34));
        }
        string rankString;
        Color  rankColor;

        rankControl.GetRank(score, out rankString, out rankColor);
        return(string.Format(
                   "<color=#{0}>{1}</color>",
                   ColorUtility.ToHtmlStringRGBA(rankColor),
                   rankString
                   ));
    }
Example #14
0
        Language LoadLanguages()
        {
            LanguageLoader.LoadLanguages(GlobalSettings.GetDataURI("Languages"));

            Language useLanguage = null;

            try
            {
                // stage 1 (prelim): if no language, see if our languages contain it
                if (string.IsNullOrEmpty(GlobalSettings.LanguageFile))
                {
                    useLanguage =
                        LanguageLoader.FindLanguage((CultureInfo.CurrentUICulture.IsNeutralCulture == false)
                                                                                                                ? CultureInfo.CurrentUICulture.Parent.Name
                                                                                                                : CultureInfo.CurrentUICulture.Name);
                }

                // stage 2: load from last used language
                if (useLanguage == null)
                {
                    useLanguage = LanguageLoader.FindLanguage(GlobalSettings.LanguageFile);
                }

                // stage 3: use English file, if it exists
                if (useLanguage == null)
                {
                    useLanguage = LanguageLoader.FindLanguage("English");
                }
            }
            catch
            {
            }
            finally
            {
                // stage 4: fallback to built-in English file
                if (useLanguage == null)
                {
                    Program.Context.SplashForm.Invoke((Action)(() => MessageBox.Show(this, "For some reason, the default language files were missing or failed to load (did you extract?) - we'll supply you with a base language of English just so you know what you're doing!")));
                    useLanguage = LanguageLoader.LoadDefault();
                }
            }

            return(useLanguage);
        }
Example #15
0
    // Use this for initialization
    void Start()
    {
        if (File.Exists(GeneralSettingPath))
        {
            Debug.Log("aaa");
            LoadSettings(GeneralSettingPath);
            WriteStartupLog(LogPath, DateTime.Now + SMDefine.GetSysMsg("Space_Tag") + SMDefine.GetSysMsg("Operation_Tag") + SMDefine.GetSysMsg("OperationMsg_001") + "(" + GeneralSettingPath + ")");
        }
        Define             = GetComponent <GameObjectDefine>();
        SMDefine           = GetComponent <SystemMessageDefine>();
        ItemStr            = GetComponent <ItemString>();
        RDStr              = GetComponent <RandomDialogString>();
        AreaStr            = GetComponent <AreaString>();
        TalkStr            = GetComponent <TalkString>();
        LangLdr            = GetComponent <LanguageLoader>();
        SysSet             = GetComponent <SystemSettings>();
        StringTablePath    = Application.dataPath + "/Resources/stringtable/";
        StringTable_UIPath = StringTablePath + "jp/" + stringtable_UI_FileName;

        GeneralSettingPath = Application.dataPath + "/Resources/GeneralSettings.csv";
        LogPath            = Application.dataPath + "/log/Startup.log";
        if (!Directory.Exists(Application.dataPath + "/log/"))
        {
            Directory.CreateDirectory(Application.dataPath + "/log/");
        }
        if (!File.Exists(LogPath))
        {
            File.Create(LogPath).Close();
        }
        DefineLoadFiles();
        //Debug.Log("File Define Loaded");
        LoadSystemDefine(StringTable_System);
        //Debug.Log("System Define Loaded");
        LoggingSystemInfo();
        //Debug.Log("SystemInfo Loaded");
        LoadFiles();
        //Debug.Log("System Loaded");

        Debug.Log(GeneralSettingPath);


        //GameStartBtnTextPath = GameObject.Find(Define.GameMenu_StartBtnText).GetComponent<Text>();
        //ClickText = GameObject.Find(Define.GameMenu_ClickText).GetComponent<Text>();
    }
    public void ShowKeyMapMenu(int channel)
    {
        if (Array.IndexOf(usableChannels, channel) < 0)
        {
            return;
        }
        selectedChannel = -1;
        KeyCode keyCode;

        if (!keyMapping.TryGetValue(channel, out keyCode))
        {
            keyCode = KeyCode.None;
        }
        keyMappingDropdown.value   = Array.IndexOf(keyCodeValues, keyCode);
        selectedChannel            = channel;
        keyMappingDescDisplay.text = string.Format(LanguageLoader.GetText(14), channel);
        keyMapMenu.gameObject.SetActive(true);
        isMapping = true;
    }
Example #17
0
    public void SetText(int langId, params object[] args)
    {
        var text = LanguageLoader.GetText(langId);

        if (args != null && args.Length > 0 && !string.IsNullOrEmpty(text))
        {
            text = string.Format(text, args);
        }
        this.langId = langId;
        this.text   = text;
        font        = LanguageLoader.currentFont;
        SetAllDirty();
        RectTransform parent = rectTransform.parent as RectTransform;

        if (parent)
        {
            LayoutRebuilder.MarkLayoutForRebuild(parent);
        }
    }
Example #18
0
    public void ReloadRecord()
    {
        if (Loader.judgeMode == 2)
        {
            // Competition-Free mode will not bring out any result here
            playerBest.text = string.Empty;
            return;
        }
        RecordsManager.Record?record = GetCurrentrecord(songInfo.bmsHash);
        var recordContent            = record.GetValueOrDefault();

        playerBest.text = record.HasValue ? string.Format(
            LanguageLoader.GetText(39),
            recordContent.score,
            recordContent.combos,
            recordContent.playCount,
            recordContent.timeStamp,
            GetFormattedRankString(rankControl, recordContent.score)
            ) : string.Empty;
    }
Example #19
0
        /// <summary>
        /// Initialize the Translator for later use in the application
        /// </summary>
        /// <param name="assemblyHelper">AssemblyHelper that is used to determine the application folder</param>
        /// <param name="languageName">Language to use for initialization</param>
        public void InitTranslator(string languageName, IAssemblyHelper assemblyHelper = null)
        {
            if (assemblyHelper != null)
            {
                _assemblyHelper = assemblyHelper;
            }
            LanguageLoader = BuildLanguageLoader();

            if (string.IsNullOrEmpty(languageName))
            {
                languageName = "english";
            }

            string translationFile = LanguageLoader.GetTranslationFile(languageName);

            _translator = BuildLanguageTranslator(translationFile);
            _translator.FallbackTranslator = BuildLanguageTranslator(Path.Combine(TranslationPath, "english.ini"));

            UserGuideHelper.SetLanguage(languageName);
        }
Example #20
0
        public void SetUp()
        {
            _translationTestHelper = new TranslationTestHelper();

            var a      = Assembly.GetExecutingAssembly();
            var appDir = Path.GetDirectoryName(a.CodeBase.Replace(@"file:///", ""));

            if (appDir == null)
            {
                throw new InvalidDataException("The app dir may never be null");
            }

            _languagePath = _translationTestHelper.FindTranslationFolder();

            Assert.True(Directory.Exists(_languagePath), "Could not find language path: " + _languagePath);

            var languageLoader = new LanguageLoader(_languagePath);

            _translations = languageLoader.GetAvailableLanguages().ToList();

            _settings = new PdfCreatorSettings(new IniStorage());
            _settings.LoadData("settings.ini");

            var assemblyHelper = Substitute.For <IAssemblyHelper>();

            assemblyHelper.GetPdfforgeAssemblyDirectory().Returns(Path.Combine(_languagePath, ".."));

            LoggingHelper.InitConsoleLogger("PDFCreator-TranslationTest", LoggingLevel.Error);
            var settingsProvider = new DefaultSettingsProvider();

            settingsProvider.UpdateSettings(_settings);

            _translationProxy = new MappedTranslationProxy(new TranslationProxy(), _languagePath + "\\_sectionMappings.txt");

            _translationHelper = new TranslationHelper(_translationProxy, settingsProvider, assemblyHelper);
            _translationHelper.InitTranslator(_settings.ApplicationSettings.Language);

            // TODO extact stuff into separate classes, so this test only contains the actual test code
        }
Example #21
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ConfigurationMaster.ContainsKey(SkinHelper.SkinColorConfigurationKey))
                {
                    SkinColorType skin = SkinHelper.StringToSkinColorType(ConfigurationMaster.Get(SkinHelper.SkinColorConfigurationKey));
                    SkinHelper.LoadSkin(skin);
                }

                LanguageLoader.LoadLanguageResource(CultureHelper.Component, CultureHelper.Culture);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Handle(ex);
            }

            LoginModel     model     = new LoginModel();
            LoginViewModel viewModel = new LoginViewModel(model, LoginResultCallback);

            loginView.DataContext = viewModel;
        }
Example #22
0
        private void InitializeUI()
        {
            InitializeComponent();

            foreach (var i in OverlayConfigs)
            {
                overlayManageTabControl1.TabPages.Add(i.Value);
                SelectOverlayNameDisplay();
            }

            if (!DesignMode)
            {
                LanguageLoader.LanguagePatch(this);
            }

            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeNone);
            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeNormal);
            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeCenter);
            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeFill);
            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeUniform);
            ScreenshotBackgroundFillModeComboBox.Items.Add(BackgroundModeUniformToFill);

            IssueBrowser = new ChromiumWebBrowser("https://github.com/lalafellsleep/Aliapoh.Overlay/issues")
            {
                Dock = DockStyle.Fill
            };

            IssueBrowser.BrowserSettings.WebGl = CefState.Disabled;

            // main tab page setting
            OverlayControlTabPage.Dock     = DockStyle.None;
            OverlayControlTabPage.Location = new Point(-2, -2);
            OverlayControlTabPage.Size     = new Size(Width + 4, Height + 4);
            OverlayControlTabPage.Anchor   = (AnchorStyles)(1 | 2 | 4 | 8);

            AutoHideCheckBox.Checked      = SettingManager.GlobalSetting.AutoHide;
            DetectProcessNameTextBox.Text = SettingManager.GlobalSetting.DetectProcessName;
        }
 public Language FindBestLanguage(CultureInfo culture)
 {
     return(LanguageLoader.FindBestLanguage(culture));
 }
 public bool HasTranslation(string language)
 {
     return(LanguageLoader.GetTranslationFileIfExists(language) != null);
 }
 public IEnumerable <Language> GetAvailableLanguages()
 {
     return(LanguageLoader.GetAvailableLanguages());
 }
 /// <summary>
 ///     Initialize an empty translator (i.e. for tests)
 /// </summary>
 public void InitEmptyTranslator()
 {
     _languageLoader = BuildLanguageLoader();
 }
Example #27
0
    void Update()
    {
        bool triggerLoadingbar = bmsLoaded;

        if (bmsLoaded)
        {
            bmsLoaded          = false;
            titleDisplay.text  = bmsManager.Title;
            artistDisplay.text = string.Format(LanguageLoader.GetText(17), bmsManager.Artist, bmsManager.SubArtist.Replace("\n", " / "));
            levelDisplay.text  = bmsManager.PlayLevel.ToString();
            if (startOnLoad)
            {
                if (!bmsManager.BGAEnabled)
                {
                    bmsManager.placeHolderTexture = Texture2D.whiteTexture;
                }
                bmsManager.IsStarted = true;
                startOnLoad          = false;
                gameStarted          = true;
            }
        }
        if (stageFileLoaded)
        {
            stageFileLoaded = false;
            bgTexture.SetTexture(bmsManager.StageFile);
            bgTexture.rawImage.enabled = bmsManager.StageFile != null && !bmsManager.IsStarted;
        }
        if (gameEnded)
        {
            gameEnded = false;
            if (!Loader.listenMode)
            {
                panel.gameObject.SetActive(true);
                if (Loader.judgeMode != 2)
                {
                    resultText.text = "";
                    detailsPanel.gameObject.SetActive(true);
                    for (int i = 0; i < resultCountText.Length; i++)
                    {
                        resultCountText[i].text = bmsManager.GetNoteScoreCount(i).ToString("\\x0");
                    }
                    resultComboText.text = bmsManager.MaxCombos.ToString("\\x0");
                    resultScoreText.text = bmsManager.Score.ToString("0000000");
                    resultRankText.text  = string.Format(
                        "<color=#{0}>{1}</color>",
                        ColorUtility.ToHtmlStringRGBA(bmsManager.RankColor),
                        bmsManager.RankString
                        );
                }
                bgTexture.rawImage.enabled = bgTexture.rawImage.texture != null;
                if (graphDisplay)
                {
                    if (graphHandler)
                    {
                        graphDisplay.texture = graphHandler.Texture;
                    }
                    graphDisplay.enabled = graphDisplay.texture;
                }
                var recordsManager = RecordsManager.Instance;
                if (Loader.judgeMode == 2)
                {
                    var  hash        = bmsManager.GetHash(SongInfoLoader.CurrentEncoding, recordsManager.HashAlgorithm);
                    int  channelHash = RecordsManager.GetAdoptedChannelHash(bmsManager.GetAllAdoptedChannels());
                    var  records     = recordsManager.GetRecord(hash, channelHash);
                    bool pass        = bmsManager.Score >= bmsManager.MaxScore / 2;
                    if (pass && records != null)
                    {
                        pass = bmsManager.Score >= records.Value.score;
                    }
                    resultText.text = LanguageLoader.GetText(pass ? 33 : 34);
                    detailsPanel.gameObject.SetActive(false);
                }
                if (!Loader.autoMode)
                {
                    recordsManager.CreateRecord(bmsManager);
                }
            }
            SetPauseButton();
        }
        if (gameStarted)
        {
            gameStarted = false;
            panel.gameObject.SetActive(false);
            pausePanel.gameObject.SetActive(false);
            dummyBGA.SetActive(bmsManager.BGAEnabled);
            bgTexture.rawImage.enabled = false;
            SetPauseButton();
        }
        if (pauseChanged)
        {
            pauseChanged = false;
            pausePanel.gameObject.SetActive(bmsManager.IsPaused);
            SetPauseButton();
        }
        if (backgroundChanged)
        {
            backgroundChanged = false;
            dummyBGA.SetActive(false);
        }
        float t = Time.deltaTime * 10;

        if (bmsManager.Score < displayingScore)
        {
            displayingScore = bmsManager.Score;
        }
        displayingScore   = Mathf.CeilToInt(Mathf.Lerp(displayingScore, bmsManager.Score, t));
        scoreDisplay.text = displayingScore.ToString("0000000");

        if (targetCombos != bmsManager.Combos)
        {
            combosValue  = combosValue + bmsManager.Combos - targetCombos;
            targetCombos = bmsManager.Combos;
        }
        else
        {
            combosValue = Mathf.Lerp(combosValue, 0, t / 4);
        }
        if (displayCombos < targetCombos)
        {
            displayCombos = targetCombos;
        }
        displayCombos     = Mathf.FloorToInt(Mathf.Lerp(displayCombos, bmsManager.Combos, t));
        comboDisplay.text = (bmsManager.IsStarted && displayCombos >= 3) ? displayCombos.ToString() : "";
        comboDisplay.transform.localScale = Vector3.one * (1 + Mathf.Log(Mathf.Max(0, combosValue) + 1, 8));
        if (bmsManager.IsLoadingResources || triggerLoadingbar)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.LoadResourceProgress;
            durationBar.anchorMax = anchorMax;
        }
        else if (bmsManager.IsStarted)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.PercentageTimePassed;
            durationBar.anchorMax = anchorMax;
        }
        float deltaTime = Time.unscaledDeltaTime;

        if (fpsBar)
        {
            UpdateVerticalBar(fpsBar, deltaTime * 10F);
        }
        if (fpsText)
        {
            fpsText.text = string.Format("{0:0} FPS", 1 / deltaTime);
        }
        if (polyphonyBar)
        {
            UpdateVerticalBar(polyphonyBar, bmsManager.Polyphony / 255F);
        }
        if (polyphonyText)
        {
            polyphonyText.text = string.Format("{0} POLY", bmsManager.Polyphony);
        }
        if (accuracyBar)
        {
            UpdateHorzBar(accuracyBar, bmsManager.Accuracy / 50F);
        }
        if (accuracyText)
        {
            accuracyText.text = string.Format("{0:+0000;-0000}MS", bmsManager.Accuracy);
        }
        if (bpmText)
        {
            bpmText.text = string.Format(
                bpmFormatText, bmsManager.BPM,
                ColorUtility.ToHtmlStringRGBA(
                    Color.Lerp(bpmText.color, bpmLightColor, bpmLightLerp)
                    ));
        }
    }
Example #28
0
 /// <summary>
 /// Initialize an empty translator (i.e. for tests)
 /// </summary>
 public void InitEmptyTranslator()
 {
     _translator     = new BasicTranslator("empty", Data.CreateDataStorage());
     _languageLoader = BuildLanguageLoader();
 }
Example #29
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                #region 测试版

#if DEBUG
                try
                {
                    var      apiHelper = new ApiHelper();
                    DateTime now       = apiHelper.GetDate(DateType.SysDate);
                    if (now > AboutBox.PublishDate.AddMonths(1)) //发布一个月失效
                    {
                        SplashScreen.CloseSplashScreen();
                        MsgBox.ShowErrorMessage("该测试版已失效,请下在最新版!");
                        OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl);
                        Exit_Click(Exit, new EventArgs());
                    }
                }
                catch (WebException)
                {
                    Config.InitErrorInfo = Config.LocalLanguage.Messages.InitializeFailed + "," +
                                           Config.LocalLanguage.Messages.PleaseCheckNetworkSettingsAreCorrect;
                }
#endif

                #endregion

                #region

                _languageLoader         = new LanguageLoader();
                TimerAutoSwitchingProxy = new Timer();
                TimerAutoChangeIcon     = new Timer();

                //SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDatabase);
                //Config.InitDatabase();

                _deserializeDockContent = GetContentFromPersistString;

                SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingLanguages);
                Config.LanguageFileName = Config.LocalSetting.LanguageFileName;
                if (System.IO.File.Exists(Config.LanguageFileName))
                {
                    Config.LocalLanguage = XmlHelper.XmlDeserialize(
                        Config.LanguageFileName,
                        typeof(Language)) as Language;
                }
                LoadLanguage();

                #endregion

                #region 初始化配置

                GetNetConfigAndCheckVersion();

                #endregion

                #region 连接云引擎

                try
                {
                    DelegateVoid dv    = ConnectCloud;
                    var          thred = new Thread(new ThreadStart(dv));
                    thred.Start();
                }
                catch
                {
                    if (Config.LocalLanguage != null)
                    {
                        CloudStatus.Text = Config.LocalLanguage.Messages.ConnectCloudEngineFailed;
                    }
                    CloudStatus.Image = Resources.cloudno;
                }

                #endregion

                #region Hotkey

                //Hotkey hotkey = new Hotkey(this.Handle);
                //Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.T, Hotkey.KeyFlags.MOD_CONTROL);
                //hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey);

                #endregion

                #region UI

                MainToolbar.Visible = false;
                MainStatusBar.Items.Insert(2, new ToolStripSeparator());
                MainStatusBar.Items.Insert(4, new ToolStripSeparator());
                MainStatusBar.Items.Insert(6, new ToolStripSeparator());
                MainStatusBar.Items.Insert(8, new ToolStripSeparator());
                MainStatusBar.Items.Insert(10, new ToolStripSeparator());
                tsslVersion.Text = @"Version:" + Assembly.GetExecutingAssembly().GetName().Version;
                if (Config.LocalLanguage != null)
                {
                    CloudStatus.Text = Config.LocalLanguage.Messages.ConnectingCloudEngine;
                }

                _httpHelper.HttpOption.Timeout = 60 * 1000;

                SetProxyStatusLabel();
                if (Config.LocalLanguage != null)
                {
                    AutoSwitchProxyStatus.Text = Config.LocalLanguage.Messages.AutomaticSwitchingOff;
                }
                Status.Text   = Config.InitErrorInfo;
                Status.Spring = true;

                #endregion

                #region timer

                TimerAutoSwitchingProxy.Enabled  = false;
                TimerAutoSwitchingProxy.Interval = 1000;
                TimerAutoSwitchingProxy.Elapsed += timerAutoSwitchingProxy_Elapsed;

                TimerAutoChangeIcon.Enabled  = false;
                TimerAutoChangeIcon.Interval = 1000;
                TimerAutoChangeIcon.Elapsed += timerAutoChangeIcon_Elapsed;

                #endregion

                #region DockPanel

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDockPanel);
                    if (System.IO.File.Exists(Config.DockSettingFileName))
                    {
                        try
                        {
                            MainDockPanel.LoadFromXml(Config.DockSettingFileName, _deserializeDockContent);
                        }
                        catch
                        {
                            _hasDockSettingExceptioin = true;
                            if (System.IO.File.Exists(Config.DockSettingFileName))
                            {
                                SplashScreen.CloseSplashScreen();
                                System.IO.File.Delete(Config.DockSettingFileName);
                                MsgBox.ShowErrorMessage(Config.LocalLanguage.Messages.InitializeFailed);
                                Application.Exit();
                            }
                        }
                    }
                    else
                    {
                        #region dock

                        StartPage.Show(MainDockPanel, DockState.Document);
                        InfoPage.Show(MainDockPanel, DockState.DockBottomAutoHide);
                        InfoPage.Hide();
                        ProxyPage.Show(MainDockPanel, DockState.Document);

                        #endregion
                    }
                }

                #endregion

                #region

                LoadViewSetting();

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.CheckUpdate);
                }
                CheckVersionAndDownLoad();

                #region 读取上次代理

                if (System.IO.File.Exists(Config.LastProxyFileName))
                {
                    ProxyData.ProxyList =
                        (List <ProxyServer>)
                        XmlHelper.XmlDeserialize(Config.LastProxyFileName, typeof(List <ProxyServer>));
                    ProxyPage.BindData();
                }

                #endregion

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingPlugins);
                }
                PluginManager.LoadAllPlugins();
                //如果没有获取代理网页列表,则禁止使用
#if !DEBUG
                if (Config.ProxySiteUrlList.Count == 0)
                {
                    this.ProxyPage.Enabled = false;
                }
#endif

                SplashScreen.CloseSplashScreen();
                StartPage.Activate();
                Activate();
                if (Config.ProxyHeroCloudSetting.EnableCommercialPage == "1") //如果显示弹出广告
                {
#if !DEBUG
                    if (Config.IsChineseOs)
                    {
                        this.OpenNewTab(Config.ProxyHeroCloudSetting.CommercialUrl);
                    }
                    else
                    {
                        this.OpenNewTab(Config.ProxyHeroCloudSetting.EnglishCommercialUrl);
                    }
#else
                    OpenNewTab(Config.IsChineseLanguage
                                   ? Config.ProxyHeroCloudSetting.CommercialUrl
                                   : Config.ProxyHeroCloudSetting.EnglishCommercialUrl);
#endif
                }

                #endregion
            }
            catch (Exception ex)
            {
                SplashScreen.CloseSplashScreen();
                MsgBox.ShowExceptionMessage(ex);
            }
        }
Example #30
0
 public IEnumerable <Language> GetAvailableLanguages()
 {
     return(LanguageLoader.GetAvailableLanguages().OrderBy(t => t.NativeName));
 }