Example #1
0
            public static Mailable CreateFromXml(System.Xml.XmlElement n, IXCRMParser ixcrm_parser)
            {
                Mailable retval = new Mailable();

                retval.id           = n.GetAttribute("id");
                retval.type         = n.GetAttribute("type");
                retval.label        = n.GetAttribute("label");
                retval.requirements = ixcrm_parser.ParseRequirementList(n.SelectSingleNode("./requirements") as System.Xml.XmlElement);
                retval.costs        = ixcrm_parser.ParseCostList(n.SelectSingleNode("./costs") as System.Xml.XmlElement);
                retval.on_accept    = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./on_accept") as System.Xml.XmlElement);
                retval.on_give      = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./on_give") as System.Xml.XmlElement);
                retval.tags         = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement);
                return(retval);
            }
Example #2
0
 void onRoarGiftsGiftSent(Roar.CallbackInfo <Roar.WebObjects.Mail.SendResponse> data)
 {
     networkActionInProgress = false;
     if (data.code == IWebAPI.OK)
     {
         statusString = "Gift sent succcessfully!";
         Debug.Log("Gift sent " + data.msg);
         selectedMailable = null;
     }
     else
     {
         statusString = "Gift sending failed. Reason: " + data.msg;
         Debug.Log("Gift sent " + data.msg);
     }
 }
Example #3
0
 public async Task SendAsync <T>(Mailable <T> mailable)
 {
     await mailable.SendAsync(this._renderer, this);
 }
Example #4
0
 public Task <string> RenderAsync <T>(Mailable <T> mailable) =>
 mailable.RenderAsync(this._renderer, this);
Example #5
0
 void onRoarGiftsGiftSent(Roar.CallbackInfo<Roar.WebObjects.Mail.SendResponse> data)
 {
     networkActionInProgress = false;
     if(data.code == IWebAPI.OK)
     {
         statusString = "Gift sent succcessfully!";
         Debug.Log("Gift sent "+data.msg);
         selectedMailable = null;
     }
     else
     {
         statusString = "Gift sending failed. Reason: "+data.msg;
         Debug.Log("Gift sent "+data.msg);
     }
 }
Example #6
0
    protected override void DrawGUI(int windowId)
    {
        if (!IsLoggedIn) return;
        if (isFetching)
        {
            GUI.Label(new Rect(this.bounds.width/2f - 256,this.bounds.height/2f - 32,512,64), "Fetching Gifts...", "StatusNormal");
            return;
        }

        if( gifts==null)
        {
            GUI.Label(new Rect(this.bounds.width/2f - 256,this.bounds.height/2f - 32,512,64), "Error loading Gifts...", "StatusError");
            return;
        }

        float heightSoFar = 0;
        Rect currentRect = new Rect(interColumnSeprators, heightSoFar, fromColumnWidth, divideHeight);

        if(section == Section.Normal)
        {
            GUI.Box(new Rect(0, 0, contentBounds.width, divideHeight), new GUIContent(""), "DefaultSeparationBar");
            GUI.Label ( currentRect, "FROM", "DefaultSeparationBarText");
            currentRect.x += interColumnSeprators + fromColumnWidth;

            GUI.Label ( currentRect, "MESSAGE", "DefaultSeparationBarText");
            currentRect.x += interColumnSeprators + messageColumnWidth;

            GUI.Label ( currentRect, "TYPE", "DefaultSeparationBarText");
            currentRect.x += interColumnSeprators + typeColumnWidth;
            currentRect.x = interColumnSeprators;
            currentRect.y += divideHeight;
            currentRect.height = sectionHeight;

            internalScrollSize = GUI.BeginScrollView(new Rect(currentRect.x, currentRect.y, contentBounds.width, contentBounds.height - currentRect.y - verticalSeparators - labelHeight*2 -footerSpacing), internalScrollSize,
                new Rect(currentRect.x, currentRect.y, contentBounds.width - interColumnSeprators*2, sectionHeight*mailDict.Count));
            foreach (KeyValuePair<string,Roar.DomainObjects.MailPackage> f in mailDict)
            {
                currentRect.width = fromColumnWidth;
                GUI.Label(currentRect,  f.Value.sender_name, playerIdFormat );
                currentRect.x += interColumnSeprators + fromColumnWidth;
                currentRect.width = messageColumnWidth;
                GUI.Label(currentRect, f.Value.message, messageFormat );
                currentRect.x += interColumnSeprators + messageColumnWidth;
                currentRect.width = typeColumnWidth;
                GUI.Label(currentRect, f.Value.type, typeFormat );
                currentRect.x += interColumnSeprators + typeColumnWidth;

                currentRect.width = buttonWidth;
                currentRect.height = buttonHeight;
                if(GUI.Button(currentRect, "Open", buttonFormat))
                {
                    statusString = "";
                    mailBeingRead = f.Value;
                    section = Section.ReadingMail;
                    drawSubheading = true;
                    subheaderName = f.Value.sender_name+"'s Message";
                }
                currentRect.x = interColumnSeprators;

                currentRect.y += sectionHeight;
            }
            GUI.EndScrollView();

            currentRect.y += verticalSeparators;
            currentRect.width = contentBounds.width - interColumnSeprators*2;
            currentRect.height = labelHeight *2;

            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");

            GUI.Box(new Rect(0, contentBounds.height - footerSpacing, contentBounds.width, footerSpacing), new GUIContent(""), "DefaultFooterStyle");
            currentRect.x = interColumnSeprators;
            currentRect.y = contentBounds.height - footerSpacing/2 - buttonHeight/2;
            currentRect.width = buttonWidth;
            currentRect.height = buttonHeight;

            if(GUI.Button(currentRect, "Send Gift", "DefaultButton"))
            {
                statusString = "";
                FetchMailable();
                section = Section.SendingMail;
                drawSubheading = true;
                subheaderName = "Send Gift";
            }
        }

        if(section == Section.ReadingMail)
        {
            currentRect.width = contentBounds.width;
            currentRect.height = divideHeight;
            currentRect.x = 0;
            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");
            currentRect.y += divideHeight;

            currentRect.y += divideHeight;
            currentRect.x = interColumnSeprators;
            currentRect.width = 3*labelWidth + 2*interColumnSeprators;
            currentRect.height = labelHeight;

            GUI.Label(currentRect, "From: " + mailBeingRead.sender_name +"("+mailBeingRead.sender_id+")");
            currentRect.width = contentBounds.width - interColumnSeprators;
            currentRect.y += labelHeight;
            GUI.Label(currentRect, "Message: ", "DefaultLabel");
            currentRect.x += labelWidth+interColumnSeprators;
            currentRect.width = contentBounds.width - interColumnSeprators;
            GUI.Label(currentRect, mailBeingRead.message, "DefaultLabel");

            currentRect.y += labelHeight;
            currentRect.x = interColumnSeprators;

            CRMVisitor<string> visitorObject = new RoarTasksWidget.CRMToString();
            string modifierString = "Modifiers: \n";
            foreach(Modifier m in mailBeingRead.modifiers)
                modifierString += visitorObject.visit_modifier(m)+"\n";

            if(mailBeingRead.modifiers.Count == 0)
                modifierString += "None";

            Vector2 size = GUI.skin.FindStyle("DefaultLabel").CalcSize(new GUIContent(modifierString));

            currentRect.width = size.x;
            currentRect.height = size.y;
            GUI.Label(currentRect, modifierString, "DefaultLabel");

            currentRect.y += currentRect.height+verticalSeparators;
            currentRect.x = interColumnSeprators;

            string itemsString = "Items: \n";

            foreach(InventoryItem m in mailBeingRead.items)
                itemsString += m.label;

            Vector2 itemSize = GUI.skin.FindStyle("DefaultLabel").CalcSize(new GUIContent(itemsString));
            currentRect.width = itemSize.x;
            currentRect.height = itemSize.y;
            GUI.Label(currentRect, itemsString, "DefaultLabel");

            currentRect.y += currentRect.height+verticalSeparators;
            currentRect.x = interColumnSeprators;

            currentRect.width = buttonWidth;
            currentRect.height = buttonHeight;
            if(GUI.Button(currentRect, "Accept", "DefaultButton"))
            {
                gifts.AcceptGift(mailBeingRead.id, onRoarGiftsGiftAccepted);
                networkActionInProgress = true;
            }

            currentRect.x += buttonWidth + interColumnSeprators;
            if(GUI.Button(currentRect, "Back", "DefaultButton"))
            {
                statusString = "";
                drawSubheading = false;
                section = Section.Normal;
            }
            currentRect.x += interColumnSeprators + typeColumnWidth;
        }

        if(section == Section.SendingMail)
        {
            currentRect.y += verticalSeparators;
            currentRect.width = contentBounds.width;
            currentRect.height = divideHeight;
            currentRect.x = 0;
            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");
            currentRect.y += divideHeight;

            currentRect.x = interColumnSeprators;
            currentRect.width = labelWidth;
            currentRect.height = labelHeight;
            GUI.Label(currentRect,"To: (PlayerID)");
            currentRect.x += labelWidth + interColumnSeprators;
            currentRect.width = contentBounds.width- currentRect.x  - interColumnSeprators - selectButtonWidth;
            currentRect.height = textBoxHeight;
            playerIdToSendTo = GUI.TextField(currentRect, playerIdToSendTo, "DefaultTextArea");
            currentRect.x += contentBounds.width- currentRect.x  - interColumnSeprators - selectButtonWidth;
            currentRect.width = selectButtonWidth;
            if(GUI.Button(currentRect, "?", "DefaultButton"))
            {
                Debug.Log("going");
                System.Action<string> act = (pid) => {
                    playerIdToSendTo = pid;
                };
                GameObject.Find("/PlayerSelectionWidget").SendMessage("setCallbackAndEnable", act);
            }
            currentRect.y += labelHeight+verticalSeparators;
            currentRect.x = interColumnSeprators;
            currentRect.width = labelWidth;
            currentRect.height = labelHeight;
            GUI.Label(currentRect, "Message: ", "DefaultLabel");
            currentRect.x += labelWidth + interColumnSeprators;
            currentRect.width = contentBounds.width -currentRect.x  - interColumnSeprators;
            currentRect.height = messageBoxHeight;
            messageToSend = GUI.TextArea(currentRect, messageToSend, "DefaultBigMessageBox");

            currentRect.y += messageBoxHeight+verticalSeparators;
            currentRect.x = interColumnSeprators;
            currentRect.width = buttonWidth;
            currentRect.height = buttonHeight;

            if(GUI.Button(currentRect, "Send", "DefaultButton"))
            {
                if(selectedMailable == null)
                {
                    statusString = "Please select an item to send with your gift";
                }
                else
                {
                    networkActionInProgress = true;
                    gifts.SendGift(playerIdToSendTo, selectedMailable.id, messageToSend, onRoarGiftsGiftSent);
                }
            }

            currentRect.x += buttonWidth + interColumnSeprators;
            if(GUI.Button(currentRect, "Back", "DefaultButton"))
            {
                statusString = "";
                drawSubheading = false;
                section = Section.Normal;
            }
            currentRect.x = interColumnSeprators;
            currentRect.y+= buttonHeight+verticalSeparators;
            internalScrollSize = GUI.BeginScrollView(new Rect(currentRect.x, currentRect.y, contentBounds.width, contentBounds.height - currentRect.y), internalScrollSize,
                new Rect(currentRect.x, currentRect.y, contentBounds.width - interColumnSeprators*2, sectionHeight*mailableDict.Count));

            foreach (KeyValuePair<string,Roar.DomainObjects.Mailable> f in mailableDict)
            {
                currentRect.width = fromColumnWidth;
                GUI.Label(currentRect,  f.Value.label, playerIdFormat );
                currentRect.x += interColumnSeprators + fromColumnWidth;
                currentRect.width = messageColumnWidth;
                GUI.Label(currentRect, f.Value.type, messageFormat );
                currentRect.x += interColumnSeprators + messageColumnWidth;

                if(GUI.Toggle(currentRect, (selectedMailable == f.Value)?true:false,"Select"))
                {
                    selectedMailable = f.Value;
                }
                currentRect.x = interColumnSeprators;

                currentRect.y += sectionHeight;
            }
            GUI.EndScrollView();
            currentRect.x += interColumnSeprators + typeColumnWidth;
        }
    }
Example #7
0
 public async Task <string> RenderAsync <T>(Mailable <T> mailable) =>
 await mailable.RenderAsync(null, this);
Example #8
0
 public async Task SendAsync <T>(Mailable <T> mailable) =>
 await mailable.SendAsync(null, this);
Example #9
0
 public async Task <string> RenderAsync <T>(Mailable <T> mailable)
 {
     return(await mailable.RenderAsync(this._renderer, this));
 }
Example #10
0
    protected override void DrawGUI(int windowId)
    {
        if (!IsLoggedIn)
        {
            return;
        }
        if (isFetching)
        {
            GUI.Label(new Rect(this.bounds.width / 2f - 256, this.bounds.height / 2f - 32, 512, 64), "Fetching Gifts...", "StatusNormal");
            return;
        }

        if (gifts == null)
        {
            GUI.Label(new Rect(this.bounds.width / 2f - 256, this.bounds.height / 2f - 32, 512, 64), "Error loading Gifts...", "StatusError");
            return;
        }

        float heightSoFar = 0;
        Rect  currentRect = new Rect(interColumnSeprators, heightSoFar, fromColumnWidth, divideHeight);

        if (section == Section.Normal)
        {
            GUI.Box(new Rect(0, 0, contentBounds.width, divideHeight), new GUIContent(""), "DefaultSeparationBar");
            GUI.Label(currentRect, "FROM", "DefaultSeparationBarText");
            currentRect.x += interColumnSeprators + fromColumnWidth;

            GUI.Label(currentRect, "MESSAGE", "DefaultSeparationBarText");
            currentRect.x += interColumnSeprators + messageColumnWidth;

            GUI.Label(currentRect, "TYPE", "DefaultSeparationBarText");
            currentRect.x     += interColumnSeprators + typeColumnWidth;
            currentRect.x      = interColumnSeprators;
            currentRect.y     += divideHeight;
            currentRect.height = sectionHeight;

            internalScrollSize = GUI.BeginScrollView(new Rect(currentRect.x, currentRect.y, contentBounds.width, contentBounds.height - currentRect.y - verticalSeparators - labelHeight * 2 - footerSpacing), internalScrollSize,
                                                     new Rect(currentRect.x, currentRect.y, contentBounds.width - interColumnSeprators * 2, sectionHeight * mailDict.Count));
            foreach (KeyValuePair <string, Roar.DomainObjects.MailPackage> f in mailDict)
            {
                currentRect.width = fromColumnWidth;
                GUI.Label(currentRect, f.Value.sender_name, playerIdFormat);
                currentRect.x    += interColumnSeprators + fromColumnWidth;
                currentRect.width = messageColumnWidth;
                GUI.Label(currentRect, f.Value.message, messageFormat);
                currentRect.x    += interColumnSeprators + messageColumnWidth;
                currentRect.width = typeColumnWidth;
                GUI.Label(currentRect, f.Value.type, typeFormat);
                currentRect.x += interColumnSeprators + typeColumnWidth;

                currentRect.width  = buttonWidth;
                currentRect.height = buttonHeight;
                if (GUI.Button(currentRect, "Open", buttonFormat))
                {
                    statusString   = "";
                    mailBeingRead  = f.Value;
                    section        = Section.ReadingMail;
                    drawSubheading = true;
                    subheaderName  = f.Value.sender_name + "'s Message";
                }
                currentRect.x = interColumnSeprators;

                currentRect.y += sectionHeight;
            }
            GUI.EndScrollView();

            currentRect.y     += verticalSeparators;
            currentRect.width  = contentBounds.width - interColumnSeprators * 2;
            currentRect.height = labelHeight * 2;

            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");

            GUI.Box(new Rect(0, contentBounds.height - footerSpacing, contentBounds.width, footerSpacing), new GUIContent(""), "DefaultFooterStyle");
            currentRect.x      = interColumnSeprators;
            currentRect.y      = contentBounds.height - footerSpacing / 2 - buttonHeight / 2;
            currentRect.width  = buttonWidth;
            currentRect.height = buttonHeight;

            if (GUI.Button(currentRect, "Send Gift", "DefaultButton"))
            {
                statusString = "";
                FetchMailable();
                section        = Section.SendingMail;
                drawSubheading = true;
                subheaderName  = "Send Gift";
            }
        }

        if (section == Section.ReadingMail)
        {
            currentRect.width  = contentBounds.width;
            currentRect.height = divideHeight;
            currentRect.x      = 0;
            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");
            currentRect.y += divideHeight;

            currentRect.y     += divideHeight;
            currentRect.x      = interColumnSeprators;
            currentRect.width  = 3 * labelWidth + 2 * interColumnSeprators;
            currentRect.height = labelHeight;

            GUI.Label(currentRect, "From: " + mailBeingRead.sender_name + "(" + mailBeingRead.sender_id + ")");
            currentRect.width = contentBounds.width - interColumnSeprators;
            currentRect.y    += labelHeight;
            GUI.Label(currentRect, "Message: ", "DefaultLabel");
            currentRect.x    += labelWidth + interColumnSeprators;
            currentRect.width = contentBounds.width - interColumnSeprators;
            GUI.Label(currentRect, mailBeingRead.message, "DefaultLabel");

            currentRect.y += labelHeight;
            currentRect.x  = interColumnSeprators;

            CRMVisitor <string> visitorObject = new RoarTasksWidget.CRMToString();
            string modifierString             = "Modifiers: \n";
            foreach (Modifier m in mailBeingRead.modifiers)
            {
                modifierString += visitorObject.visit_modifier(m) + "\n";
            }

            if (mailBeingRead.modifiers.Count == 0)
            {
                modifierString += "None";
            }

            Vector2 size = GUI.skin.FindStyle("DefaultLabel").CalcSize(new GUIContent(modifierString));

            currentRect.width  = size.x;
            currentRect.height = size.y;
            GUI.Label(currentRect, modifierString, "DefaultLabel");

            currentRect.y += currentRect.height + verticalSeparators;
            currentRect.x  = interColumnSeprators;

            string itemsString = "Items: \n";

            foreach (InventoryItem m in mailBeingRead.items)
            {
                itemsString += m.label;
            }

            Vector2 itemSize = GUI.skin.FindStyle("DefaultLabel").CalcSize(new GUIContent(itemsString));
            currentRect.width  = itemSize.x;
            currentRect.height = itemSize.y;
            GUI.Label(currentRect, itemsString, "DefaultLabel");

            currentRect.y += currentRect.height + verticalSeparators;
            currentRect.x  = interColumnSeprators;

            currentRect.width  = buttonWidth;
            currentRect.height = buttonHeight;
            if (GUI.Button(currentRect, "Accept", "DefaultButton"))
            {
                gifts.AcceptGift(mailBeingRead.id, onRoarGiftsGiftAccepted);
                networkActionInProgress = true;
            }

            currentRect.x += buttonWidth + interColumnSeprators;
            if (GUI.Button(currentRect, "Back", "DefaultButton"))
            {
                statusString   = "";
                drawSubheading = false;
                section        = Section.Normal;
            }
            currentRect.x += interColumnSeprators + typeColumnWidth;
        }

        if (section == Section.SendingMail)
        {
            currentRect.y     += verticalSeparators;
            currentRect.width  = contentBounds.width;
            currentRect.height = divideHeight;
            currentRect.x      = 0;
            GUI.Label(currentRect, statusString, "DefaultSmallStatusText");
            currentRect.y += divideHeight;

            currentRect.x      = interColumnSeprators;
            currentRect.width  = labelWidth;
            currentRect.height = labelHeight;
            GUI.Label(currentRect, "To: (PlayerID)");
            currentRect.x     += labelWidth + interColumnSeprators;
            currentRect.width  = contentBounds.width - currentRect.x - interColumnSeprators - selectButtonWidth;
            currentRect.height = textBoxHeight;
            playerIdToSendTo   = GUI.TextField(currentRect, playerIdToSendTo, "DefaultTextArea");
            currentRect.x     += contentBounds.width - currentRect.x - interColumnSeprators - selectButtonWidth;
            currentRect.width  = selectButtonWidth;
            if (GUI.Button(currentRect, "?", "DefaultButton"))
            {
                Debug.Log("going");
                System.Action <string> act = (pid) => {
                    playerIdToSendTo = pid;
                };
                GameObject.Find("/PlayerSelectionWidget").SendMessage("setCallbackAndEnable", act);
            }
            currentRect.y     += labelHeight + verticalSeparators;
            currentRect.x      = interColumnSeprators;
            currentRect.width  = labelWidth;
            currentRect.height = labelHeight;
            GUI.Label(currentRect, "Message: ", "DefaultLabel");
            currentRect.x     += labelWidth + interColumnSeprators;
            currentRect.width  = contentBounds.width - currentRect.x - interColumnSeprators;
            currentRect.height = messageBoxHeight;
            messageToSend      = GUI.TextArea(currentRect, messageToSend, "DefaultBigMessageBox");

            currentRect.y     += messageBoxHeight + verticalSeparators;
            currentRect.x      = interColumnSeprators;
            currentRect.width  = buttonWidth;
            currentRect.height = buttonHeight;

            if (GUI.Button(currentRect, "Send", "DefaultButton"))
            {
                if (selectedMailable == null)
                {
                    statusString = "Please select an item to send with your gift";
                }
                else
                {
                    networkActionInProgress = true;
                    gifts.SendGift(playerIdToSendTo, selectedMailable.id, messageToSend, onRoarGiftsGiftSent);
                }
            }

            currentRect.x += buttonWidth + interColumnSeprators;
            if (GUI.Button(currentRect, "Back", "DefaultButton"))
            {
                statusString   = "";
                drawSubheading = false;
                section        = Section.Normal;
            }
            currentRect.x      = interColumnSeprators;
            currentRect.y     += buttonHeight + verticalSeparators;
            internalScrollSize = GUI.BeginScrollView(new Rect(currentRect.x, currentRect.y, contentBounds.width, contentBounds.height - currentRect.y), internalScrollSize,
                                                     new Rect(currentRect.x, currentRect.y, contentBounds.width - interColumnSeprators * 2, sectionHeight * mailableDict.Count));

            foreach (KeyValuePair <string, Roar.DomainObjects.Mailable> f in mailableDict)
            {
                currentRect.width = fromColumnWidth;
                GUI.Label(currentRect, f.Value.label, playerIdFormat);
                currentRect.x    += interColumnSeprators + fromColumnWidth;
                currentRect.width = messageColumnWidth;
                GUI.Label(currentRect, f.Value.type, messageFormat);
                currentRect.x += interColumnSeprators + messageColumnWidth;

                if (GUI.Toggle(currentRect, (selectedMailable == f.Value)?true:false, "Select"))
                {
                    selectedMailable = f.Value;
                }
                currentRect.x = interColumnSeprators;

                currentRect.y += sectionHeight;
            }
            GUI.EndScrollView();
            currentRect.x += interColumnSeprators + typeColumnWidth;
        }
    }
 public Task SendMail(Mailable mailable) => _mailer.SendAsync(mailable);