Example #1
0
        public static void Main()
        {
            Marshal.PrelinkAll(typeof(Program));
            try
            {
                CommonStrings.InitStrings();
                MBGE_LogInit();
                Trace.WriteLine("[" + DateTime.UtcNow.ToString() + "] " + "[Kernel/" + LogStatus.Info + "]: " + "Kernel loading complete!");

                if (debugThrow == true)
                {
                    throw new Exception();
                }

                MBGE_PressEnter();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("[" + DateTime.UtcNow.ToString() + "] " + "[Kernel/" + LogStatus.Fatal + "]: " + $"{ex.Message}");
                Process.Start(new ProcessStartInfo("https://stackoverflow.com/search?q=" + $"{ex.Message}")
                {
                    UseShellExecute = true
                });
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Get the string for a given key in a given culture.
        /// </summary>
        /// <param name="culture"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        /// <remarks>
        /// If string for culture found return.
        /// If not found seach English
        /// If not found return key
        /// </remarks>
        public string GetString(string culture, string key)
        {
            // Do some checks before we go to cache.
            // No need to touch cache if blanks.
            if (string.IsNullOrEmpty(culture) || string.IsNullOrWhiteSpace(culture))
            {
                return(key);
            }
            if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
            {
                return(key);
            }
            // Ok get cached strings
            var resourceStrings = GetCachedData();

            // Setup common strings so that we do not have to touch cache with no need.
            if (_commonStrings == null)
            {
                _commonStrings = LoadCommonStrings(culture, resourceStrings);
            }
            // Get the string for this culture
            string result = FindOneString(culture, key, resourceStrings);

            result = ReplacePatterns(result, _commonStrings.Translations);
            return(result);
        }
Example #3
0
 private void ValidateReportSecurity(PreviewItemContext itemContext, PublishingResult publishingResult)
 {
     if (publishingResult.HasExternalImages && !EnableExternalImages)
     {
         throw new ReportSecurityException(CommonStrings.ExternalImagesError(itemContext.ItemName));
     }
     if (publishingResult.HasHyperlinks && !EnableHyperlinks)
     {
         throw new ReportSecurityException(CommonStrings.HyperlinkSecurityError(itemContext.ItemName));
     }
 }
Example #4
0
        /// <summary>
        /// Return common strings for a given culture.
        /// </summary>
        /// <param name="culture"></param>
        /// <returns></returns>
        /// <remarks>Has to be a function. I'd rather not set the culture per instance.</remarks>
        public CommonStringsDto GetCommonStrings(string culture)
        {
            // See if we got the strings already
            if (_commonStrings != null)
            {
                return(_commonStrings.Strings);
            }
            // Well ... nothing we can do ... load from cache.
            var resourceStrings = GetCachedData();

            // Setup common strings so that we do not have to touch cache with no need.
            _commonStrings = LoadCommonStrings(culture, resourceStrings);
            return(_commonStrings.Strings);
        }
Example #5
0
        private int GetIndexForParameter(string parameterName)
        {
            int num = -1;

            for (int i = 0; i < m_executionInfo.Parameters.Count; i++)
            {
                if (string.Compare(m_executionInfo.Parameters[i].Name, parameterName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    num = i;
                    break;
                }
            }
            if (num == -1 && string.Compare(parameterName, "rs:StoredParametersID", StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new ArgumentException(CommonStrings.ParameterNotFound(parameterName));
            }
            return(num);
        }
Example #6
0
 public override void SetParameters(IEnumerable <ReportParameter> parameters)
 {
     lock (m_syncObject)
     {
         if (parameters == null)
         {
             throw new ArgumentNullException("parameters");
         }
         EnsureExecutionSession();
         Dictionary <int, bool> dictionary = new Dictionary <int, bool>();
         foreach (ReportParameter parameter in parameters)
         {
             if (parameter == null || parameter.Name == null)
             {
                 throw new ArgumentNullException("parameters");
             }
             int indexForParameter = GetIndexForParameter(parameter.Name);
             if (dictionary.ContainsKey(indexForParameter))
             {
                 throw new ArgumentException(CommonStrings.ParameterSpecifiedMultipleTimes(parameter.Name));
             }
             dictionary.Add(indexForParameter, parameter.Visible);
         }
         m_executionInfo = Service.SetExecutionParameters(parameters, Thread.CurrentThread.CurrentCulture.Name);
         foreach (int key in dictionary.Keys)
         {
             if (dictionary[key])
             {
                 m_hiddenParameters.Remove(key);
             }
             else if (!m_hiddenParameters.Contains(key))
             {
                 m_hiddenParameters.Add(key);
             }
         }
         OnChange(isRefreshOnly: false);
     }
 }
Example #7
0
        static void Main(string[] args)
        {
            //ChangeStarters();
            //return;

            var basePath        = @"D:\01003D200BAA2000";
            var natureDiagnosis = JsonConvert.DeserializeObject <NDConverterSharedData.DataStore>(File.ReadAllText(basePath + @"\romfs\Data\StreamingAssets\data\nature_diagnosis\diagnosis.json"));
            //var actorDataInfoPath = basePath + @"\romfs\Data\StreamingAssets\native_data\pokemon\pokemon_actor_data_info.bin";
            //var actorDataInfo = new PokemonActorDataInfo(File.ReadAllBytes(actorDataInfoPath));

            var graphicsDatabasePath = basePath + @"\romfs\Data\StreamingAssets\native_data\pokemon_graphics_database.bin";
            var graphicsDatabase     = new PokemonGraphicsDatabase(File.ReadAllBytes(graphicsDatabasePath));

            var             nsoPath = basePath + @"\exefs\main";
            IMainExecutable nso     = MainExecutable.LoadFromNso(File.ReadAllBytes(nsoPath));

            var           fixedPokemonPath = basePath + @"\romfs\Data\StreamingAssets\native_data\dungeon\fixed_pokemon.bin";
            IFixedPokemon fixedPokemon     = new FixedPokemon(File.ReadAllBytes(fixedPokemonPath));

            var messageBinPath = basePath + @"\romfs\Data\StreamingAssets\native_data\message_us.bin";
            var messageBin     = new Farc(File.ReadAllBytes(messageBinPath));
            var common         = new MessageBinEntry(messageBin.GetFile("common.bin"));

            ICommonStrings  commonStrings  = new CommonStrings(common);
            IStarterQueries starterQueries = new StarterQueries(commonStrings, nso, natureDiagnosis, fixedPokemon);

            Console.WriteLine("Starters:");
            var starters = starterQueries.GetStarters();

            foreach (var starter in starters)
            {
                Console.WriteLine(starter.PokemonName);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
Example #8
0
        /// <summary>
        /// Load common strings for the current culture.
        /// </summary>
        /// <param name="culture"></param>
        /// <param name="resourceStrings"></param>
        /// <returns></returns>
        private CommonStrings LoadCommonStrings(string culture, List <ResourceString> resourceStrings)
        {
            var result = new CommonStrings();

            //TODO
            result.Strings = new CommonStringsDto();
            //TODO
            result.Translations = new Dictionary <string, string>();

            result.Strings.Best          = LoadOneCommonString(culture, "best_start_capital", resourceStrings, result.Translations);
            result.Strings.For           = LoadOneCommonString(culture, "for_lower", resourceStrings, result.Translations);
            result.Strings.Is            = LoadOneCommonString(culture, "is_lower", resourceStrings, result.Translations);
            result.Strings.FlagLower     = LoadOneCommonString(culture, "flag_lower", resourceStrings, result.Translations);
            result.Strings.FlagUpper     = LoadOneCommonString(culture, "flag_upper", resourceStrings, result.Translations);
            result.Strings.VoteLower     = LoadOneCommonString(culture, "vote_lower", resourceStrings, result.Translations);
            result.Strings.VoteUpper     = LoadOneCommonString(culture, "vote_upper", resourceStrings, result.Translations);
            result.Strings.DescribeLower = LoadOneCommonString(culture, "describe_lower", resourceStrings, result.Translations);
            result.Strings.DescribeUpper = LoadOneCommonString(culture, "describe_upper", resourceStrings, result.Translations);
            result.Strings.MoreLower     = LoadOneCommonString(culture, "more_lower", resourceStrings, result.Translations);
            result.Strings.MoreUpper     = LoadOneCommonString(culture, "more_upper", resourceStrings, result.Translations);
            result.Strings.PostersUpper  = LoadOneCommonString(culture, "posters_capital", resourceStrings, result.Translations);
            result.Strings.GuestUpper    = LoadOneCommonString(culture, "guest_capital", resourceStrings, result.Translations);
            return(result);
        }
Example #9
0
        /// <summary>
        /// Find a set of strings for set of keys
        /// </summary>
        /// <param name="culture"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public string[] GetStrings(string culture, string[] keys)
        {
            // Do some checks before we go to cache.
            // No need to touch cache if blanks.
            if (string.IsNullOrEmpty(culture) || string.IsNullOrWhiteSpace(culture))
            {
                return(keys);
            }
            if (keys == null)
            {
                return(keys);
            }
            var result = new string[keys.Length];
            // Ok get cached strings
            var resourceStrings = GetCachedData();

            // Setup common strings so that we do not have to touch cache with no need.
            if (_commonStrings == null)
            {
                _commonStrings = LoadCommonStrings(culture, resourceStrings);
            }
            // Loop through the resources
            for (var i = 0; i < keys.Length; i++)
            {
                if (string.IsNullOrEmpty(keys[i]) || string.IsNullOrWhiteSpace(keys[i]))
                {
                    result[i] = keys[i];
                }
                else
                {
                    result[i] = FindOneString(culture, keys[i], resourceStrings);
                }
                result[i] = ReplacePatterns(result[i], _commonStrings.Translations);
            }
            return(result);
        }
Example #10
0
        private void ReadClassMember5(EndianBinaryReader reader, int fileFormatVersion, bool baseDefinitions)
        {
            var classID = reader.ReadInt32();

            if (fileFormatVersion > 15)
            {
                reader.ReadByte();
                var type1 = (int)reader.ReadInt16();
                if (type1 >= 0)
                {
                    type1 = -(1 + type1);
                }
                else
                {
                    type1 = classID;
                }

                var classIDs = _classIDs ?? (_classIDs = new List <(int Type1, int Type2)>());
                classIDs.Add((type1, classID));

                if (classID == 114)
                {
                    reader.Position += 16;
                }

                classID = type1;
            }
            else if (classID < 0)
            {
                reader.Position += 16;
            }
            reader.Position += 16;

            if (baseDefinitions)
            {
                var varCount   = reader.ReadInt32();
                var stringSize = reader.ReadInt32();

                reader.Position += varCount * 24;

                var stringBlockData = reader.ReadBytes(stringSize);

                var classVars = new List <ClassMember>();
                reader.Position -= varCount * 24 + stringSize;

                string baseName = null, baseType = null;
                int    baseSize = 0, baseIndex = 0, baseFlags = 0;

                using (var stringBlockMemory = new MemoryStream(stringBlockData, false)) {
                    using (var stringReader = new EndianBinaryReader(stringBlockMemory, Endian.BigEndian)) {
                        for (var i = 0; i < varCount; ++i)
                        {
                            var dummy   = reader.ReadInt16();
                            var level   = reader.ReadByte();
                            var isArray = reader.ReadBoolean();

                            var    varTypeIndex      = reader.ReadUInt16();
                            var    isUserDefinedName = reader.ReadUInt16();
                            string varTypeStr;

                            if (isUserDefinedName == 0)
                            {
                                stringReader.Position = varTypeIndex;
                                varTypeStr            = stringReader.ReadStringToNull();
                            }
                            else
                            {
                                varTypeStr = CommonStrings.ContainsKey(varTypeIndex) ? CommonStrings[varTypeIndex] : varTypeIndex.ToString();
                            }

                            var varNameIndex = reader.ReadUInt16();
                            isUserDefinedName = reader.ReadUInt16();
                            string varNameStr;

                            if (isUserDefinedName == 0)
                            {
                                stringReader.Position = varNameIndex;
                                varNameStr            = stringReader.ReadStringToNull();
                            }
                            else
                            {
                                varNameStr = CommonStrings.ContainsKey(varNameIndex) ? CommonStrings[varNameIndex] : varNameIndex.ToString();
                            }

                            var size  = reader.ReadInt32();
                            var index = reader.ReadInt32();
                            var flags = reader.ReadInt32();

                            if (index == 0)
                            {
                                baseName  = varNameStr;
                                baseType  = varTypeStr;
                                baseSize  = size;
                                baseIndex = index;
                                baseFlags = flags;
                            }
                            else
                            {
                                var member = new ClassMember(level - 1, baseType, baseName, varTypeStr, varNameStr, size, flags, null);
                                classVars.Add(member);
                            }
                        }
                    }
                }

                var baseMember = new ClassMember(0, string.Empty, string.Empty, baseType, baseName, baseSize, baseFlags, classVars);
                _objects[classID] = baseMember;

                reader.Position += stringSize;
            }
        }
Example #11
0
 internal MissingParameterException(string parameterName)
     : base(CommonStrings.MissingParameter(parameterName))
 {
 }
        string IReportViewerMessages3.TotalPages(int pageCount, PageCountMode pageCountMode)
        {
            string builtinString = (pageCountMode != 0 && pageCount > 0) ? CommonStrings.EstimateTotalPages(pageCount) : pageCount.ToString(CultureInfo.CurrentCulture);

            return(GetLocalizedString(builtinString, (ReportViewerMessages3 != null) ? ReportViewerMessages3.TotalPages(pageCount, pageCountMode) : null));
        }
Example #13
0
 internal MissingDataSourceException(string dataSourceName)
     : base(CommonStrings.MissingDataSource(dataSourceName))
 {
 }