示例#1
0
        private static IEnumerable <string> SanitizeByLanguage(
            IEnumerable <string> unsanitizedStrings, ClientLanguage clientLanguage)
        {
            var sanitizedStrings = new List <string>();

            switch (clientLanguage)
            {
            case ClientLanguage.Japanese:
            case ClientLanguage.English:
                sanitizedStrings.AddRange(unsanitizedStrings.Select(FilterUnprintableCharacters));
                return(sanitizedStrings);

            case ClientLanguage.German:
                sanitizedStrings.AddRange(
                    unsanitizedStrings.Select(
                        unsanitizedString =>
                        FilterByDict(FilterUnprintableCharacters(unsanitizedString), DESanitizationDict)));
                return(sanitizedStrings);

            case ClientLanguage.French:
                sanitizedStrings.AddRange(
                    unsanitizedStrings.Select(
                        unsanitizedString =>
                        FilterByDict(FilterUnprintableCharacters(unsanitizedString), FRSanitizationDict)));
                return(sanitizedStrings);

            default:
                throw new ArgumentOutOfRangeException(nameof(clientLanguage), clientLanguage, null);
            }
        }
示例#2
0
        private void ParseTeleporterFile(string filePath)
        {
            try
            {
                const string teleporterLanguageString = "\"teleporterlanguage\":";

                var content = File.ReadAllText(filePath).ToLowerInvariant();
                var idx     = content.IndexOf(teleporterLanguageString);
                if (idx < 0)
                {
                    return;
                }

                content = content.Substring(idx + teleporterLanguageString.Length).Trim();
                if (content.Length < 1)
                {
                    return;
                }

                _teleporterLanguage = content[0] switch
                {
                    '0' => ClientLanguage.Japanese,
                    '1' => ClientLanguage.English,
                    '2' => ClientLanguage.German,
                    '3' => ClientLanguage.French,
                    _ => _language,
                };
            }
            catch (Exception e)
            {
                PluginLog.Error($"Could not read Teleporter Config:\n{e}");
                _teleporterLanguage = _language;
            }
        }
示例#3
0
        private static string GenerateFrontierReferer(ClientLanguage language)
        {
            var langCode      = language.GetLangCode();
            var formattedTime = GetLauncherFormattedTime();

            return($"https://frontier.ffxiv.com/version_5_0_win/index.html?rc_lang={langCode}&time={formattedTime}");
        }
示例#4
0
    private static string GenerateFrontierReferer(ClientLanguage language)
    {
        var langCode      = language.GetLangCode().Replace("-", "_");
        var formattedTime = GetLauncherFormattedTimeLong();

        return($"https://launcher.finalfantasyxiv.com/v610/index.html?rc_lang={langCode}&time={formattedTime}");
    }
示例#5
0
        //public string[] ToCommonSpec(ServiceSpec spec, string dir)
        //{
        //    throw new NotImplementedException();

        //}

        //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType)
        //{
        //    var generator = IdlGenerator.GetInstance(targetType);
        //    Assembly asm = Assembly.LoadFrom(spec);
        //    generator.Generate(asm);
        //    ServiceSpec serviceSpec = new ServiceSpec();
        //    // FIXME
        //    serviceSpec.SType = targetType;
        //    serviceSpec.Directory = ".";
        //    serviceSpec.MainSpecFile = "";
        //    serviceSpec.ReferencedSpecFiles = null;
        //    return serviceSpec;
        //}


        public FlowErrorCode GenerateServiceClient(
            ServiceSpec spec,
            string dir,
            ClientLanguage lang,
            ClientPlatform platform,
            out LinkageInfo linkInfo
            )
        {
            if (!spec.IsRdsnRpc)
            {
                throw new NotImplementedException();
            }
            linkInfo = new LinkageInfo();
            var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile);

            if (
                SystemHelper.RunProcess("php.exe",
                                        Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " +
                                        Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0)
            {
                return(FlowErrorCode.ProcessStartFailed);
            }
            linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs"));
            linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs"));
            linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs"));
            linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs"));
            linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll"));
            linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll"));
            linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll"));
            return(FlowErrorCode.Success);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (CoreVersion.Length != 0)
            {
                hash ^= CoreVersion.GetHashCode();
            }
            if (RobotVersion.Length != 0)
            {
                hash ^= RobotVersion.GetHashCode();
            }
            if (ClientVersion.Length != 0)
            {
                hash ^= ClientVersion.GetHashCode();
            }
            if (ClientLanguage.Length != 0)
            {
                hash ^= ClientLanguage.GetHashCode();
            }
            if (DriverVersion.Length != 0)
            {
                hash ^= DriverVersion.GetHashCode();
            }
            if (DriverLanguage.Length != 0)
            {
                hash ^= DriverLanguage.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#7
0
 //public string[] ToCommonSpec(ServiceSpec spec, string dir)
 //{
 //    throw new NotImplementedException();
 //}
 //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType)
 //{
 //    var generator = IdlGenerator.GetInstance(targetType);
 //    Assembly asm = Assembly.LoadFrom(spec);
 //    generator.Generate(asm);
 //    ServiceSpec serviceSpec = new ServiceSpec();
 //    // FIXME
 //    serviceSpec.SType = targetType;
 //    serviceSpec.Directory = ".";
 //    serviceSpec.MainSpecFile = "";
 //    serviceSpec.ReferencedSpecFiles = null;
 //    return serviceSpec;
 //}
 public FlowErrorCode GenerateServiceClient(
     ServiceSpec spec,
     string dir,
     ClientLanguage lang,
     ClientPlatform platform,
     out LinkageInfo linkInfo
     )
 {
     if (!spec.IsRdsnRpc) throw new NotImplementedException();
     linkInfo = new LinkageInfo();
     var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile);
     if (
         SystemHelper.RunProcess("php.exe",
              Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " +
             Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0)
         return FlowErrorCode.ProcessStartFailed;
     linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs"));
     linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs"));
     linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs"));
     linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs"));
     linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll"));
     linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll"));
     linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll"));
     return FlowErrorCode.Success;
 }
示例#8
0
 public void Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess        = gameProcess;
     _gamePath           = setting.GamePath;
     _language           = setting.Language.GetValueOrDefault(ClientLanguage.English);
     _optOutMbCollection = setting.OptOutMbCollection.GetValueOrDefault();;
 }
示例#9
0
        public DataManager(ClientLanguage language)
        {
            // Set up default values so plugins do not null-reference when data is being loaded.
            this.ServerOpCodes = new ReadOnlyDictionary <string, ushort>(new Dictionary <string, ushort>());

            this.language = language;
        }
示例#10
0
        private static readonly uint[] _privateHouseIds = { 59, 60, 61, 97 }; //limsa, gridania, uldah, kugane

        internal static string GetAetheryteName(uint id, byte subIndex, ClientLanguage language)
        {
            if (!AetheryteNames.TryGetValue(language, out var list))
            {
                return(string.Empty);
            }
            if (!list.TryGetValue(id, out var name))
            {
                return(string.Empty);
            }
            if (!_privateHouseIds.Contains(id))
            {
                return(name);
            }

            switch (subIndex)
            {
            case 0:     //use default name
                return(name);

            case 128:
                return(_apartmentNames[language]);

            case var n when n >= 1 && n <= 127:
                return(_sharedHouseNames[language].Replace("<number>", $"{subIndex}"));

            default:
                return($"Unknown Estate ({id}, {subIndex})");
            }
        }
示例#11
0
        private static string GenerateFrontierReferer(ClientLanguage language)
        {
            var langCode      = language.GetLangCode();
            var formattedTime = DateTime.UtcNow.ToString("yyyy-MM-dd-HH");

            return($"https://frontier.ffxiv.com/version_5_0_win/index.html?rc_lang={langCode}&time={formattedTime}");
        }
示例#12
0
        /// <summary>
        /// Set up client state access.
        /// </summary>
        /// <param name="dalamud">Dalamud instance</param>
        /// /// <param name="startInfo">StartInfo of the current Dalamud launch</param>
        /// <param name="scanner">Sig scanner</param>
        public ClientState(Dalamud dalamud, DalamudStartInfo startInfo, SigScanner scanner)
        {
            this.dalamud = dalamud;
            Address      = new ClientStateAddressResolver();
            Address.Setup(scanner);

            Log.Verbose("===== C L I E N T  S T A T E =====");

            this.ClientLanguage = startInfo.Language;

            this.Actors = new ActorTable(dalamud, Address);

            this.PartyList = new PartyList(dalamud, Address);

            this.JobGauges = new JobGauges(Address);

            this.KeyState = new KeyState(Address, scanner.Module.BaseAddress);

            this.Condition = new Condition(Address);

            this.Targets = new Targets(dalamud, Address);

            Log.Verbose("SetupTerritoryType address {SetupTerritoryType}", Address.SetupTerritoryType);

            this.setupTerritoryTypeHook = new Hook <SetupTerritoryTypeDelegate>(Address.SetupTerritoryType,
                                                                                new SetupTerritoryTypeDelegate(SetupTerritoryTypeDetour),
                                                                                this);

            dalamud.Framework.OnUpdateEvent += FrameworkOnOnUpdateEvent;
            dalamud.NetworkHandlers.CfPop   += NetworkHandlersOnCfPop;
        }
示例#13
0
        public CommandManager(Dalamud dalamud, ClientLanguage language)
        {
            this.dalamud = dalamud;

            switch (language)
            {
            case ClientLanguage.Japanese:
                this.currentLangCommandRegex = this.commandRegexJp;
                break;

            case ClientLanguage.English:
                this.currentLangCommandRegex = this.commandRegexEn;
                break;

            case ClientLanguage.German:
                this.currentLangCommandRegex = this.commandRegexDe;
                break;

            case ClientLanguage.French:
                this.currentLangCommandRegex = this.commandRegexFr;
                break;
            }

            dalamud.Framework.Gui.Chat.OnCheckMessageHandled += OnCheckMessageHandled;
        }
示例#14
0
 private void ChangeMajorLanguage(Settings.Channel channel, ClientLanguage language)
 {
     if (ironworksSettings != null)
     {
         channel.MajorLanguage = language;
     }
 }
示例#15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataManager"/> class.
        /// </summary>
        /// <param name="language">The language to load data with by default.</param>
        /// <param name="interfaceManager">An <see cref="InterfaceManager"/> instance to parse the data with.</param>
        internal DataManager(ClientLanguage language, InterfaceManager interfaceManager)
        {
            this.interfaceManager = interfaceManager;
            // Set up default values so plugins do not null-reference when data is being loaded.
            this.ServerOpCodes = new ReadOnlyDictionary <string, ushort>(new Dictionary <string, ushort>());

            this.Language = language;
        }
示例#16
0
    public object?LaunchGame(IGameRunner runner, string sessionId, int region, int expansionLevel,
                             bool isSteamServiceAccount, string additionalArguments,
                             DirectoryInfo gamePath, bool isDx11, ClientLanguage language,
                             bool encryptArguments, DpiAwareness dpiAwareness)
    {
        Log.Information(
            $"XivGame::LaunchGame(steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

        var exePath = Path.Combine(gamePath.FullName, "game", "ffxiv_dx11.exe");

        if (!isDx11)
        {
            exePath = Path.Combine(gamePath.FullName, "game", "ffxiv.exe");
        }

        var environment = new Dictionary <string, string>();

        var argumentBuilder = new ArgumentBuilder()
                              .Append("DEV.DataPathType", "1")
                              .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                              .Append("DEV.TestSID", sessionId)
                              .Append("DEV.UseSqPack", "1")
                              .Append("SYS.Region", region.ToString())
                              .Append("language", ((int)language).ToString())
                              .Append("resetConfig", "0")
                              .Append("ver", Repository.Ffxiv.GetVer(gamePath));

        if (isSteamServiceAccount)
        {
            // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
            environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
            argumentBuilder.Append("IsSteam", "1");
        }

        // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure
        if (!string.IsNullOrEmpty(additionalArguments))
        {
            var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled);
            foreach (Match match in regex.Matches(additionalArguments))
            {
                argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value);
            }
        }

        if (!File.Exists(exePath))
        {
            throw new BinaryNotPresentException(exePath);
        }

        var workingDir = Path.Combine(gamePath.FullName, "game");

        var arguments = encryptArguments
            ? argumentBuilder.BuildEncrypted()
            : argumentBuilder.Build();

        return(runner.Start(exePath, workingDir, arguments, environment, dpiAwareness));
    }
示例#17
0
 public static Regexes FromLanguage(ClientLanguage lang)
 {
     return(lang switch
     {
         ClientLanguage.English => new Regexes(true),
         ClientLanguage.German => new Regexes(true, true),
         ClientLanguage.French => new Regexes(true, true, true),
         ClientLanguage.Japanese => new Regexes(true, true, true, true),
         _ => throw new InvalidEnumArgumentException(),
     });
示例#18
0
 public DalamudLauncher(IDalamudRunner runner, DalamudUpdater updater, DalamudLoadMethod loadMethod, DirectoryInfo gamePath, DirectoryInfo configDirectory, ClientLanguage clientLanguage, int injectionDelay)
 {
     this.runner          = runner;
     this.updater         = updater;
     this.loadMethod      = loadMethod;
     this.gamePath        = gamePath;
     this.configDirectory = configDirectory;
     this.language        = clientLanguage;
     this.injectionDelay  = injectionDelay;
 }
示例#19
0
        public byte[] DownloadAsLauncher(string url, ClientLanguage language)
        {
            using (var client = new WebClient())
            {
                client.Headers.Add("User-Agent", _userAgent);
                client.Headers.Add(HttpRequestHeader.Referer, GenerateFrontierReferer(language));

                return(client.DownloadData(url));
            }
        }
示例#20
0
 /// <summary>
 /// Converts a Dalamud ClientLanguage to the corresponding Lumina variant.
 /// </summary>
 /// <param name="language">Langauge to convert.</param>
 /// <returns>Converted langauge.</returns>
 public static Lumina.Data.Language ToLumina(this ClientLanguage language)
 {
     return(language switch
     {
         ClientLanguage.Japanese => Lumina.Data.Language.Japanese,
         ClientLanguage.English => Lumina.Data.Language.English,
         ClientLanguage.German => Lumina.Data.Language.German,
         ClientLanguage.French => Lumina.Data.Language.French,
         _ => throw new ArgumentOutOfRangeException(nameof(language)),
     });
        public string TranslateChat(string sentence, ClientLanguage from)
        {
            if (IronworksSettings.Instance == null)
            {
                throw new Exception("IronworksSettings is null");
            }
            string tk = "ko";

            foreach (var item in LanguageCodeList.papago)
            {
                if (IronworksSettings.Instance.Translator.NativeLanguage.ToString().Equals(item.NameEnglish))
                {
                    tk = item.Code;
                }
            }
            string sk = "ja";

            foreach (var item in LanguageCodeList.papago)
            {
                if (from.ToString().Equals(item.NameEnglish))
                {
                    sk = item.Code;
                }
            }
            string testUrl = $"https://papago.naver.com/?sk={sk}&tk={tk}&st={Uri.EscapeDataString(sentence)}";

            lock (driver)
            {
                //Log.Debug($"Translate URL: {testUrl}");
                Log.Debug($"Locked web browser for {sentence}");
                driver.Url = testUrl;
                driver.Navigate();
                //the driver can now provide you with what you need (it will execute the script)
                //get the source of the page
                //var source = driver.PageSource;
                string translated = string.Copy(sentence);
                //fully navigate the dom
                try
                {
                    OpenQA.Selenium.IWebElement pathElement;
                    do
                    {
                        pathElement = driver.FindElementById("txtTarget");
                    } while (pathElement.Text.Equals(""));
                    translated = pathElement.Text;
                    Log.Debug($"Successfully translated {sentence} -> {translated}");
                }
                catch (Exception e)
                {
                    Log.Error($"Exception {e.Message} when translating {sentence}");
                    translated = translated.Insert(0, "[원문]");
                }
                return(translated);
            }
        }
示例#22
0
        private string GetLanguageName(ClientLanguage lang)
        {
            var map = new Dictionary <ClientLanguage, string>()
            {
                { ClientLanguage.Client_CPlusPlus, "c++" },
                { ClientLanguage.Client_CSharp, "c#" },
                { ClientLanguage.Client_Java, "java" },
            };

            return(map.ContainsKey(lang) ? map[lang] : "");
        }
示例#23
0
 public FlowErrorCode GenerateServiceSketch(
     ServiceSpec spec,
     string dir,
     ClientLanguage lang,
     ClientPlatform platform,
     out LinkageInfo linkInfo
     )
 {
     linkInfo = null;
     return(FlowErrorCode.Success);
 }
        public static void SetLanguage(ClientLanguage language)
        {
            int previousLanguage = Properties.Settings.Default.Language;

            Properties.Settings.Default.Language = (int)language;

            if (previousLanguage != (int)language)
            {
                LanguageChanged?.Invoke();
            }
        }
示例#25
0
 public static string GetSourceExtension(ClientLanguage lang)
 {
     var map = new Dictionary<ClientLanguage, string>
     {
          {ClientLanguage.Client_CPlusPlus, "cpp"},
          {ClientLanguage.Client_CSharp, "cs"},
          {ClientLanguage.Client_Java, "java"},
          {ClientLanguage.Client_Python, "py"},
          {ClientLanguage.Client_Javascript, "js"}
      };
     return map.ContainsKey(lang) ? map[lang] : "";
 }
示例#26
0
 public Gatherer(DalamudPluginInterface pi, GatherBuddyConfiguration config, CommandManager commandManager)
 {
     _commandManager = commandManager;
     _chat           = pi.Framework.Gui.Chat;
     _language       = pi.ClientState.ClientLanguage;
     _configuration  = config;
     _world          = new World(pi, _configuration);
     _groups         = TimedGroup.CreateGroups(_world);
     Timeline        = new NodeTimeLine(_world.Nodes);
     Alarms          = new AlarmManager(pi, _world.Nodes, _configuration);
     TryCreateTeleporterWatcher(pi, _configuration.UseTeleport);
 }
示例#27
0
        /// <summary>
        /// Get an <see cref="ExcelSheet{T}"/> with the given Excel sheet row type with a specified language.
        /// </summary>
        /// <param name="language">Language of the sheet to get.</param>
        /// <typeparam name="T">The excel sheet type to get.</typeparam>
        /// <returns>The <see cref="ExcelSheet{T}"/>, giving access to game rows.</returns>
        public ExcelSheet <T> GetExcelSheet <T>(ClientLanguage language) where T : IExcelRow
        {
            var lang = language switch {
                ClientLanguage.Japanese => Language.Japanese,
                ClientLanguage.English => Language.English,
                ClientLanguage.German => Language.German,
                ClientLanguage.French => Language.French,
                _ => throw new ArgumentOutOfRangeException(nameof(this.language), "Unknown Language: " + this.language)
            };

            return(this.Excel.GetSheet <T>(lang));
        }
示例#28
0
 public void Load()
 {
     using var currentUserKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32);
     using var key            = currentUserKey.CreateSubKey(@"SOFTWARE\WebZen\Mu\Config");
     this.ClientColorDepth    = (ClientColorDepth)(key.GetValue("ColorDepth") ?? 0);
     this.IsMusicEnabled      = (int)(key.GetValue("MusicOnOff") ?? 0) == 1;
     this.IsSoundEnabled      = (int)(key.GetValue("SoundOnOff") ?? 0) == 1;
     this.VolumeLevel         = (int)(key.GetValue("VolumeLevel") ?? 0);
     this.IsWindowModeActive  = (int)(key.GetValue("WindowMode") ?? 0) == 1;
     this.Resolution          = (ClientResolution)(key.GetValue("Resolution") ?? 0);
     this.LangSelection       = ((string?)key.GetValue("LangSelection") ?? DefaultLanguage).GetLanguage();
 }
        private string ClientLanguageToLangCode(ClientLanguage clientLanguage)
        {
            string langCode = clientLanguage switch
            {
                ClientLanguage.Japanese => "ja",
                ClientLanguage.German => "de",
                ClientLanguage.French => "fr",
                _ => "en"
            };

            return(langCode);
        }
    }
示例#30
0
        public static string GetSourceExtension(ClientLanguage lang)
        {
            var map = new Dictionary <ClientLanguage, string>
            {
                { ClientLanguage.Client_CPlusPlus, "cpp" },
                { ClientLanguage.Client_CSharp, "cs" },
                { ClientLanguage.Client_Java, "java" },
                { ClientLanguage.Client_Python, "py" },
                { ClientLanguage.Client_Javascript, "js" }
            };

            return(map.ContainsKey(lang) ? map[lang] : "");
        }
示例#31
0
        private string GetLanguageName(ClientLanguage lang)
        {
            var map = new Dictionary <ClientLanguage, string>
            {
                { ClientLanguage.Client_CPlusPlus, "cpp" },
                { ClientLanguage.Client_CSharp, "csharp" },
                { ClientLanguage.Client_Java, "java" },
                { ClientLanguage.Client_Javascript, "js" },
                { ClientLanguage.Client_Python, "py" }
            };

            return(map.ContainsKey(lang) ? map[lang] : "");
        }
示例#32
0
        /// <summary>
        /// Get a <see cref="TexFile"/> containing the icon with the given ID, of the given language.
        /// </summary>
        /// <param name="iconLanguage">The requested language.</param>
        /// <param name="iconId">The icon ID.</param>
        /// <returns>The <see cref="TexFile"/> containing the icon.</returns>
        public TexFile GetIcon(ClientLanguage iconLanguage, int iconId)
        {
            var type = iconLanguage switch {
                ClientLanguage.Japanese => "ja/",
                ClientLanguage.English => "en/",
                ClientLanguage.German => "de/",
                ClientLanguage.French => "fr/",
                _ => throw new ArgumentOutOfRangeException(nameof(this.language),
                                                           "Unknown Language: " + this.language)
            };

            return(GetIcon(type, iconId));
        }
示例#33
0
        /// <summary>
        ///     Set language based on selection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClientLang_radioClick(object sender, EventArgs e)
        {
            foreach (
                var radio in
                clientLanguage.Controls.Cast<Control>()
                    .Select(control => control as RadioButton)
                    .Where(radio => radio.Checked))
                _clientLanguage = (ClientLanguage) Convert.ToInt32(radio.Tag);

            SetLanguage();

            LoadRecipes();

            LoadLeves();

            SetMeals();

            SetComboxbox();

            UpdateUi();

            // MessageBox.Show("Language is changed to " + _clientLanguage.ToString());
        }
示例#34
0
 private string GetLanguageName(ClientLanguage lang)
 {
     Dictionary<ClientLanguage, string> map = new Dictionary<ClientLanguage, string>()
     {
         {ClientLanguage.Client_CPlusPlus, "c++"},
         {ClientLanguage.Client_CSharp, "c#"},
         {ClientLanguage.Client_Java, "java"},
     };
     if (map.ContainsKey(lang))
     {
         return map[lang];
     }
     else
     {
         return "";
     }
 }
示例#35
0
        public FlowErrorCode GenerateServiceSketch(
                ServiceSpec spec,
                string dir,
                ClientLanguage lang,
                ClientPlatform platform,
                out LinkageInfo linkInfo
                )
        {
            var compiler = LanguageHelper.GetCompilerPath(GetType());
            linkInfo = new LinkageInfo();
            if (compiler == "")
            {

                return FlowErrorCode.SpecCompilerNotFound;
            }

            if (platform != ClientPlatform.Windows)
            {
                Console.WriteLine("Bond compiler only supports windows platform!");
                return FlowErrorCode.PlatformNotSupported;
            }

            // hack for C# for the time being
            if (lang == ClientLanguage.Client_CSharp)
            {
                linkInfo.IncludeDirectories.Add(dir);
                linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName);
                linkInfo.LibraryPaths.Add(dir);

                linkInfo.DynamicLibraries.AddRange(new List<string>()
                            {
                                "Microsoft.Bond.dll",
                                "Microsoft.Bond.Rpc.dll",
                                "Microsoft.Bond.Interfaces.dll",
                                "Microsoft.Bond.TypeProvider.dll",
                            });
                linkInfo.Sources = FromAllSpecToSources(
                        Path.Combine(spec.Directory, spec.MainSpecFile),
                        spec.ReferencedSpecFiles.Select(rs => Path.Combine(spec.Directory, rs)),
                        dir,
                        new[] { GeneratedFileType.TYPES, GeneratedFileType.SERVICES },
                        new[] { GeneratedFileType.TYPES }
                    )
                    .Select(Path.GetFileName)
                    .ToList();

                return FlowErrorCode.Success;
            }

            var arguments = new List<string>
            {
                " ",
                "/" + GetLanguageName(lang),
                "/I:" + spec.Directory,
                "/O:" + dir,
                Path.Combine(spec.Directory, spec.MainSpecFile)
            };

            if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) == 0)
            {

                switch (lang)
                {
                    case ClientLanguage.Client_CSharp:
                        {
                            linkInfo.IncludeDirectories.Add(dir);
                            linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName);
                            linkInfo.LibraryPaths.Add(dir);

                            linkInfo.DynamicLibraries.AddRange(new List<string>()
                            {
                                "Microsoft.Bond.dll",
                                "Microsoft.Bond.Rpc.dll",
                                "Microsoft.Bond.Interfaces.dll",
                                "Microsoft.Bond.TypeProvider.dll",
                            });
                            var specName = Path.GetFileNameWithoutExtension(spec.MainSpecFile);
                            var searchPattern = specName + "_*." + LanguageHelper.GetSourceExtension(lang);
                            linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName));
                            break;
                        }

                    case ClientLanguage.Client_CPlusPlus:
                        {
                            var bondHeaders = Path.GetPathRoot(compiler);
                            linkInfo.IncludeDirectories.Add(dir);
                            linkInfo.IncludeDirectories.Add(bondHeaders);
                            var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang);
                            linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15));
                            break;
                        }
                    case ClientLanguage.Client_Java:
                        {
                            // FIXME: when generate java code, bondc will generate a subdir
                            linkInfo.IncludeDirectories.Add(dir);
                            var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang);
                            linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15));
                            break;
                        }
                    default:
                        break;

                }

                return FlowErrorCode.Success;
            }
            else
            {
                return FlowErrorCode.ExceptionError;
            }
        }
示例#36
0
 private string GetLanguageName(ClientLanguage lang)
 {
     var map = new Dictionary<ClientLanguage, string>()
     {
         {ClientLanguage.Client_CPlusPlus, "c++"},
         {ClientLanguage.Client_CSharp, "c#"},
         {ClientLanguage.Client_Java, "java"},
     };
     return map.ContainsKey(lang) ? map[lang] : "";
 }
示例#37
0
 public FlowErrorCode GenerateServiceSketch(
     ServiceSpec spec,
     string dir,
     ClientLanguage lang,
     ClientPlatform platform,
     out LinkageInfo linkInfo
     )
 {
     linkInfo = null;
     return FlowErrorCode.Success;
 }
示例#38
0
 private string GetLanguageName(ClientLanguage lang)
 {
     var map = new Dictionary<ClientLanguage, string>
     {
         {ClientLanguage.Client_CPlusPlus, "cpp"},
         {ClientLanguage.Client_CSharp, "csharp"},
         {ClientLanguage.Client_Java, "java"},
         {ClientLanguage.Client_Javascript, "js"},
         {ClientLanguage.Client_Python, "py"}
     };
     return map.ContainsKey(lang) ? map[lang] : "";
 }
示例#39
0
        public FlowErrorCode GenerateServiceClient(
            ServiceSpec spec,
            string dir,
            ClientLanguage lang,
            ClientPlatform platform,
            out LinkageInfo linkInfo
            )
        {
            if (spec.IsRdsnRpc)
            {
                return GenerateRdsnClient(spec, dir, out linkInfo);
            }

            var compiler = LanguageHelper.GetCompilerPath(GetType(), platform);
            linkInfo = new LinkageInfo();
            if (compiler == "")
            {

                return FlowErrorCode.SpecCompilerNotFound;
            }

            var arguments = new List<string>();
            var languageName = GetLanguageName(lang);

            arguments.Add(" ");
            arguments.Add("--" + languageName);
            arguments.Add("-r");
            arguments.Add("-out " + dir);
            arguments.Add(Path.Combine(spec.Directory, spec.MainSpecFile));
            if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) != 0) return FlowErrorCode.ExceptionError;
            // generally, thrift.exe will generate a folder in the name of the mainspec's namespace to the output dir,e.g. gen-csharp
            // all language libraries are availabe in the source code of thrift project, placed in the thrift\\lib\\{language} dir
            // in Tron project, we place thrift compiler at "external\\thrift\\bin", and place the libraries in at"external\\thrift\\lib\\{language}"
            switch (lang)
            {
                case ClientLanguage.Client_CSharp:
                {
                    var sourceDir = Path.Combine(dir, "gen-" + languageName);
                    linkInfo.IncludeDirectories.Add(sourceDir);
                    linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\csharp"));
                    linkInfo.LibraryPaths.Add(dir);

                    linkInfo.DynamicLibraries.AddRange(new List<string>
                    {
                        "Thrift.dll"
                    });
                    var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang);
                    linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName));
                    break;
                }

                case ClientLanguage.Client_CPlusPlus:
                {
                    var sourceDir = Path.Combine(dir, "gen-" + languageName);
                    linkInfo.IncludeDirectories.Add(sourceDir);
                    linkInfo.LibraryPaths.Add(sourceDir);
                    linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\cpp"));
                    var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang);
                    linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15));
                    break;
                }
                case ClientLanguage.Client_Java:
                {
                    var sourceDir = Path.Combine(dir, "gen-" + languageName);
                    linkInfo.IncludeDirectories.Add(sourceDir);
                    linkInfo.LibraryPaths.Add(sourceDir);
                    linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\java"));
                    var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang);
                    linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15));
                    break;
                }
                default:
                    break;

            }

            return FlowErrorCode.Success;
        }