Exemplo n.º 1
0
 public GuiElement(GuiLayer owningLayer, string elementText)
 {
     GuiElement.lastid++;
     this.id = "GuiElement_" + GuiElement.lastid;
     this.parentLayer = owningLayer;
     owningLayer.AddGUIElement(this);
     this.text = elementText;
 }
Exemplo n.º 2
0
 //we can only show one hint at a time, so there should be like a global or static hint that gets displayed / updated
 public Hint(GuiLayer owningLayer, string elementText)
     : base(owningLayer, elementText)
 {
     //set height to 285 pixels
     //set width to "auto"? or let CSS handle that?
     //add a CSS class
     //jQueryObject thisGuy = jQuery.FromElement(this.GetRenderElement());
     //thisGuy.AddClass("GUIHint");
 }
Exemplo n.º 3
0
        //public static GuiEvent FromClickData(GuiLayer gLayer, jQueryEvent jqClickData)
        public static GuiEvent FromClickData(GuiLayer gLayer, Point clickPos)
        {
            GuiEvent returnEvent = new GuiEvent(Helpah.d2i(clickPos.x), Helpah.d2i(clickPos.y));
            //Dimension TileSize = Stage.CurrentStage.GetTileSize();

            //returnEvent.eventPixelPos = new Point(clickPos.x, clickPos.y);
            //returnEvent.eventPos = new Point(returnEvent.eventPixelPos.x / TileSize.First, returnEvent.eventPixelPos.y / TileSize.Second);
            //Script.Eval("console.log('Pixelpos is " + returnEvent.eventPixelPos.x + ", " + returnEvent.eventPixelPos.y + ". Pos is " + returnEvent.eventPos.x + ", " + returnEvent.eventPos.y + "');");
            //returnEvent.eventAction = "Click";

            returnEvent.clickedElement = gLayer.GetElementAt(returnEvent.eventPos.x, returnEvent.eventPos.y);
            returnEvent.clickedEntities = gLayer.GetEntitiesAt(returnEvent.eventPos.x, returnEvent.eventPos.y);
            returnEvent.clickedTiles = gLayer.GetTilesAt(returnEvent.eventPos.x, returnEvent.eventPos.y);

            return returnEvent;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Add a LabelValue for the reasource to the GUI Layer.
 /// Displays the Icon (Sprite) if there is one for the resource, otherwise displays the name.
 /// </summary>
 /// <param name="resource">Which resource to display.</param>
 /// <param name="position">Where to display it within the layer.</param>
 public void AddResource(Resource resource, Point position)
 {
     GuiLayer splash = new GuiLayer("Splash", View.GetMainView(), new Rectangle(0, 0, 0, 0));
 }
Exemplo n.º 5
0
        private static GuiLayer GetDebugLayer()
        {
            if (DebugLayer == null)
            {
                Debug.DebugLayer = View.GetMainView().AddLayer("DebugLayer", new Rectangle(0, -40, 400, 40));
                Debug.DebugLayer.RenderTarget = Render_Target.Div;
            }

            return Debug.DebugLayer;
        }
Exemplo n.º 6
0
        public static void Init()
        {
            Game.Clock = new DOM_Clock();
            //Game.Clock.Start();

            //I must be script#'ing wrong. This won't fire here.
            InputManager.Input.Init();
            // Set up the local player
            Player LocalPlayer = new Player();
            //Surface.Initialize(new DOM_Renderer());
            //Surface.Initialize(new Canvas_Renderer());
            Game.Renderer = new Canvas_Renderer();
            SoundSystem = new HTML5_Audio();
            //set up the primary view
            // Remember to initialize the renderer first!
            View playerOneView = new View(LightingStyle.Tiles);
            playerOneView.SetArea(new Rectangle(0, 0, Renderer.GetSize().width, Renderer.GetSize().height));

            //notificationLayer = new GuiLayer(playerOneView, new Rectangle(0, 0, 0, 0));
            notificationLayer = playerOneView.AddLayer("NotificationLayer", new Rectangle(0, 0, 0, 0));
            notificationLayer.SetSize(522, 60);
            //notificationLayer.Hide();

            //create two gui elements on the layer:
            //an image on the left
            GuiElement notifIcon = notificationLayer.AddGUIElement("");
            notifIcon.AddStyle("notifIcon");
            notifIcon.SetPosition(12, 0);
            //and sender on the right
            GuiElement notifSender = notificationLayer.AddGUIElement("");
            notifSender.SetPosition(58, 0);
            notifSender.SetSize(474, 12);
            //and the sender's handle, if applicable
            GuiElement notifSenderHandle = notificationLayer.AddGUIElement("");
            notifSenderHandle.SetPosition(80, 0);
            notifSenderHandle.SetSize(474, 12);
            notifSenderHandle.AddStyle("tweetName");
            //and the text on the right
            GuiElement notifText = notificationLayer.AddGUIElement("");
            notifText.SetPosition(58, 18);
            notifText.SetSize(474, 40);
            notificationLayer.Hide();

            //clockRenderguy = Game.Clock.AddRender(Game.Renderer.RenderUpdate);
            //clockRenderguy = Game.Clock.AddRender(Game.Renderer.Render);

            //reposition the notification layer after a few seconds
            string notif_repos = Clock.AddRender(reposition_notification_layeer);
            Clock.delayRender(notif_repos, 2);

            Clock.AddCalculation(StandardCalculations);
            Clock.IntervalExecute(Game.StandardIntervalCalculations, .2);
            Game.Paused = false;
        }
Exemplo n.º 7
0
 public void RenderCollisionMap()
 {
     collisionMap = GuiLayer.AsCollisionMap(this);
 }
Exemplo n.º 8
0
 public void SetNeedsUpdate(GuiLayer layer)
 {
     if (!this.guiElementsToUpdate.Contains(layer.GetId()))
     {
         this.guiElementsToUpdate.Add(layer.GetId());
     }
 }
Exemplo n.º 9
0
        public void RenderGUILayer(GuiLayer glayer)
        {
            HtmlElement layerElem = null;
            if(elementsByGuiId.ContainsKey(glayer.GetId()))
            {
                layerElem = elementsByGuiId[glayer.GetId()].As<HtmlElement>();
            }

            //if it's not rendered, render it
            if (layerElem == null)
            {
                layerElem = document.createElement("div").As<HtmlElement>();
                layerElem.id = glayer.GetName();
                this.AddClass(layerElem, "GUILayer");
                document.getElementById("gameWrapper").appendChild(layerElem);
                //this.elementsByGuiId[gelm.GetParentLayer().GetName()].appendChild(gentlement);

                elementsByGuiId[glayer.GetId()] = layerElem;
            }

            if (guiElementsToUpdate.Contains(glayer.GetId()))
            {
                guiElementsToUpdate.Remove(glayer.GetId());
            }

            if (glayer.Visible())
            {
                layerElem.style.display = "inline";
            }
            else
            {
                layerElem.style.display = "none";
            }

            if (glayer.FollowingCursor() == true)
            {
                //set the position to the cursor position
                glayer.SetPosition(
                    InputManager.InputDevice.Mouse.GetAxisPosition(0) - (glayer.GetSize().width / 2),
                    InputManager.InputDevice.Mouse.GetAxisPosition(1) - (glayer.GetSize().height / 2));
                layerElem.style.position = "absolute";
            }

            //reposition the element based on game position
            if (glayer.GetPosition().x >= 0)
            {
                layerElem.style.left = glayer.GetPosition().x + "px";
            }
            else
            {
                layerElem.style.right = JsMath.abs(glayer.GetPosition().x) + "px";
            }
            if (glayer.GetPosition().y >= 0)
            {
                layerElem.style.top = glayer.GetPosition().y + "px";
            }
            else
            {
                layerElem.style.bottom = JsMath.abs(glayer.GetPosition().y) + "px";
            }
            layerElem.style.width = glayer.GetSize().width + "px";
            layerElem.style.height = glayer.GetSize().height + "px";
        }
Exemplo n.º 10
0
 public void DestroyGUILayer(GuiLayer glayer)
 {
     Element layerElem = elementsByGuiId[glayer.GetId()].As<HtmlElement>();
     if (layerElem != null)
     {
         try
         {
             layerElem.parentElement.removeChild(layerElem);
             elementsByGuiId.Remove(glayer.GetId());
         }
         catch (Exception ex)
         {
             Debug.log("Failed to destroy " + glayer.GetId() + " ( " + glayer.GetName() + " ) :");
             Debug.log(ex.Message);
         }
     }
 }
Exemplo n.º 11
0
 public void RemoveLayer(GuiLayer layer)
 {
     if (this.guiLayers.Contains(layer))
     {
         this.guiLayers.Remove(layer);
     }
 }
Exemplo n.º 12
0
 public void AddLayer(GuiLayer layer)
 {
     if (!guiLayers.Contains(layer))
     {
         this.guiLayers.Add(layer);
     }
 }
Exemplo n.º 13
0
        public GuiLayer AddLayer(string layerName, Rectangle layerPos)
        {
            //create a new element with this as the parent, and the given text as its caption
            GuiLayer newLayer = new GuiLayer(layerName, this, layerPos);
            //add the element to the list of elements in this layer

            //make the view the active view?

            return newLayer;
        }