public TileSet GetTileSet(string tilesetId) { TileSet tileSet = null; if (tileSetManager.Exists(tilesetId)) { tileSet = tileSetManager.Get(tilesetId); } else { tileSet = LoadTileSet(tilesetId); if (tileSet != null) { tileSetManager.Add(tileSet); } else { Texture tex = GetTexture(tilesetId); if (tex != null) { tileSet = new TileSet(tilesetId); tileSet.AddImage(tex); tileSetManager.Add(tileSet); } } } return(tileSet); }
public void Load(string rootPath, string moduleName) { if (!Directory.Exists(rootPath)) { return; } _rm = new ResourceManager(); moduleName = Path.GetExtension(moduleName) != ErfFile.ModExt ? moduleName + ErfFile.ModExt : moduleName; _diRoot = new DirectoryInfo(rootPath); _diModules = new DirectoryInfo(_diRoot.FullName + ModuleDir); _diOverride = new DirectoryInfo(_diRoot.FullName + OverrideDir); _diHak = new DirectoryInfo(_diRoot.FullName + HakDir); _rm.Add(Directory.GetFiles(_diRoot.FullName, "*" + KeyFile.Ext)); _rm.Add(_diOverride.FullName); _mod = new ErfFile(_diModules.FullName + "/" + moduleName); _modInfo = new GffDocument(_mod[FileInfoName].DataStream); _rm.Add(HakList); _rm.Add(_diModules.FullName + "/" + moduleName); }
/// <summary> /// Creates the resource manager for the server. /// </summary> protected override ResourceManager CreateResourceManager(IServerInternal server, ApplicationConfiguration configuration) { ResourceManager resourceManager = new ResourceManager(server, configuration); // add some localized strings to the resource manager to demonstrate that localization occurs. resourceManager.Add("UnexpectedUserTokenError", "fr-FR", "Une erreur inattendue s'est produite lors de la validation utilisateur."); resourceManager.Add("BadUserAccessDenied", "fr-FR", "Utilisateur ne peut pas changer la valeur."); return(resourceManager); }
public static void LoadResources(ResourceManager resourceManager) { //var dir = Path.GetDirectoryName(PathTools.GetSourceFilePath()) + @"\Resources\"; //resourceManager.Add<Shader>("shader", new ResourceVertFragShaderFile(dir + "vertex.vert", dir + "fragment.frag")); resourceManager.Add <Shader>(ShaderDefault, new ResourceVertFragShaderString(Encoding.UTF8.GetString(Resourcen.vertex), Encoding.UTF8.GetString(Resourcen.fragment))); resourceManager.Add <Shader>(ShaderCopy, new ResourceVertFragShaderString(TextureToFrameBuffer.VertexShaderScreenQuad, TextureToFrameBuffer.FragmentShaderCopy)); //resourceManager.AddShader("shader", dir + "vertex.vert", dir + "fragment.frag" // , Resourcen.vertex, Resourcen.fragment); resourceManager.Add <Texture>(TextureDiffuse, new ResourceTextureBitmap(Resourcen.capsule0)); }
protected override ResourceManager CreateResourceManager(IServerInternal server, ApplicationConfiguration configuration) { ResourceManager resourceManager = new ResourceManager(server, configuration); // add some localized strings to the resource manager to demonstrate that localization occurs. resourceManager.Add("InvalidPassword", "de-DE", "Das Passwort ist nicht gültig für Konto '{0}'."); resourceManager.Add("InvalidPassword", "es-ES", "La contraseña no es válida para la cuenta de '{0}'."); resourceManager.Add("UnexpectedUserTokenError", "fr-FR", "Une erreur inattendue s'est produite lors de la validation utilisateur."); resourceManager.Add("UnexpectedUserTokenError", "de-DE", "Ein unerwarteter Fehler ist aufgetreten während des Anwenders."); return(resourceManager); }
/// <summary> /// Creates the resource manager for the server. /// </summary> protected override ResourceManager CreateResourceManager(IServerInternal server, ApplicationConfiguration configuration) { ResourceManager resourceManager = new ResourceManager(server, configuration); // add some localized strings to the resource manager to demonstrate that localization occurs. resourceManager.Add("InvalidPassword", "zh-cn", "密码验证失败,'{0}'."); resourceManager.Add("UnexpectedUserTokenError", "zh-cn", "错误的用户令牌。"); resourceManager.Add("BadUserAccessDenied", "zh-cn", "当前用户名不存在。"); return(resourceManager); }
public static void SearchScript() { var noConfigfiles = Directory.GetFiles(varDir + @"\script\", "*.lua", SearchOption.TopDirectoryOnly); foreach (var f in noConfigfiles) { var info = new FileInfo(f); var key = Guid.NewGuid().ToString(); Scripts.Add(key, new Script() { FileName = info.Name, DisplayName = info.Name.Replace(info.Extension, ""), FullPath = info.FullName, Content = File.ReadAllText(info.FullName, Encoding.Default) }); } var configFiles = Directory.GetFiles(varDir + @"\script\", "*.lua", SearchOption.AllDirectories); foreach (var f in configFiles) { // 已经读过了 if (noConfigfiles.Contains(f)) { continue; } var info = new FileInfo(f); var conf = info.Directory + @"\config.json"; if (!File.Exists(conf)) { // 没有配置文件 var key = Guid.NewGuid().ToString(); Scripts.Add(key, new Script() { FileName = info.Name, DisplayName = info.Name.Replace(info.Extension, ""), FullPath = info.FullName, Content = File.ReadAllText(info.FullName, Encoding.Default) }); continue; } var script = new Script() { FileName = info.Name, FullPath = info.FullName, Content = File.ReadAllText(info.FullName, Encoding.Default) }; // 解析配置 script.ParseConfig(conf); Program.Scripts.Add(Guid.NewGuid().ToString(), script); } }
private void InitializeResources() { var tilesets = new GameTilesets(); resources = new ResourceManager(); resources.Add(tilesets); }
private void OnAssetLoaded(string lowerResPath, AssetBundle ab, UnityEngine.Object asset) { SameRequestCache src; bool isPreload = false; if (sameRequestCache_.TryGetValue(lowerResPath, out src)) { try { foreach (AsyncLoadRequest request in src.srcList) { isPreload = isPreload | request.isPreload; Callback(lowerResPath, request, asset); } src.srcList.Clear(); sameRequestCache_.Remove(lowerResPath); } catch (Exception ex) { Debug.Log(ex.Message); Debug.Log(ex.StackTrace); Debug.Log("Execption in OnAssetLoaded*********"); Debug.Log(ex.ToString()); } } if (ab && asset) { ResourceManager.Add(lowerResPath, ab, asset, isPreload); } }
public void InitializeSfml() { var tilesets = new EditorTilesets(); model = new HexModel(40); resources = new ResourceManager(); resources.Add(tilesets); CreateBrushes(tilesets); toolBar.SelectPlayer(PlayerColour.Red); world = new Map(model, resources); world.Create(new Vector2i(10, 10)); window = drawingSurface.InitializeSfml(); editorView = new EditorView(window, world); window.OnKeyPress(Keyboard.Key.Space, () => editorView.Return()); window.OnKeyHold(Keyboard.Key.Left, () => editorView.Scroll(Direction.Left)); window.OnKeyHold(Keyboard.Key.Right, () => editorView.Scroll(Direction.Right)); window.OnKeyHold(Keyboard.Key.Up, () => editorView.Scroll(Direction.Up)); window.OnKeyHold(Keyboard.Key.Down, () => editorView.Scroll(Direction.Down)); window.OnKeyHold(Keyboard.Key.Add, editorView.IncrementScrollSpeed); window.OnKeyHold(Keyboard.Key.Subtract, editorView.DecrementScrollSpeed); }
public override SpriteComponent GetComponentFromDefinition(Entity entity) { if (SpriteType == null) { throw new NullReferenceException("sprite type"); } if (SpriteType.ToLower().Equals("static")) { if (Resource == null) { throw new NullReferenceException("static type, resource"); } if (ResourceManager <Texture> .Get(Resource) is null) { ResourceManager <Texture> .Add(ResourceLoader.LoadTexture(Resource, TextureFilter.NEAREST)); } return(new SpriteComponent { Value = new Renderable2D(new SharpDX.Vector2(Size[0], Size[1]), ResourceManager <Texture> .Get(Resource)) }); } return(new SpriteComponent { Value = new Renderable2D(new SharpDX.Vector2(Size[0], Size[1]), 0xffff00ff) }); }
public void TestResourceServer() { m_noAdmitCount = 0; m_admitCount = 0; m_model = new Model(); ((Model)m_model).RandomServer = new Randoms.RandomServer(54321, 100); ItemSource factory = CreatePatientGenerator("Patient_", 25, 5.0, 3.0); Queue queue = new Queue(m_model, "TestQueue", Guid.NewGuid()); ConnectorFactory.Connect(factory.Output, queue.Input); NormalDistribution dist = new NormalDistribution(m_model, "SvcDistribution", Guid.NewGuid(), 15.0, 3.0); IPeriodicity per = new Periodicity(dist, Periodicity.Units.Minutes); ResourceManager rscPool = new ResourceManager(m_model, "RscMgr", Guid.NewGuid()); for (int i = 0; i < 3; i++) { rscPool.Add(new Resource(m_model, "rsc_" + i, Guid.NewGuid(), 1.0, 1.0, true, true, true)); } ResourceServer rs = new ResourceServer(m_model, "RscSvr", Guid.NewGuid(), per, new IResourceRequest[] { new SimpleResourceRequest(1.0, rscPool) }); rs.PlaceInService(); ConnectorFactory.Connect(queue.Output, rs.Input); factory.Output.PortDataPresented += new PortDataEvent(FactoryOutput_PortDataPresented); queue.LevelChangedEvent += new QueueLevelChangeEvent(Queue_LevelChangedEvent); rs.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning); rs.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted); m_model.Start(); }
private static void LoadResources(ResourceManager resourceManager) { resourceManager.Add(nameof(Resourcen.smoke), new ResourceTextureBitmap(Resourcen.smoke)); var dir = Path.GetDirectoryName(PathTools.GetSourceFilePath()) + "/Resources/"; resourceManager.AddShader(VisualSmoke.ShaderName, dir + "smoke.vert", dir + "smoke.frag" , Resourcen.smoke_vert, Resourcen.smoke_frag); resourceManager.AddShader(VisualWaterfall.ShaderName, dir + "smoke.vert", dir + "smoke.frag" , Resourcen.smoke_vert, Resourcen.smoke_frag); }
public void ResourceDisposalHighReferenceCount() { var bm = new BitmapResource(); ResourceManager.Add("ResourceDisposalHighReferenceCount", bm); ResourceManager.Request <BitmapResource>("ResourceDisposalHighReferenceCount"); ResourceManager.Request <BitmapResource>("ResourceDisposalHighReferenceCount"); bm.Dispose(); Assert.IsFalse(bm.Disposed); bm.Dispose(); Assert.IsTrue(bm.Disposed); }
public void ResourceDisposal() { var bm = new BitmapResource(); ResourceManager.Add("ResourceDisposal", bm); Assert.AreEqual(0, bm.ReferenceCount, "Incorrect initial count"); ResourceManager.Request <BitmapResource>("ResourceDisposal"); Assert.AreEqual(1, bm.ReferenceCount, "Incorrect reference count"); bm.Dispose(); Assert.AreEqual(0, bm.ReferenceCount, "Incorrect count after dispose"); Assert.IsTrue(bm.Disposed); }
//Creating Resource manager for the server. protected override ResourceManager CreateResourceManager(IServerInternal server, ApplicationConfiguration configuration) { ResourceManager resourceManager = new ResourceManager(server, configuration); System.Reflection.FieldInfo[] fields = typeof(StatusCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); foreach (System.Reflection.FieldInfo field in fields) { uint?id = field.GetValue(typeof(StatusCodes)) as uint?; if (id != null) { resourceManager.Add(id.Value, "en-US", field.Name); } } return(resourceManager); }
public void SubBitmaps() { var bm = new BitmapResource(); ResourceManager.Add("SubBitmaps", bm); var sub = bm.CreateSubBitmap(new Rectangle(0, 0, 1, 1)); Assert.AreEqual(0, bm.ReferenceCount, "Incorrect base reference count after sub bitmap"); Assert.AreEqual(1, sub.ReferenceCount, "Incorrect subbitmap count"); sub.Dispose(); Assert.AreEqual(0, bm.ReferenceCount, "Incorrect base reference count after sub disposal"); Assert.AreEqual(0, sub.ReferenceCount, "Incorrect sub bitmap count after disposal"); }
public Font OpenFont(string name, int size) { string fn = Font.GetFontName(name, size); Font font = fontManager.Get(fn); if (font == null) { font = MakeFont(name, size); if (font != null) { fontManager.Add(font); } } return(font); }
public Texture GetTexture(string textureId) { Texture tex = null; if (textureManager.Exists(textureId)) { tex = textureManager.Get(textureId); } else { tex = graphics.GetTexture(textureId, fileResolver); if (tex != null) { textureManager.Add(tex); } } return(tex); }
static Vegetation() { Scene.Define("vegetation", typeof(BitmapRenderComponent), typeof(VegetationLifeComponent)); //Add dead bitmaps using (Effect e = new Effect()) { e.AddSaturation(.2f); e.Create(); foreach (var s in new string[] { "v_water", "v_desert", "v_grassland", "v_shrubland", "v_temperatedeciduous" }) { var b = e.ApplyTo(ResourceManager.Request <BitmapResource>(s)); ResourceManager.Add(s + "_dead", b, true); } } }
public Sound GetSound(string soundId) { Sound snd = null; if (soundManager.Exists(soundId)) { snd = soundManager.Get(soundId); } else { snd = sounds.GetSound(soundId, fileResolver); if (snd != null) { soundManager.Add(snd); } } return(snd); }
public Music GetMusic(string musicId) { Music mus = null; if (musicManager.Exists(musicId)) { mus = musicManager.Get(musicId); } else { mus = sounds.GetMusic(musicId, fileResolver); if (mus != null) { musicManager.Add(mus); } } return(mus); }
public override void LoadContent() { ResourceManager.Add <BitmapResource>("organism", "Graphics/organism.png", true); ResourceManager.Add <BitmapResource>("hungry", "Graphics/hungry.png", true); ResourceManager.Add <BitmapResource>("heart", "Graphics/heart.png", true); ResourceManager.Add <BitmapResource>("sleep", "Graphics/sleep.png", true); ResourceManager.Add <BitmapResource>("scared", "Graphics/scared.png", true); ResourceManager.Add <BitmapResource>("enemy", "Graphics/Enemy.png", true); ResourceManager.Add <BitmapResource>("enemy_spawner", "Graphics/enemy_spawner.png", true); ResourceManager.Add <BitmapResource>("v_water", "Graphics/v_water.png", true); ResourceManager.Add <BitmapResource>("v_grassland", "Graphics/v_grassland.png", true); ResourceManager.Add <BitmapResource>("v_shrubland", "Graphics/v_shrubland.png", true); ResourceManager.Add <BitmapResource>("v_temperatedeciduous", "Graphics/v_temperatedeciduous.png", true); ResourceManager.Add <BitmapResource>("v_desert", "Graphics/v_desert.png", true); ResourceManager.Add <AudioResource>("menu", "Audio/misc_menu.wav"); ResourceManager.Add <AudioResource>("nom", "Audio/nom.wav"); }
public Pen Get(Brush brush, HilightType type) { ResourceManager <HilightType, Pen> hilights; Pen effect; if (this.cache.TryGetValue(brush, out hilights)) { if (hilights.TryGetValue(type, out effect)) { return(effect); } effect = CreatePen(brush, type); hilights.Add(type, effect); return(effect); } effect = CreatePen(brush, type); hilights = new ResourceManager <HilightType, Pen>(); hilights.Add(type, effect); this.cache.Add(brush, hilights); return(effect); }
/// <summary> /// Creates the resource manager for the server. /// </summary> protected override ResourceManager CreateResourceManager(IServerInternal server, ApplicationConfiguration configuration) { ResourceManager resourceManager = new ResourceManager(server, configuration); // load default text for all status codes. resourceManager.LoadDefaultText(); // add translations for standard error codes. resourceManager.Add(StatusCodes.BadUserAccessDenied, "en-US", "User does not have permission to perform the requested operation."); resourceManager.Add(StatusCodes.BadUserAccessDenied, "fr-FR", "Utilisateur ne peut pas changer la valeur."); resourceManager.Add(StatusCodes.BadUserAccessDenied, "de-DE", "User nicht ändern können, Wert."); // add translations for server defined error codes. resourceManager.Add(TutorialErrorCodes.InvalidPassword, "en-US", "Specified password is not valid for user '{0}'."); resourceManager.Add(TutorialErrorCodes.InvalidPassword, "de-DE", "Das Passwort ist nicht gültig für Konto '{0}'."); resourceManager.Add(TutorialErrorCodes.InvalidPassword, "es-ES", "La contraseña no es válida para la cuenta de '{0}'."); return(resourceManager); }
public static void LoadResources(ResourceManager resourceManager) { resourceManager.Add <Shader>(ShaderPaintObstacles, new ResourceVertFragShaderString(TextureToFrameBuffer.VertexShaderScreenQuad, Encoding.UTF8.GetString(Resourcen.paintObstacles))); resourceManager.Add <Shader>(ShaderParticles, new ResourceVertFragShaderString(Encoding.UTF8.GetString(Resourcen.particles), Encoding.UTF8.GetString(Resourcen.particlesFrag))); }