public void PutMessage(InteractDialogMsg msg)
    {
        msg.modal = false;
        msg.xmlName = xmlFile.name;
        msg.className = className;
        GUIDialog dialog = GUIManager.GetInstance().LoadDialog(msg) as GUIDialog;
		if ( dialog != null )
		{
			// find the title
			GUILabel label = dialog.Find("title") as GUILabel;
			if ( label != null )
			{
				label.text = msg.title;
			}
		}
    }
    public void SpeechToText(string command)
    {
        // move to lower case
        command = command.ToLower();

        // translate command to game world
        command = Translate(command);

        // put info qi
        //QuickInfoMsg qimsg = new QuickInfoMsg();
        //qimsg.command = DialogMsg.Cmd.open;
        //qimsg.title = "Speech Command";
        //qimsg.text = "Cmd=<" + command + "> ...";
        //QuickInfoDialog.GetInstance().PutMessage(qimsg);

        // check dialog manager
        DialogMgr.GetInstance().SpeechToText(command);

        // run it through the dialog
        if (DialogueTree.Instance.ActiveDialogue != null)
            DialogueTree.Instance.ActiveDialogue.SpeechToText(command);

        // send to everyone
        SpeechMsg speechmsg = new SpeechMsg(command);
        ObjectManager.GetInstance().PutMessage(speechmsg);

        // find closest command by interrigating all the objects
        if (speechmsg.Stats.Count > 0)
        {
            SpeechMsg.Info info = null;
            foreach (SpeechMsg.Info tmp in speechmsg.Stats)
            {
                if (info == null)
                    // first one
                    info = tmp;
                else
                {
                    // check for higher percentage
                    if (tmp.percent > info.percent)
                        info = tmp;
                }
            }
            if (info != null)
            {
                // send this command
                InteractMsg interact = new InteractMsg(info.obj.gameObject, info.map, true);
                info.obj.PutMessage(interact);

                // close the interact menu....just in case
                InteractDialogMsg msg = new InteractDialogMsg();
                msg.command = DialogMsg.Cmd.close;
                InteractDialogLoader.GetInstance().PutMessage(msg);
            }
        }
    }
	void LoadOldMenu() {
		page = 0;
		menuLocation = breadcrumbs.Last();
		breadcrumbs.RemoveAt(breadcrumbs.Count-1);
		string newXML;
		if(breadcrumbs.Count > 0) {
			newXML = breadcrumbs.Last().Remove(0, 4);
			Debug.Log("Reverting to " + newXML);
			InteractDialogMsg idmsg = new InteractDialogMsg();
	        idmsg.LoadXML("XML/Interactions/" + newXML);
			items = idmsg.items;
			menuLocation = newXML;
		}
		else {
			newXML = baseXML;
			Debug.Log("Reverting to " + newXML);
			InteractDialogMsg idmsg = new InteractDialogMsg();
	        idmsg.LoadXML(newXML);
			items = idmsg.items;
			menuLocation = newXML;
		}
	}
	public override void DoInteractMenu ()
	{
		return; // disable this menu
        // causes object to dim
        OnMouseExit();

        // interact menu
        InteractDialogMsg msg = new InteractDialogMsg();
		msg.title = this.prettyname;
        msg.command = DialogMsg.Cmd.open;
        msg.baseobj = this;
		ScriptedObject so = GetComponent<ScriptedObject>();
		if (so != null)
			msg.items = so.QualifiedInteractions();
		else
			msg.items = ItemResponse; // this is where added items get placed on the menu, because they are in here...

        msg.modal = true;
        print(InteractDialog.GetInstance().title);
        //InteractDialog.GetInstance().PutMessage(msg);
        InteractDialogLoader.GetInstance().PutMessage(msg);

        Brain.GetInstance().PlayAudio("OBJECT:INTERACT:CLICK");
	}
	void LoadNewMenu(InteractionMap item) {
		page = 0;
		breadcrumbs.Add(item.item);
		menuLocation = item.item;
		string newXML = item.item.Remove(0, 4);
		
		InteractDialogMsg idmsg = new InteractDialogMsg();
        //idmsg.command = DialogMsg.Cmd.open;
        idmsg.LoadXML("XML/Interactions/" + newXML);
		items = idmsg.items;
        //InteractDialog.GetInstance().PutMessage(idmsg);
	}
Example #6
0
 public virtual void UpdateMenu(InteractDialogMsg msg)
 {
     prettyname = msg.title;
     originXML = msg.baseXML;
 }
    public void CompileInteractions(string category)
    {
        dioItems = new List<DIOInteractions>();
        Object[] temp = ObjectInteraction.FindObjectsOfType(typeof(ObjectInteraction));
        List<InteractionMap> items = new List<InteractionMap>();
        List<InteractionMap> tempList;
        foreach (Object obj in temp)
        {
            // Ignore this instance
            if (obj == this) continue;
            ObjectInteraction objI = obj as ObjectInteraction;
            if (!objI.onTeamMenu) continue;

            tempList = new List<InteractionMap>();

            ScriptedObject so = objI.GetComponent<ScriptedObject>();
            if (so != null)
                tempList = so.QualifiedInteractions();
            else
                tempList = ItemResponse;

            // Check each interactionmap's category to see if it matches the passed-in category
            foreach (InteractionMap im in tempList)
            {
                string front;
                int start = 0;

                // check if subcatagories listed in string
                if (im.category == null) continue;
                foreach (string cat in im.category)
                {
                    if ((start = cat.IndexOf("/")) >= 0)
                        front = cat.Substring(0, start);
                    else
                        front = cat;

                    if (front.ToLower() == category.ToLower())
                    {
                        items.Add(im);

                        DIOInteractions dio = new DIOInteractions();
                        dio.item = im;
                        dio.objectInteraction = objI;
                        dioItems.Add(dio);
                        break;
                    }
                }
            }
        } // End of object looping

        // Create Interact dialog message
        prettyname = category.ToUpper();
        ItemResponse = items;
        InteractDialogMsg msg = new InteractDialogMsg();
        msg.command = DialogMsg.Cmd.open;
        msg.baseobj = this;
        msg.title = category;
        msg.x = (int)Input.mousePosition.x;
        msg.y = (int)Input.mousePosition.y;
        msg.items = items; // this is where added items get placed on the menu, because they are in here...
        msg.modal = true;
        msg.baseXML = "";
        InteractDialogLoader.GetInstance().PutMessage(msg);

    }
    public override void Execute()
    {
        if (!Visible)
            return;

		base.Execute();

        int i;
        List<GUIMenu.MenuButton> buttons = lmenu.GetButtons();
		GUIMenu.MenuButton mbutton = lmenu.GetOnButton();
		
		if ( mbutton != null )
		{
	        // Check Target button, if active
            if ( mbutton.button.text == sHome ) // Patient button
	        {
                interactObject = target;
	
				// change title
				if ( title != null )
					title.text = interactObject.prettyname;
	
                InteractDialogMsg idmsg = new InteractDialogMsg();
                xmlData = interactObject.originXML;
                ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
                if (so != null)
                    idmsg.items = so.QualifiedInteractions();
                else
                    idmsg.items = interactObject.ItemResponse;
                //idmsg.LoadXML(xmlData);
                idmsg.baseXML = xmlData;
                idmsg.baseobj = interactObject;
	
                Setup(idmsg);
	
                pastXMLs.Clear();
                rooming = false;
            }
            if ( mbutton.button.text == sPatient ) // Patient button
	        {
	            interactObject = patient;
				
				// change title
				if ( title != null )
					title.text = interactObject.prettyname;
	
	            InteractDialogMsg idmsg = new InteractDialogMsg();
	            xmlData = interactObject.originXML;
	            ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
	            if (so != null)
	                idmsg.items = so.QualifiedInteractions();
	            else
	                idmsg.items = interactObject.ItemResponse;
	            //idmsg.LoadXML(xmlData);
	            idmsg.baseXML = xmlData;
	            idmsg.baseobj = interactObject;
	
	            Setup(idmsg);
	
	            pastXMLs.Clear();
	            rooming = false;
	        }
	        else if ( mbutton.button.text == sTeam ) // Team button
	        {
				// change button[0] name to this object
				
	            // Setup buttons
	            List<string> entries = new List<string>();
	            foreach (ObjectInteraction obj in roomObjects)
	            {
					if (obj.onTeamMenu)
						entries.Add(obj.prettyname);
	            }
	            rmenu.Setup(entries);
	            rooming = true;
	        }
	        else if ( mbutton.button.text == sBack ) // GoBack button
	        {
	            if (current != listings)
	            {
	                //InteractDialogMsg idmsg = new InteractDialogMsg();
	                //xmlData = pastXMLs[pastXMLs.Count - 1];
	                //idmsg.LoadXML(xmlData);
	                //idmsg.baseXML = xmlData;
	                //idmsg.baseobj = interactObject;
	
	                //Setup(idmsg);
	
	                //pastXMLs.RemoveAt(pastXMLs.Count - 1);
	                //rooming = false;
	
	                current = current.parent;
	                rooming = false;
	                SetupRight(current);
	            }
	            else
	            {
	                Visible = false;
	            }
	        }
			// clear buttons
	        for (i = 0; i < buttons.Count; i++)
	        {
	            buttons[i].on = false;
	        }
		}

        buttons = rmenu.GetButtons();
        for (i = 0; i < buttons.Count; i++)
        {
            if (rooming)
            {
                if (buttons[i].on)
                {
                    interactObject = null;
                    // Find matching Object by name (allows for onTeamMenu to work during runtime)
                    foreach (ObjectInteraction oi in roomObjects)
                    {
                        if (buttons[i].button.text == oi.prettyname)
                        {
                            interactObject = oi;
                            break;
                        }
                    }
                    if (interactObject == null) break; // Safety measure

                    InteractDialogMsg idmsg = new InteractDialogMsg();
                    xmlData = interactObject.originXML;
                    ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
                    if (so != null)
                        idmsg.items = so.QualifiedInteractions();
                    else
                        idmsg.items = interactObject.ItemResponse;
					
                    idmsg.baseXML = xmlData;
                    idmsg.baseobj = interactObject;

					// change the title bar (or first element of left column for now) to be
					// this button name
					title.text = buttons[i].button.text;

					Setup(idmsg);					

                    pastXMLs.Clear();
                    rooming = false;
                    break;
                }
            }
            else
            {
                if (buttons[i].on)
                {
                    if (i < current.subCategories.Count)
                    {
                        current = current.subCategories[i];
                        SetupRight(current);
                        break;
                    }
                    else
                    {
                        InteractionMap im = current.items[i - current.subCategories.Count];
                        
                        // Activate interaction!
                        interactObject.PutMessage(new InteractMsg(interactObject.gameObject, im, im.log));
                        current=listings; // reset the menu for next time PAA
                        Visible = false;
                        break;
                    }
                }
            }
            buttons[i].on = false;
        }
    }
    void Setup(InteractDialogMsg msg)
    {
        // set visible
        Visible = true;
        if (msg.items != null)
        {
            // copy new items
            items = msg.items;

            // set game object
            interactObject = msg.baseobj;
			
            xmlData = msg.baseXML;

            // set position
            //area.x = x;
            //area.y = y;

            // Setup buttons
            List<string> entries = new List<string>();
			
			listings = new Listings();
            listings.subCategories.Clear();
            listings.items.Clear();
            // Build catagories
            foreach (InteractionMap item in items)
            {
                if (item.category != null)
                {
                    foreach (string category in item.category)
                    {
                        ParseCategory(listings, category);
                    }
                }
            }

            // Fill entries
            foreach (InteractionMap item in items)
            {
                if (item.category != null && item.category.Count > 0)
                {
                    foreach (string category in item.category)
                    {
                        AddtoCategory(item, listings, category);
                    }
                }
                else
                {
                    listings.items.Add(item);
                }
            }

            //rmenu.Setup(entries);
            RightPanelInit(listings);
			current = listings;
        }
        else
        {
            interactObject = null;
            xmlData = "";
        }
    }
	protected void GotoObj( ObjectInteraction objint )
	{
		if ( objint == null )
			return;
		
        interactObject = objint;
				
		// change title
		if ( label != null )
			label.text = interactObject.prettyname;
	
        InteractDialogMsg idmsg = new InteractDialogMsg();
        xmlData = interactObject.originXML;
        ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
        if (so != null)
            idmsg.items = so.QualifiedInteractions();
        else
            idmsg.items = interactObject.ItemResponse;
        //idmsg.LoadXML(xmlData);
    	idmsg.baseXML = xmlData;
        idmsg.baseobj = interactObject;
	
        Setup(idmsg);
	}