InitFromFile() 공개 메소드

public InitFromFile ( string path, bool rebuild = true, bool cache = true ) : bool
path string
rebuild bool
cache bool
리턴 bool
예제 #1
0
        public idUserInterface FindInterface(string path, bool autoLoad = false, bool needUnique = false, bool forceNotUnique = false)
        {
            foreach (idUserInterface gui in _guiList)
            {
                if (gui.SourceFile.Equals(path, StringComparison.OrdinalIgnoreCase) == true)
                {
                    if ((forceNotUnique == false) && ((needUnique == true) || (gui.IsInteractive == true)))
                    {
                        break;
                    }

                    gui.AddReference();

                    return(gui);
                }
            }

            if (autoLoad == true)
            {
                idUserInterface gui = new idUserInterface();

                if (gui.InitFromFile(path) == true)
                {
                    gui.IsUnique = (forceNotUnique == true) ? false : needUnique;
                    return(gui);
                }
            }

            return(null);
        }
예제 #2
0
		/// <summary>
		/// This is called after parsing an EntityDef and for each entity spawnArgs before
		/// merging the entitydef.  It could be done post-merge, but that would
		/// avoid the fast pre-cache check associated with each entityDef.
		/// </summary>
		/// <param name="dict"></param>
		public override void CacheDictionaryMedia(idDict dict)
		{	
			#region Model
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("model"))
			{
				// precache model/animations
				if((kvp.Value != string.Empty) && (idR.DeclManager.FindType<idDecl>(DeclType.ModelDef, kvp.Value, false) == null))
				{
					// precache the render model
					idR.RenderModelManager.FindModel(kvp.Value);

					// precache .cm files only
					idR.CollisionModelManager.LoadModel(kvp.Value, true);
				}
			}
			#endregion

			#region Gui
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("gui"))
			{
				string keyLower = kvp.Key.ToLower();

				if((keyLower == "gui_noninteractive")
					|| (keyLower.StartsWith("gui_parm") == true)
					|| (keyLower == "gui_inventory"))
				{
					// unfortunate flag names, they aren't actually a gui
				}
				else
				{
					idR.DeclManager.MediaPrint(string.Format("Precaching gui {0}", kvp.Value));

					idUserInterface gui = new idUserInterface();
					
					if(gui != null)
					{
						gui.InitFromFile(kvp.Value);
						idE.UIManager.Remove(gui);
					}					
				}
			}
			#endregion

			#region Fx
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("fx"))
			{
				idR.DeclManager.MediaPrint(string.Format("Precaching fx {0}", kvp.Value));
				idR.DeclManager.FindType<idDecl>(DeclType.Fx, kvp.Value);
			}
			#endregion

			#region Smoke
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("smoke"))
			{
				string prtName = kvp.Value;
				int dash = prtName.IndexOf('-');

				if(dash > 0)
				{
					prtName = prtName.Substring(0, dash);
				}

				idR.DeclManager.FindType(DeclType.Particle, prtName);
			}
			#endregion

			#region Skin
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("skin"))
			{
				idR.DeclManager.MediaPrint(string.Format("Precaching skin {0}", kvp.Value));
				idR.DeclManager.FindType(DeclType.Skin, kvp.Value);
			}
			#endregion

			#region Def
			foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("def"))
			{
				FindEntityDef(kvp.Value, false);
			}
			#endregion

			#region Misc
			string value = dict.GetString("s_shader");

			if(value != string.Empty)
			{
				idR.DeclManager.FindType<idDecl>(DeclType.Sound, value);
			}

			value = dict.GetString("texture");

			if(value != string.Empty)
			{
				idR.DeclManager.FindType<idDecl>(DeclType.Material, value);
			}

			Dictionary<string, DeclType> cacheElements = new Dictionary<string, DeclType>() {
				{ "snd", DeclType.Sound },
				{ "mtr", DeclType.Material },
				{ "inv_icon", DeclType.Material },
				{ "pda_name", DeclType.Pda },
				{ "video", DeclType.Video },
				{ "audio", DeclType.Audio }
			};

			foreach(KeyValuePair<string, DeclType> element in cacheElements)
			{
				foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix(element.Key))
				{
					idR.DeclManager.FindType<idDecl>(element.Value, kvp.Value);
				}
			}
			#endregion
		}
		public idUserInterface FindInterface(string path, bool autoLoad = false, bool needUnique = false, bool forceNotUnique = false)
		{
			foreach(idUserInterface gui in _guiList)
			{
				if(gui.SourceFile.Equals(path, StringComparison.OrdinalIgnoreCase) == true)
				{
					if((forceNotUnique == false) && ((needUnique == true) || (gui.IsInteractive == true)))
					{
						break;
					}

					gui.AddReference();

					return gui;
				}
			}

			if(autoLoad == true)
			{
				idUserInterface gui = new idUserInterface();

				if(gui.InitFromFile(path) == true)
				{
					gui.IsUnique = (forceNotUnique == true) ? false : needUnique;
					return gui;
				}
			}

			return null;
		}