Пример #1
0
        private void ProcessOneLayoutForCountry(IntPtr configRegistry, ref XklConfigItem item,
                                                ref XklConfigItem subitem, IntPtr data)
        {
            var           subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
            XklConfigItem country       = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
            var           description   = subitemIsNull ? item.Description : subitem.Description;
            var           name          = subitemIsNull ? item.Name : subitem.Name;
            var           variant       = subitemIsNull ? String.Empty : subitem.Description;
            var           layouts       = GetLayoutList(description);

            foreach (var desc in layouts)
            {
                if (desc.LayoutId == name && desc.Description == description && desc.LayoutVariant == variant)
                {
                    return;
                }
            }
            var langCode = subitemIsNull ? item.Short_Description : subitem.Short_Description;

            if (String.IsNullOrEmpty(langCode))
            {
                langCode = subitemIsNull ? item.Name : subitem.Name;
            }
            var newLayout = new LayoutDescription {
                LayoutId      = name,
                Description   = description,
                LayoutVariant = variant,
                LanguageCode  = Get2LetterLanguageCode(langCode),
                CountryCode   = country.Name
            };

            layouts.Add(newLayout);
        }
Пример #2
0
        private void CreateLayoutFile(string layoutsDirectory, LayoutDescription layoutDescription)
        {
            LayoutTemplate layoutTemplate = new LayoutTemplate()
            {
                Session = new Dictionary <string, object> {
                    ["generator"]         = this,
                    ["layoutDescription"] = layoutDescription
                }
            };

            layoutTemplate.Initialize();

            File.WriteAllText($@"{layoutsDirectory}\{layoutDescription.Name}.cs", layoutTemplate.TransformText());
        }
Пример #3
0
        private void ProcessOneLayoutForLanguage(IntPtr configRegistry, ref XklConfigItem item,
                                                 ref XklConfigItem subitem, IntPtr data)
        {
            var           subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
            XklConfigItem language      = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
            var           description   = subitemIsNull ? item.Description : subitem.Description;
            var           layouts       = GetLayoutList(description);
            var           newLayout     = new LayoutDescription {
                LayoutId      = subitemIsNull ? item.Name : subitem.Name,
                Description   = description,
                LayoutVariant = subitemIsNull ? string.Empty : subitem.Description,
                LanguageCode  = Get2LetterLanguageCode(language.Name),
                CountryCode   = item.Name.ToUpper()
            };

            layouts.Add(newLayout);
        }
Пример #4
0
        void StoreLayoutInfo(XklConfigItem item, IntPtr data)
        {
            var description = item.Description;
            var variant     = data != IntPtr.Zero ? description : String.Empty;
            var layouts     = GetLayoutList(description);

            foreach (var desc in layouts)
            {
                if (desc.LayoutId == item.Name && desc.Description == description && desc.LayoutVariant == variant)
                {
                    return;
                }
            }
            var newLayout = new LayoutDescription {
                LayoutId      = item.Name,
                Description   = description,
                LayoutVariant = variant
            };

            if (data != IntPtr.Zero)
            {
                XklConfigItem parent   = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
                var           langCode = String.IsNullOrEmpty(item.Short_Description) ? parent.Short_Description : item.Short_Description;
                if (String.IsNullOrEmpty(langCode))
                {
                    langCode = String.IsNullOrEmpty(item.Name) ? parent.Name : item.Name;
                }
                newLayout.LanguageCode = Get2LetterLanguageCode(langCode);
                if (parent.Name.Length == 2 || item.Name != item.Short_Description)
                {
                    newLayout.CountryCode = parent.Name.ToUpper();
                }
            }
            else
            {
                newLayout.LanguageCode = Get2LetterLanguageCode(String.IsNullOrEmpty(item.Short_Description) ? item.Name : item.Short_Description);
                if (item.Name.Length == 2 || item.Name != item.Short_Description)
                {
                    newLayout.CountryCode = item.Name.ToUpper();
                }
            }
            layouts.Add(newLayout);
        }
Пример #5
0
        public override void OnApplicationStart()
        {
            Instance = this;
            CacheManager.Init();

            foreach (MethodInfo method in typeof(MenuController).GetMethods().Where(mi => mi.Name.StartsWith("Method_Public_Void_APIUser_") && !mi.Name.Contains("_PDM_")))
            {
                HarmonyInstance.Patch(method, postfix: new HarmonyMethod(typeof(UserInfoExtensionsMod).GetMethod("OnUserInfoOpen", BindingFlags.Static | BindingFlags.Public)));
            }
            HarmonyInstance.Patch(AccessTools.Method(typeof(PageUserInfo), "Back"), postfix: new HarmonyMethod(typeof(UserInfoExtensionsMod).GetMethod("OnUserInfoClose", BindingFlags.Static | BindingFlags.Public)));
            LayoutDescription popupLayout = new LayoutDescription
            {
                RowHeight  = 80,
                NumColumns = 3,
                NumRows    = 5
            };

            menu            = ExpansionKitApi.CreateCustomFullMenuPopup(popupLayout);
            userDetailsMenu = ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UserDetailsMenu);

            menu.AddLabel("General Things");
            menu.AddSpacer();
            menu.AddSimpleButton("Back", () => menu.Hide());
            userDetailsMenu.AddSimpleButton("UserInfoExtensions", () =>
            {
                HideAllPopups();
                menu.Show();
                foreach (ModuleBase module in modules)
                {
                    module.OnUIXMenuOpen();
                }
            });

            AddModule(new QuickMenuFromSocial());
            AddModule(new GetAvatarAuthor());
            AddModule(new BioButtons());
            AddModule(new UserInformation());
            AddModule(new AvatarInformation());

            VRCUtils.OnUiManagerInit += OnUiManagerInit;

            MelonLogger.Msg("Initialized!");
        }
Пример #6
0
        private void ProcessOneLayoutForLanguage(IntPtr configRegistry, ref XklConfigItem item,
                                                 ref XklConfigItem subitem, IntPtr data)
        {
            var           subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
            XklConfigItem language      = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
            var           description   = subitemIsNull ? item.Description :
                                          item.Description + " - " + subitem.Description;
            List <LayoutDescription> layouts;

            if (m_Layouts.ContainsKey(description))
            {
                layouts = m_Layouts[description];
            }
            else
            {
                layouts = new List <LayoutDescription>();
                m_Layouts[description] = layouts;
            }

            var newLayout = new LayoutDescription {
                LayoutId      = subitemIsNull ? item.Name : item.Name + "\t" + subitem.Name,
                Description   = description,
                LayoutVariant = subitemIsNull ? string.Empty : subitem.Description,
                LanguageCode  = language.Name
            };

            if (item.Short_Description.Length < 3)
            {
                // we have a two letter country code; need to find the three-letter one
                newLayout.CountryCode =
                    Icu.GetISO3Country(item.Short_Description + "_" + item.Name).ToUpper();
            }
            else
            {
                newLayout.CountryCode = item.Short_Description.ToUpper();
            }
            layouts.Add(newLayout);
        }
Пример #7
0
        private void ProcessOneLayoutForLanguage(IntPtr configRegistry, ref XklConfigItem item,
                                                 ref XklConfigItem subitem, IntPtr data)
        {
            var subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
            var language      = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
            var description   = subitemIsNull ? item.Description : subitem.Description;
            var name          = subitemIsNull ? item.Name : subitem.Name;
            var variant       = subitemIsNull ? string.Empty : subitem.Description;
            var layouts       = GetLayoutList(description);

            var newLayout = new LayoutDescription {
                LayoutId      = name,
                Description   = description,
                LayoutVariant = variant,
                LanguageCode  = Get2LetterLanguageCode(language.Name),
                CountryCode   = item.Name.ToUpper()
            };

            // don't add same layout twice (LT-20288)
            if (!layouts.Any(layout => layout.Equals(newLayout)))
            {
                layouts.Add(newLayout);
            }
        }
Пример #8
0
 private void RegisterLayout(string name, dynamic value)
 {
     _layoutsDescriptions[name] = new LayoutDescription(this, name, value);
 }
Пример #9
0
		void StoreLayoutInfo(XklConfigItem item, IntPtr data)
		{
			var description = item.Description;
			var variant = data != IntPtr.Zero ? description : String.Empty;
			var layouts = GetLayoutList(description);
			foreach (var desc in layouts)
			{
				if (desc.LayoutId == item.Name && desc.Description == description && desc.LayoutVariant == variant)
					return;
			}
			var newLayout = new LayoutDescription {
				LayoutId = item.Name,
				Description = description,
				LayoutVariant = variant
			};
			if (data != IntPtr.Zero)
			{
				XklConfigItem parent = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
				var langCode = String.IsNullOrEmpty(item.Short_Description) ? parent.Short_Description : item.Short_Description;
				if (String.IsNullOrEmpty(langCode))
					langCode = String.IsNullOrEmpty(item.Name) ? parent.Name : item.Name;
				newLayout.LanguageCode = Get2LetterLanguageCode(langCode);
				if (parent.Name.Length == 2 || item.Name != item.Short_Description)
					newLayout.CountryCode = parent.Name.ToUpper();
			}
			else
			{
				newLayout.LanguageCode = Get2LetterLanguageCode(String.IsNullOrEmpty(item.Short_Description) ? item.Name : item.Short_Description);
				if (item.Name.Length == 2 || item.Name != item.Short_Description)
					newLayout.CountryCode = item.Name.ToUpper();
			}
			layouts.Add(newLayout);
		}
Пример #10
0
		private void ProcessOneLayoutForCountry(IntPtr configRegistry, ref XklConfigItem item,
			ref XklConfigItem subitem, IntPtr data)
		{
			var subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
			XklConfigItem country = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
			var description = subitemIsNull ? item.Description : subitem.Description;
			var name = subitemIsNull ? item.Name : subitem.Name;
			var variant = subitemIsNull ? String.Empty : subitem.Description;
			var layouts = GetLayoutList(description);
			foreach (var desc in layouts)
			{
				if (desc.LayoutId == name && desc.Description == description && desc.LayoutVariant == variant)
					return;
			}
			var langCode = subitemIsNull ? item.Short_Description : subitem.Short_Description;
			if (String.IsNullOrEmpty(langCode))
				langCode = subitemIsNull ? item.Name : subitem.Name;
			var newLayout = new LayoutDescription {
				LayoutId = name,
				Description = description,
				LayoutVariant = variant,
				LanguageCode = Get2LetterLanguageCode(langCode),
				CountryCode = country.Name
			};
			layouts.Add(newLayout);
		}
Пример #11
0
		private void ProcessOneLayoutForLanguage(IntPtr configRegistry, ref XklConfigItem item,
			ref XklConfigItem subitem, IntPtr data)
		{
			var subitemIsNull = subitem.Parent.RefCount == IntPtr.Zero;
			XklConfigItem language = (XklConfigItem)Marshal.PtrToStructure(data, typeof(XklConfigItem));
			var description = subitemIsNull ? item.Description : subitem.Description;
			var layouts = GetLayoutList(description);
			var newLayout = new LayoutDescription {
				LayoutId = subitemIsNull ? item.Name : subitem.Name,
				Description = description,
				LayoutVariant = subitemIsNull ? string.Empty : subitem.Description,
				LanguageCode = Get2LetterLanguageCode(language.Name),
				CountryCode = item.Name.ToUpper()
			};
			layouts.Add(newLayout);
		}
Пример #12
0
 public bool Equals(LayoutDescription other)
 {
     return(LayoutId == other.LayoutId && Description == other.Description &&
            LayoutVariant == other.LayoutVariant &&
            LanguageCode == other.LanguageCode && CountryCode == other.CountryCode);
 }
Пример #13
0
        protected void ProcessLayouts(BoardLayoutFinder finder)
        {
            var lua = LuaMachine.Instance;
            object[] luaResult = lua.DoFile("Content/Config/layouts.lua");
            var tbl = (LuaTable) luaResult[0];

            var thumbnailsPath = (string) tbl["thumbnails"];
            var blockSizeTbl = (LuaTable) tbl["block_size"];
            var blockSize = LuaMachine.LuaTableToPoint(blockSizeTbl);

            Texture2D thumbnailSprites = null;
            if (thumbnailsPath != null)
                thumbnailSprites = _content.Load<Texture2D>(thumbnailsPath);

            foreach (var key in tbl.Keys)
            {
                if (!(key is double))
                {
                    continue;
                }
                var layoutTbl = (LuaTable) tbl[key];
                var top = (string) layoutTbl["top"];
                var bottom = (string) layoutTbl["bottom"];
                var unit = (string) layoutTbl["unit"];
                var coords = (LuaTable) layoutTbl["thumbnails"];

                var layout = new LayoutDescription(unit, top, bottom);

                if (coords != null && thumbnailSprites != null)
                {
                    // process thumbnails coordinates
                    layout.Thumbnails = thumbnailSprites;
                    layout.ThumbnailBlocks =
                        coords.Values.Cast<LuaTable>().Select(LuaMachine.LuaTableToPoint).ToArray();
                    layout.BlockSize = blockSize;
                }

                finder.AddLayout(layout);
            }
        }