Esempio n. 1
0
        private void UpdateGuiParams(idUserInterface gui, idDict args)
        {
            if ((gui == null) || (args == null))
            {
                return;
            }

            foreach (KeyValuePair <string, string> kvp in args.MatchPrefix("gui_parm"))
            {
                gui.State.Set(kvp.Key, kvp.Value);
            }

            gui.State.Set("noninteractive", args.GetBool("gui_noninteractive"));
            gui.StateChanged(idR.Game.Time);
        }
Esempio n. 2
0
		private void UpdateGuiParams(idUserInterface gui, idDict args)
		{
			if((gui == null) || (args == null))
			{
				return;
			}

			foreach(KeyValuePair<string, string> kvp in args.MatchPrefix("gui_parm"))
			{
				gui.State.Set(kvp.Key, kvp.Value);
			}

			gui.State.Set("noninteractive", args.GetBool("gui_noninteractive"));
			gui.StateChanged(idR.Game.Time);
		}
Esempio n. 3
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
		}
Esempio n. 4
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken token;
            idToken token2;
            string  value;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                value = token.ToString();

                if (value == "}")
                {
                    break;
                }

                if (token.Type != TokenType.String)
                {
                    lexer.Warning("Expected quoted string, but found '{0}'", value);
                    MakeDefault();

                    return(false);
                }

                if ((token2 = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Unexpected end of file");
                    MakeDefault();

                    return(false);
                }

                if (_dict.ContainsKey(value) == true)
                {
                    lexer.Warning("'{0}' already defined", value);
                }

                _dict.Set(value, token2.ToString());
            }

            // we always automatically set a "classname" key to our name
            _dict.Set("classname", this.Name);

            // "inherit" keys will cause all values from another entityDef to be copied into this one
            // if they don't conflict.  We can't have circular recursions, because each entityDef will
            // never be parsed more than once

            // find all of the dicts first, because copying inherited values will modify the dict
            List <idDeclEntity> defList      = new List <idDeclEntity>();
            List <string>       keysToRemove = new List <string>();

            foreach (KeyValuePair <string, string> kvp in _dict.MatchPrefix("inherit"))
            {
                idDeclEntity copy = idE.DeclManager.FindType <idDeclEntity>(DeclType.EntityDef, kvp.Value, false);

                if (copy == null)
                {
                    lexer.Warning("Unknown entityDef '{0}' inherited by '{1}'", kvp.Value, this.Name);
                }
                else
                {
                    defList.Add(copy);
                }

                // delete this key/value pair
                keysToRemove.Add(kvp.Key);
            }

            _dict.Remove(keysToRemove.ToArray());

            // now copy over the inherited key / value pairs
            foreach (idDeclEntity def in defList)
            {
                _dict.SetDefaults(def._dict);
            }

            // precache all referenced media
            // do this as long as we arent in modview
            idE.Game.CacheDictionaryMedia(_dict);

            return(true);
        }