public Spritesheet(int id, string name, Texture2D texture, SpriteCategory category) { Id = id; Name = name; Texture = texture; Category = category; }
private void enableFont() { SpriteCategory category = new SpriteCategory("customfonts", UIResourceManager.SpriteData, 1); category.SheetSizes = new Vec2i[1] { new Vec2i(8192, 8192) }; category.Load(UIResourceManager.ResourceContext, UIResourceManager.UIResourceDepot); SpritePart spritePart = new SpritePart("sim1", category, 8192, 8192) { SheetID = 1 }; string currentModulePath = ModuleInfo.GetPath("SettlementExtend"); string currentModuleDirPath = currentModulePath.Substring(0, currentModulePath.LastIndexOf("/")); string fontPath = currentModuleDirPath + "/GUI/GauntletUI/Fonts"; string fontFilePath = fontPath + "/simkai/"; UIResourceManager.FontFactory.AddFontDefinition(fontFilePath, "simkai2", UIResourceManager.SpriteData); Font font = UIResourceManager.FontFactory.GetFont("simkai2"); font.GetType().GetProperty("FontSprite").SetValue((object)font, (object)spritePart); TaleWorlds.Engine.Texture engineTexture = TaleWorlds.Engine.Texture.LoadTextureFromPath("Galahad.png", fontPath); font.FontSprite.Category.SpriteSheets[font.FontSprite.SheetID - 1] = new Texture(new EngineTexture(engineTexture)); UIResourceManager.FontFactory.DefaultFont = font; }
public void CreateLayout() { SpriteData spriteData = UIResourceManager.SpriteData; TwoDimensionEngineResourceContext resourceContext = UIResourceManager.ResourceContext; ResourceDepot uiResourceDepot = UIResourceManager.UIResourceDepot; this._spriteCategory = spriteData.SpriteCategories["ui_crafting"]; this._spriteCategory.Load((ITwoDimensionResourceContext)resourceContext, uiResourceDepot); this._gauntletLayer = new GauntletLayer(1, "GauntletLayer"); this._gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.All); this._gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericCampaignPanelsGameKeyCategory")); this._gauntletLayer.IsFocusLayer = true; //ScreenManager.TrySetFocus((ScreenLayer) this._gauntletLayer); MissionScreen.AddLayer((ScreenLayer)this._gauntletLayer); this._gauntletLayer.LoadMovie("ScrollGrid", new GameEntityVM()); //this._testGlobalLayer = new testGlobalLayer(); //this._testGlobalLayer.Initialize(); // screen where //MissionScreen.AddLayer(this._testGlobalLayer.Layer); //MissionScreen // ScreenManager.AddGlobalLayer(this._testGlobalLayer, true); //ScreenManager.TrySetFocus(this._testGlobalLayer.Layer); }
protected override void OnActivate() { base.OnActivate(); SpriteData spriteData = UIResourceManager.SpriteData; TwoDimensionEngineResourceContext resourceContext = UIResourceManager.ResourceContext; ResourceDepot uIResourceDepot = UIResourceManager.UIResourceDepot; this._characterdeveloper = spriteData.SpriteCategories["ui_characterdeveloper"]; this._characterdeveloper.Load(resourceContext, uIResourceDepot); //this._clanCategory = spriteData.SpriteCategories["ui_encyclopedia"]; //this._clanCategory.Load(resourceContext, uIResourceDepot); this._clanCategory = spriteData.SpriteCategories["ui_clan"]; this._clanCategory.Load(resourceContext, uIResourceDepot); this._gauntletLayer = new GauntletLayer(1, "GauntletLayer"); this._gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.All); this._gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericCampaignPanelsGameKeyCategory")); this._gauntletLayer.IsFocusLayer = true; ScreenManager.TrySetFocus(this._gauntletLayer); base.AddLayer(this._gauntletLayer); this._dataSource = new HereAdminDashBoardVM(this._heroAdminState.EditHero, OnCloseHereAdminDashBoard); this._gauntletLayer.LoadMovie("HeroAdminDashBoard", this._dataSource); }
/// <summary> /// Creates a new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>. This method should /// always return a new <see cref="ControlBorder"/> and not use any sort of caching. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The optional sub-category. Can be null.</param> /// <returns>A new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>.</returns> protected virtual ControlBorder CreateBorder(string controlName, SpriteCategory subCategory) { // Get the full sub-category var fullSubCategory = GetControlSpriteSubCategory(controlName); if (subCategory != null && subCategory.ToString().Length > 0) { fullSubCategory += SpriteCategorization.Delimiter + subCategory; } // Load all the sides var bg = GetSprite(fullSubCategory, "Background"); var l = GetSprite(fullSubCategory, "Left"); var r = GetSprite(fullSubCategory, "Right"); var b = GetSprite(fullSubCategory, "Bottom"); var bl = GetSprite(fullSubCategory, "BottomLeft"); var br = GetSprite(fullSubCategory, "BottomRight"); var tl = GetSprite(fullSubCategory, "TopLeft"); var t = GetSprite(fullSubCategory, "Top"); var tr = GetSprite(fullSubCategory, "TopRight"); // Create the control var ret = new ControlBorder(tl, t, tr, r, br, b, bl, l, bg); // Try to load the user-defined border drawing styles var borderDrawStylesFile = GetBorderDrawStylesFilePath(fullSubCategory); if (!string.IsNullOrEmpty(borderDrawStylesFile)) { ret.TrySetDrawStyles(borderDrawStylesFile); } return(ret); }
/// <summary> /// Gets the <see cref="ControlBorder"/> for the <see cref="Control"/> with the given name. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The sprite sub-category under the <paramref name="controlName"/>.</param> /// <returns>The <see cref="ControlBorder"/> for the <see cref="Control"/> with the given name.</returns> public ControlBorder GetBorder(string controlName, SpriteCategory subCategory) { var key = controlName; if (subCategory != null && subCategory.ToString().Length > 0) { key += subCategory; } // First, try to get the border from the cache ControlBorder ret; if (_borderCache.TryGetValue(key, out ret)) { return(ret); } // Didn't exist in the cache, so create the new border and add it to the cache ret = CreateBorder(controlName, subCategory); try { _borderCache.Add(key, ret); } catch (ArgumentException ex) { Debug.Fail( "Key already exists. Multi-threading conflict? This should never happen, but its likely not critical." + ex); } // Return the border return(ret); }
protected override void OnInitialize() { base.OnInitialize(); SpriteData spriteData = UIResourceManager.SpriteData; TwoDimensionEngineResourceContext resourceContext = UIResourceManager.ResourceContext; ResourceDepot uIResourceDepot = UIResourceManager.UIResourceDepot; _clanCategory = spriteData.SpriteCategories["ui_clan"]; _clanCategory.Load(resourceContext, uIResourceDepot); this._kingdomCategory = spriteData.SpriteCategories["ui_kingdom"]; this._kingdomCategory.Load(resourceContext, uIResourceDepot); this._spriteCategory = spriteData.SpriteCategories["ui_options"]; this._spriteCategory.Load(resourceContext, uIResourceDepot); _gauntletLayer = new GauntletLayer(1); _gauntletLayer.InputRestrictions.SetInputRestrictions(); _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericCampaignPanelsGameKeyCategory")); _gauntletLayer.IsFocusLayer = true; ScreenManager.TrySetFocus(_gauntletLayer); AddLayer(_gauntletLayer); _dataSource = new WangVM(CloseWangScreen, OpenPartyAsManage, OpenBannerEditorWithPlayerClan); _gauntletLayer.LoadMovie("WangScreen", _dataSource); // Game.Current.EventManager.TriggerEvent(new TutorialContextChangedEvent(TutorialContexts.ClanScreen)); }
/// <summary> /// Creates a new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>. This method should /// always return a new <see cref="ControlBorder"/> and not use any sort of caching. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The optional sub-category. Can be null.</param> /// <returns>A new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>.</returns> protected virtual ControlBorder CreateBorder(string controlName, SpriteCategory subCategory) { // Get the full sub-category var fullSubCategory = GetControlSpriteSubCategory(controlName); if (subCategory != null && subCategory.ToString().Length > 0) fullSubCategory += SpriteCategorization.Delimiter + subCategory; // Load all the sides var bg = GetSprite(fullSubCategory, "Background"); var l = GetSprite(fullSubCategory, "Left"); var r = GetSprite(fullSubCategory, "Right"); var b = GetSprite(fullSubCategory, "Bottom"); var bl = GetSprite(fullSubCategory, "BottomLeft"); var br = GetSprite(fullSubCategory, "BottomRight"); var tl = GetSprite(fullSubCategory, "TopLeft"); var t = GetSprite(fullSubCategory, "Top"); var tr = GetSprite(fullSubCategory, "TopRight"); // Create the control var ret = new ControlBorder(tl, t, tr, r, br, b, bl, l, bg); // Try to load the user-defined border drawing styles var borderDrawStylesFile = GetBorderDrawStylesFilePath(fullSubCategory); if (!string.IsNullOrEmpty(borderDrawStylesFile)) ret.TrySetDrawStyles(borderDrawStylesFile); return ret; }
/// <summary> /// Gets a unique title for a <see cref="GrhData"/> in the given category. /// </summary> /// <param name="category">The category.</param> /// <param name="title">The string to base the new title off of.</param> /// <returns>A unique title for the given <paramref name="category"/>.</returns> public static SpriteTitle GetUniqueTitle(SpriteCategory category, string title) { if (!string.IsNullOrEmpty(title)) { title = SpriteTitle.Sanitize(title); } if (!SpriteTitle.IsValid(title)) { title = "tmp"; } // Check if the given title is already free var sTitle = new SpriteTitle(title); if (GetData(category, sTitle) == null) { return(sTitle); } // Find next free number for the title suffix var copyNum = 1; SpriteTitle sNewTitle; do { copyNum++; sNewTitle = new SpriteTitle(title + " (" + copyNum + ")"); }while (GetData(category, sNewTitle) != null); return(sNewTitle); }
public SelectedObject(SpriteCategory type, Tile selectedTile = null, Creature selectedCreature = null, Item selectedItem = null) { SelectedType = type; SelectedTile = selectedTile; SelectedCreature = selectedCreature; SelectedItem = selectedItem; IsSet = true; }
public SpriteCollection(int id, string name, int columns, int rows, SpriteCategory category) { Id = id; Name = name; Columns = columns; Rows = rows; Sprite = new SpriteObject[rows, columns]; Category = category; }
public static void LoadFontFromModule() { var licence = true; if (licence) { //load texture GameTex texture = new GameTex((ITexture) new EngineTexture(EngineTex.CreateTextureFromPath($"../../Modules/{ModuleName}/Font", $"{FontName}.png"))); //set temporary sprite data SpriteData spriteData = new SpriteData("Font Atlas"); SpriteCategory category = new SpriteCategory($"{FontName}", spriteData, 1); SpritePart spritePart = new SpritePart($"{FontName}", category, texture.Width, texture.Height); SpriteGeneric spriteGeneric = new SpriteGeneric($"{FontName}", spritePart); // set sprite part data. (sheetid = 1 is chinise font.) category.Load((IResourceContext) new TextureLoader(texture), (ResourceDepot)null); spritePart.SheetID = 1; spritePart.SheetX = 0; spritePart.SheetY = 0; spriteData.SpriteNames.Add($"{FontName}", (Sprite)spriteGeneric); Font font = new Font($"{FontName}", $"../../Modules/{ModuleName}/Font/{FontName}.fnt", spriteData); /* reflection font factory */ Dictionary <string, Font> _bitmapFont = typeof(FontFactory).GetField("_bitmapFonts", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue((object)UIResourceManager.FontFactory) as Dictionary <string, Font>; Dictionary <string, Dictionary <string, Font> > _localizationMap = typeof(FontFactory).GetField("_fontLocalizationMap", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue((object)UIResourceManager.FontFactory) as Dictionary <string, Dictionary <string, Font> >; _bitmapFont[CoverFontName] = font; Dictionary <string, Font> _defaultFontMap = typeof(FontFactory).GetField("_fontLocalizationMap", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue((object)UIResourceManager.FontFactory) as Dictionary <string, Font>; LocalizationMap = _localizationMap; /* cover font data. */ foreach (string index in new List <string>((IEnumerable <string>)_localizationMap[XMLKey].Keys)) { _localizationMap[XMLKey][index] = font; } /* apply */ UIResourceManager.FontFactory.DefaultFont = font; FontLoaded = true; } else { InformationManager.ShowInquiry(new InquiryData("Module Load Faile!", "failed load module.", true, false, ":(", null, null, null)); } }
internal Spritesheet GetSpritesheetById(int id, SpriteCategory category) { for (int i = 0; i < Spritesheets.Count; i++) { if (Spritesheets[i].Id == id && Spritesheets[i].Category == category) { return(Spritesheets[i]); } } return(new Spritesheet()); }
internal Spritesheet GetSpritesheetByName(string name, SpriteCategory category) { for (int i = 0; i < Spritesheets.Count; i++) { if (Spritesheets[i].Name.ToLower() == name.ToLower() && Spritesheets[i].Category == category) { return(Spritesheets[i]); } } return(new Spritesheet()); }
/// <summary> /// Gets the <see cref="ISprite"/> for the <see cref="Control"/> with the given <paramref name="spriteTitle"/>. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The sprite sub-category under the <paramref name="controlName"/>.</param> /// <param name="spriteTitle">The <see cref="SpriteTitle"/> of the <see cref="ISprite"/> to load.</param> /// <returns>The <see cref="ISprite"/> for the <see cref="Control"/> with the given /// <paramref name="spriteTitle"/>.</returns> public ISprite GetControlSprite(string controlName, SpriteCategory subCategory, SpriteTitle spriteTitle) { var completeSubCategory = GetControlSpriteSubCategory(controlName); if (subCategory != null && subCategory.ToString().Length > 0) { completeSubCategory += SpriteCategorization.Delimiter + subCategory; } return(GetSprite(completeSubCategory, spriteTitle)); }
public ChangeAction(Coordinates pos, int zorder, MapAction mapAction, SpriteObject sprite, Size tileAmount, SpriteCategory category, List <Tile> tilesChanged = null, List <Creature> creaturesChanged = null, List <Item> itemsChanged = null) { Category = category; Pos = pos; MapAction = mapAction; Sprite = sprite; TileAmount = tileAmount; Zorder = zorder; TilesChanged = tilesChanged; CreaturesChanged = creaturesChanged; ItemsChanged = itemsChanged; }
public MissionGauntletOptionsWithModOptionsUIHandler() { var spriteData = UIResourceManager.SpriteData; var resourceContext = UIResourceManager.ResourceContext; var uiresourceDepot = UIResourceManager.UIResourceDepot; _spriteCategoryOptions = spriteData.SpriteCategories["ui_options"]; _spriteCategoryOptions.Load(resourceContext, uiresourceDepot); _spriteCategoryEncyclopedia = spriteData.SpriteCategories["ui_encyclopedia"]; _spriteCategoryEncyclopedia.Load(resourceContext, uiresourceDepot); ViewOrderPriorty = 49; }
public void AddSprites(string spriteSheet, int sheetId = 1) { SpriteCategory spriteCategory = UIResourceManager.SpriteData.SpriteCategories[spriteSheet]; spriteCategory.Load(UIResourceManager.ResourceContext, resourceDepot); var texture = TaleWorlds.Engine.Texture.LoadTextureFromPath($"{spriteSheet}_{sheetId}.png", BasePath.Name + "Modules/BattleStamina/Sprites/SpriteSheets/" + spriteSheet); texture.PreloadTexture(); var texture2D = new TaleWorlds.TwoDimension.Texture(new EngineTexture(texture)); UIResourceManager.SpriteData.SpriteCategories[spriteSheet].SpriteSheets[sheetId - 1] = texture2D; }
public SpriteObject(Texture2D sprite, int id, SpriteCategory category, string spriteName, bool walkthrough, string randomizeCategory = null, string spriteCollection = null, bool show = true, string tileCategory = null) { Sprite = sprite; Id = id; Category = category; SpriteName = spriteName; Walkthrough = walkthrough; LoadFromSpritesheet = false; SpritesheetId = -1; SpriteCollection = spriteCollection; Show = show; ListCategory = tileCategory; }
public static void Postfix(ref BodyGeneratorView __instance) { SpriteData spriteData = UIResourceManager.SpriteData; TwoDimensionEngineResourceContext resourceContext = UIResourceManager.ResourceContext; ResourceDepot uIResourceDepot = UIResourceManager.UIResourceDepot; clanCategory = spriteData.SpriteCategories["ui_clan"]; clanCategory.Load(resourceContext, uIResourceDepot); FacGenRecordVM facGenRecord = new FacGenRecordVM(__instance, GlobalDataProvider.Instance.FacGenRecordData()); GauntletMovie movie = __instance.GauntletLayer.LoadMovie("FacGenRecord", facGenRecord); //movie.BrushFactory.LoadBrushFile("FacGenRecord"); }
/// <summary> /// Gets the <see cref="GrhData"/>s by the given information. /// </summary> /// <param name="category">Category of the <see cref="GrhData"/>s.</param> /// <returns>All <see cref="GrhData"/>s from the given category with their Title as the key, or /// null if the <paramref name="category"/> was invalid.</returns> public static IDictionary <SpriteTitle, GrhData> GetDatas(SpriteCategory category) { Dictionary <SpriteTitle, GrhData> titleDic; // Return the whole dictionary for the given catgory, or null if it does not exist if (_catDic.TryGetValue(category, out titleDic)) { return(titleDic); } else { return(null); } }
public SpriteObject(int id, SpriteCategory category, string spriteName, bool walkthrough, Rectangle spritesheetPosition, int spritesheetId, string randomizeCategory = null, string spriteCollection = null, bool show = true, string tileCategory = null) { Id = id; Category = category; SpriteName = spriteName; Walkthrough = walkthrough; SpritesheetPosition = spritesheetPosition; SpritesheetId = spritesheetId; LoadFromSpritesheet = true; RandomizeCategory = randomizeCategory; SpriteCollection = spriteCollection; Show = show; ListCategory = tileCategory; }
/// <summary> /// Gets a unique category based off of an existing category. /// </summary> /// <param name="category">The category to base the new category name off of.</param> /// <returns>A unique, unused category.</returns> public static SpriteCategory GetUniqueCategory(string category) { var copyNum = 1; SpriteCategory newCategory; IDictionary <SpriteTitle, GrhData> coll; do { newCategory = new SpriteCategory(category + " (" + ++copyNum + ")"); }while ((coll = GetDatas(newCategory)) != null && !coll.IsEmpty()); return(newCategory); }
/// <summary> /// Gets the file path to the file containing the <see cref="ControlBorderDrawStyle"/>s for a <see cref="ControlBorder"/>. /// </summary> /// <param name="fullSubCategory">The full sub-category of the border.</param> /// <returns>The path to the border draw styles file.</returns> string GetBorderDrawStylesFilePath(SpriteCategory fullSubCategory) { // Get the sprite category for the current skin var spriteCat = GetSpriteCategory(CurrentSkin, fullSubCategory); // Replace the sprite categorization delimiters with path separators var spritePath = spriteCat.ToString().Replace(SpriteCategorization.Delimiter, Path.DirectorySeparatorChar.ToString()); // Take the sprite category, now formatted as a path, and prefix the full qualified path to the Grhs var borderStylesFile = ContentPaths.Build.Grhs.Join(spritePath); // Append the name of the file borderStylesFile = borderStylesFile.Join(_borderStylesFileName); return(borderStylesFile); }
/// <summary> /// Gets the absolute <see cref="SpriteCategory"/> path for the given skin and skin sub-category. /// </summary> /// <param name="skinName">The name of the skin.</param> /// <param name="subCategory">The sub-category under the skin directory. Can be null or empty.</param> /// <returns>The absolute <see cref="SpriteCategory"/> path for the given skin and skin sub-category.</returns> protected virtual SpriteCategory GetSpriteCategory(string skinName, SpriteCategory subCategory) { const string del = SpriteCategorization.Delimiter; var sb = new StringBuilder(64); sb.Append("GUI"); sb.Append(del); sb.Append(skinName); if (subCategory != null && subCategory.ToString().Length > 0) { sb.Append(del); sb.Append(subCategory); } return(new SpriteCategory(sb.ToString())); }
protected override void OnInitialize() { base.OnInitialize(); var spriteData = UIResourceManager.SpriteData; var resourceContext = UIResourceManager.ResourceContext; var uiresourceDepot = UIResourceManager.UIResourceDepot; _spriteCategoryEncyclopedia = spriteData.SpriteCategories["ui_encyclopedia"]; _spriteCategoryEncyclopedia.Load(resourceContext, uiresourceDepot); _dataSource = new ModOptionsVM(); _gauntletLayer = new GauntletLayer(4000, "GauntletLayer"); _gauntletMovie = _gauntletLayer.LoadMovie("ModOptionsView", _dataSource); _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericPanelGameKeyCategory")); _gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.All); _gauntletLayer.IsFocusLayer = true; AddLayer(_gauntletLayer); ScreenManager.TrySetFocus(_gauntletLayer); }
public void AddSprite(Sprite sprite) { if (sprite == null) { return; } string tname = sprite.texture.name; for (int i = 0; i < lsc.Count; i++) { if (tname == lsc[i].txtName) { lsc[i].sprites.Add(sprite); return; } } SpriteCategory category = new SpriteCategory(); category.txtName = tname; category.sprites.Add(sprite); lsc.Add(category); }
protected override void OnInitialize() { base.OnInitialize(); var spriteData = UIResourceManager.SpriteData; var resourceContext = UIResourceManager.ResourceContext; var uiresourceDepot = UIResourceManager.UIResourceDepot; _spriteCategoryOptions = spriteData.SpriteCategories["ui_options"]; _spriteCategoryOptions.Load(resourceContext, uiresourceDepot); _spriteCategoryEncyclopedia = spriteData.SpriteCategories["ui_encyclopedia"]; _spriteCategoryEncyclopedia.Load(resourceContext, uiresourceDepot); _dataSource = new OptionsModOptionsViewModel(new OptionsVM(true, false, OnKeybindRequest), new ModOptionsVM()); _gauntletLayer = new GauntletLayer(4000, "GauntletLayer"); _gauntletMovie = _gauntletLayer.LoadMovie("OptionsWithModOptionsView_v3", _dataSource); _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericPanelGameKeyCategory")); _gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.All); _gauntletLayer.IsFocusLayer = true; _keybindingPopup = new KeybindingPopup(SetHotKey, this); AddLayer(_gauntletLayer); ScreenManager.TrySetFocus(_gauntletLayer); Utilities.SetForceVsync(true); }
protected override void OnInitialize() { base.OnInitialize(); _spriteCategory = UIResourceManager.SpriteData.SpriteCategories["ui_options"]; _spriteCategory.Load(UIResourceManager.ResourceContext, UIResourceManager.UIResourceDepot); _optionsVm = new OptionsVM(true, false, OnKeyBindRequest); _dataSource = new CustomOptionsViewModel(_optionsVm) { ModOptions = new CustomOptionCategoryViewModel(_optionsVm, "ModOptions".Localized(), OptionsStore.GetRegisteredForGui() .SelectMany(store => GenerateOptionDataViewModels(store.GetKnownOptions()))) }; _gauntletLayer = new GauntletLayer(4000); _gauntletMovie = _gauntletLayer.LoadMovie("CustomOptions", _dataSource); _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericPanelGameKeyCategory")); _gauntletLayer.InputRestrictions.SetInputRestrictions(); _gauntletLayer.IsFocusLayer = true; _keyBindingPopup = new KeybindingPopup(SetHotKey, this); AddLayer(_gauntletLayer); ScreenManager.TrySetFocus(_gauntletLayer); }
/// <summary> /// Gets the <see cref="GrhData"/> by the given categorization information. /// </summary> /// <param name="category">Category of the <see cref="GrhData"/>.</param> /// <param name="title">Title of the <see cref="GrhData"/>.</param> /// <returns><see cref="GrhData"/> matching the given information if found, or null if no matches.</returns> public static GrhData GetData(SpriteCategory category, SpriteTitle title) { // Get the dictionary for the category var titleDic = GetDatas(category); // If we failed to get it, return null if (titleDic == null) { return(null); } // Try and get the GrhData for the given title, returning the GrhData // if it exists, or null if it does not exist in the dictionary GrhData ret; if (titleDic.TryGetValue(title, out ret)) { return(ret); } else { return(null); } }
protected override void OnInitialize() { base.OnInitialize(); TogglePause(); var spriteData = UIResourceManager.SpriteData; var resourceContext = UIResourceManager.ResourceContext; var uiResourceDepot = UIResourceManager.UIResourceDepot; _plotCategory = spriteData.SpriteCategories["ui_quest"]; _plotCategory.Load(resourceContext, uiResourceDepot); _dataSource = new PlotsVM(CloseScreen); _gauntletLayer = new GauntletLayer(1337); _gauntletLayer.InputRestrictions.SetInputRestrictions(); _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericPanelGameKeyCategory")); _gauntletLayer.LoadMovie("PlotsScreen", _dataSource); _gauntletLayer.IsFocusLayer = true; AddLayer(_gauntletLayer); ScreenManager.TrySetFocus(_gauntletLayer); }
/// <summary> /// Initializes a new instance of the <see cref="GrhCharacterSprite"/> class. /// </summary> /// <param name="character">The character this <see cref="GrhCharacterSprite"/> is for.</param> /// <param name="rootCategory">The root category for the character sprites.</param> public GrhCharacterSprite(Entity character, SpriteCategory rootCategory) { _character = character; _rootCategory = rootCategory; }
/// <summary> /// Gets the <see cref="ISprite"/> for the skin with the given <see cref="SpriteTitle"/>. /// </summary> /// <param name="subCategory">The sprite sub-category under the skin.</param> /// <param name="spriteTitle">The title of the <see cref="ISprite"/> to get.</param> /// <returns>The <see cref="ISprite"/> for the skin with the given <see cref="SpriteTitle"/>, /// or null if no <see cref="ISprite"/> could be created with the given categorization information.</returns> public ISprite GetSprite(SpriteCategory subCategory, SpriteTitle spriteTitle) { var key = string.Empty; if (subCategory != null && subCategory.ToString().Length > 0) key += subCategory; if (spriteTitle != null) key += "." + spriteTitle; // Check for the sprite in the cache ISprite sprite; if (_spriteCache.TryGetValue(key, out sprite)) return sprite; // Check for the sprite in the current skin var fullSC = GetSpriteCategory(CurrentSkin, subCategory); var grhData = GrhInfo.GetData(fullSC, spriteTitle); // The sprite was not found in the current category, so check the default category only if the current category // is not the default category if (grhData == null && !IsCurrentSkinDefault) { fullSC = GetSpriteCategory(DefaultSkin, subCategory); grhData = GrhInfo.GetData(fullSC, spriteTitle); } // If the grhData is not null, create the sprite, otherwise have the sprite be null if (grhData == null) sprite = null; else sprite = new Grh(grhData); // Add the sprite to the cache, even if it is null try { if (sprite != null) _spriteCache.Add(key, sprite); } catch (ArgumentException ex) { const string errmsg = "Key `{0}` already exists. Multi-threading conflict? This should never happen, but its likely not critical. Exception: {1}"; if (log.IsWarnEnabled) log.WarnFormat(errmsg, key, ex); Debug.Fail(string.Format(errmsg, key, ex)); } // Return the sprite return sprite; }
/// <summary> /// Gets the <see cref="ControlBorder"/> for the <see cref="Control"/> with the given name. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The sprite sub-category under the <paramref name="controlName"/>.</param> /// <returns>The <see cref="ControlBorder"/> for the <see cref="Control"/> with the given name.</returns> public ControlBorder GetBorder(string controlName, SpriteCategory subCategory) { var key = controlName; if (subCategory != null && subCategory.ToString().Length > 0) key += subCategory; // First, try to get the border from the cache ControlBorder ret; if (_borderCache.TryGetValue(key, out ret)) return ret; // Didn't exist in the cache, so create the new border and add it to the cache ret = CreateBorder(controlName, subCategory); try { _borderCache.Add(key, ret); } catch (ArgumentException ex) { Debug.Fail( "Key already exists. Multi-threading conflict? This should never happen, but its likely not critical." + ex); } // Return the border return ret; }
/// <summary> /// Gets the file path to the file containing the <see cref="ControlBorderDrawStyle"/>s for a <see cref="ControlBorder"/>. /// </summary> /// <param name="fullSubCategory">The full sub-category of the border.</param> /// <returns>The path to the border draw styles file.</returns> string GetBorderDrawStylesFilePath(SpriteCategory fullSubCategory) { // Get the sprite category for the current skin var spriteCat = GetSpriteCategory(CurrentSkin, fullSubCategory); // Replace the sprite categorization delimiters with path separators var spritePath = spriteCat.ToString().Replace(SpriteCategorization.Delimiter, Path.DirectorySeparatorChar.ToString()); // Take the sprite category, now formatted as a path, and prefix the full qualified path to the Grhs var borderStylesFile = ContentPaths.Build.Grhs.Join(spritePath); // Append the name of the file borderStylesFile = borderStylesFile.Join(_borderStylesFileName); return borderStylesFile; }
/// <summary> /// Gets the <see cref="ISprite"/> for the <see cref="Control"/> with the given <paramref name="spriteTitle"/>. /// </summary> /// <param name="controlName">The name of the <see cref="Control"/>.</param> /// <param name="subCategory">The sprite sub-category under the <paramref name="controlName"/>.</param> /// <param name="spriteTitle">The <see cref="SpriteTitle"/> of the <see cref="ISprite"/> to load.</param> /// <returns>The <see cref="ISprite"/> for the <see cref="Control"/> with the given /// <paramref name="spriteTitle"/>.</returns> public ISprite GetControlSprite(string controlName, SpriteCategory subCategory, SpriteTitle spriteTitle) { var completeSubCategory = GetControlSpriteSubCategory(controlName); if (subCategory != null && subCategory.ToString().Length > 0) completeSubCategory += SpriteCategorization.Delimiter + subCategory; return GetSprite(completeSubCategory, spriteTitle); }
/// <summary> /// Gets the absolute <see cref="SpriteCategory"/> path for the given skin and skin sub-category. /// </summary> /// <param name="skinName">The name of the skin.</param> /// <param name="subCategory">The sub-category under the skin directory. Can be null or empty.</param> /// <returns>The absolute <see cref="SpriteCategory"/> path for the given skin and skin sub-category.</returns> protected virtual SpriteCategory GetSpriteCategory(string skinName, SpriteCategory subCategory) { const string del = SpriteCategorization.Delimiter; var sb = new StringBuilder(64); sb.Append("GUI"); sb.Append(del); sb.Append(skinName); if (subCategory != null && subCategory.ToString().Length > 0) { sb.Append(del); sb.Append(subCategory); } return new SpriteCategory(sb.ToString()); }