Ejemplo n.º 1
0
        public override void InitTexture(ref World world, ref Body body, prim.Point point, ref prim.Size size, ref ImageTexture texture, ref MapInterface.ObjectTemplate temp, Graphics graphics, bool isDynamic = false)
        {
            Bitmap bitmap = temp.images["default"][0].image;

            SetPoints(graphics, bitmap, ref texture, point, ref size);
            BodyDef    bodyDef = new BodyDef();
            PolygonDef polyBox = new PolygonDef();
            PolygonDef polyDef = new PolygonDef();

            bodyDef.Position.Set(point.x, point.y);
            polyDef.Density     = 1f;
            polyBox.Density     = 1f;
            bodyDef.Angle       = 0f;
            polyDef.VertexCount = temp.images["default"][0].collisionVectors.Count;
            polyBox.SetAsBox(size.w / 2, size.h / 2);
            List <prim.Point> points = new List <prim.Point>();

            foreach (MapInterface.Line line in temp.images["default"][0].collisionVectors)
            {
                float nx1 = ((float)line.x1 / bitmap.Width) * (float)size.w;
                float nx2 = ((float)line.x2 / bitmap.Width) * (float)size.w;
                float ny1 = ((float)line.y1 / bitmap.Height) * (float)size.h;
                float ny2 = ((float)line.y2 / bitmap.Height) * (float)size.h;
                points.Add(new prim.Point(nx1, ny1));
                points.Add(new prim.Point(nx2, ny2));
            }

            AddCollisionPoints(ref world, ref temp, bodyDef, polyDef, points, ref body);

            if (isDynamic)
            {
                body.SetMassFromShapes();
            }
        }
Ejemplo n.º 2
0
 public MapEditor(gfx.Graphics graphics)
 {
     this.prevCursorName        = "cursor";
     this.signal                = "";
     this.graphics              = graphics;
     this.path                  = "";
     process                    = new Process();
     initState                  = new prim.InitStateMachine();
     process.StartInfo.FileName = Directory.GetCurrentDirectory()
                                  + "/res/editor/HJCompanion.exe";
     cursors = new Dictionary <string, gfx.Cursor>();
     cursors.Add("locked", new gfx.Cursor(graphics, "locked"));
     cursors.Add("edit", new gfx.Cursor(graphics, "edit"));
     cursors.Add("remove", new gfx.Cursor(graphics, "remove"));
     cursors.Add("move", new gfx.Cursor(graphics, "move"));
     cursors.Add("details", new gfx.Cursor(graphics, "details"));
     cursors.Add("shape", new gfx.Cursor(graphics, "shape"));
     defaultCursor  = new gfx.Cursor(graphics);
     cursor         = defaultCursor;
     mode           = "cursor";
     prevMode       = "";
     map            = new gfx.GameMap(graphics);
     scroll         = new prim.Point(0, 0);
     scrollVelocity = 0.025f;
 }
Ejemplo n.º 3
0
        public Label(gfx.Graphics graphics, string text, int fontSize, string fontType,
                     Color fontColor, prim.Point point, prim.Size size)
            : base(graphics, "label", text, point, size)
        {
            SizeF  textSize   = new SizeF();
            Bitmap somebitmap = new Bitmap(32, 32);
            Font   font       = new Font(graphics.fonts[fontType].Families[0], fontSize, FontStyle.Regular);

            if (text == "")
            {
                text = " ";
            }

            using (Graphics g = Graphics.FromImage(somebitmap))
            {
                textSize = g.MeasureString(text, font);
            }

            Bitmap bitmap = new Bitmap((int)textSize.Width, (int)textSize.Height);

            GraphicsPath fontText = new GraphicsPath();

            bitmap.MakeTransparent();
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                //textSize = g.MeasureString(text, font);
                using (Brush brush = new SolidBrush(fontColor))
                {
                    g.SmoothingMode      = SmoothingMode.HighQuality;
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                    g.DrawString(text, font, brush, new PointF(0, 0));
                }
            }

            //bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);

            size.w = bitmap.Width / (float)graphics.size.w;
            size.h = bitmap.Height / (float)graphics.size.h;

            point.x = point.cx ? getCenter(size.w) : point.x;
            point.y = point.cy ? getCenter(size.h) : point.y;

            float[] vertices =
            {
                point.x + size.w, point.y + size.h, 0.0f, 1.0f, 1.0f, // top right
                point.x + size.w, point.y,          0.0f, 1.0f, 0.0f, // bottom right
                point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
                point.x,          point.y + size.h, 0.0f, 0.0f, 1.0f  // top left
            };

            uint[] indices = // note that we start from 0!
            {
                0, 1, 3,     // first triangle
                1, 2, 3      // second triangle
            };

            labelTexture = new gfx.ImageTexture(graphics, bitmap, vertices, indices);
        }
Ejemplo n.º 4
0
        public ArrowButton(gfx.Graphics graphics, string dir, Color bgColor, prim.Point point, prim.Size size)
            : base(graphics, "arrow button", "", point, size)
        {
            mouseOverState = new prim.MouseOverStateMachine();
            activated      = false;

            float[] lVertices =
            {
                point.x + size.w, point.y + size.h,          0.0f, 1.0f, 1.0f,
                point.x + size.w, point.y,                   0.0f, 1.0f, 0.0f,
                point.x,          point.y + (size.h / 2.0f), 0.0f, 0.0f, 0.5f
            };

            float[] rVertices =
            {
                point.x,          point.y,                   0.0f, 1.0f, 1.0f,
                point.x,          point.y + size.h,          0.0f, 1.0f, 0.0f,
                point.x + size.w, point.y + (size.h / 2.0f), 0.0f, 0.0f, 0.5f
            };

            uint[] indices =
            {
                0, 1, 2
            };

            if (dir == "right")
            {
                texture = new gfx.ColorTexture(graphics, bgColor, rVertices, indices);
            }
            else
            {
                texture = new gfx.ColorTexture(graphics, bgColor, lVertices, indices);
            }
        }
Ejemplo n.º 5
0
        //private gfx.Texture labelTexture;
        //private gfx.Texture boxTexture;

        public ToggleBox(gfx.Graphics graphics, string bind, string value,
                         Color checkBoxColor, Color borderColor,
                         prim.Size borderSize, string text, int fontSize, string fontType, Color fontColor,
                         prim.Point point, prim.Size size)
            : base(graphics, "label", text, point, size)
        {
            this.bind  = bind;
            this.value = value;

            isChecked = this.value == "true" ? true : false;
            label     = new Label(graphics, text, fontSize, fontType, fontColor, point, new prim.Size(size.w, size.h));

            size.h = label.size.h;
            size.w = graphics.getWSquareSize(label.size.h);

            pane = new Pane(graphics, checkBoxColor, borderColor, borderSize, new prim.Point(point.x, point.y), new prim.Size(size.w, size.h));

            prim.Size  sPaneSize = pane.size.Scale(0.8f);
            prim.Point sPanePnt  = pane.point.GetTransPnt(sPaneSize.w * 0.1f, sPaneSize.h * 0.1f);
            selectedPane = new Pane(graphics, borderColor, borderColor, borderSize, sPanePnt, sPaneSize);

            label.point.x += pane.size.w;
            this.Update();
            //pane = new Pane(graphics, checkBoxColor, borderColor, borderSize, new prim.Point(point.x, point.y), new prim.Size(size.w, size.h));
        }
Ejemplo n.º 6
0
        public Graphics(prim.Size size, util.Config config)
        {
            quit            = false;
            reload          = false;
            fps             = 0;
            t_fps           = 60;
            actionKeyBuffer = new List <uint>();
            this.config     = config;
            configValues    = config.GetSettingCopy();
            leftClick       = new prim.ClickStateMachine();
            rightClick      = new prim.ClickStateMachine();
            middleClick     = new prim.ClickStateMachine();
            mousePoint      = new prim.Point(0, 0);
            shaders         = new ShaderFactory();

            this.size = size;
            fonts     = new Dictionary <string, PrivateFontCollection>();

            foreach (string fname in Directory.GetFiles("res/fonts"))
            {
                PrivateFontCollection curFonts = new PrivateFontCollection();
                curFonts.AddFontFile(fname);
                fonts.Add(Path.GetFileNameWithoutExtension(fname), curFonts);
            }
        }
Ejemplo n.º 7
0
 public void UpdateMousePoint(int x, int y, bool leftClick, bool middleClick, bool rightClick)
 {
     mousePoint = getNormalPoint(new prim.Point(x, y));
     HandleClickState(this.leftClick, leftClick);
     HandleClickState(this.middleClick, middleClick);
     HandleClickState(this.rightClick, rightClick);
 }
Ejemplo n.º 8
0
        protected void SetProjections(prim.Point s)
        {
            //Matrix4 model = Matrix4.Identity;
            Matrix4 proj = Ortho(0f + s.x, 1f + s.x, 1f + s.y, 0f + s.y, 0f, 1f);

            this.shader.SetMatrix4("projection", proj);
        }
Ejemplo n.º 9
0
 public GameMap(Graphics graphics)
 {
     this.graphics = graphics;
     this.scroll   = new prim.Point(0, 0);
     mapInterface  = new MapInterface.MapInterface();
     controlEntity = new ControlEntity();
     run           = true;
 }
Ejemplo n.º 10
0
 public void Scroll(prim.Point scroll)
 {
     foreach (Shader curShader in shaders.shaders.Values)
     {
         Matrix4 proj = Ortho(0f + scroll.x, 1f + scroll.x, 1f + scroll.y, 0f + scroll.y, 0f, 1f);
         curShader.SetMatrix4("projection", proj);
     }
 }
Ejemplo n.º 11
0
 public Button(gfx.Graphics graphics, string text, int fontSize, string fontType, Color fontColor,
               prim.Point point, prim.Size size, string action, string link)
     : base(graphics, "button", text, point, size)
 {
     activated   = false;
     mouseState  = new prim.MouseOverStateMachine();
     label       = new Label(graphics, text, fontSize, fontType, fontColor, point, size);
     this.link   = link;
     this.action = action;
 }
Ejemplo n.º 12
0
        public ValueBox(gfx.Graphics graphics, string bind, string value,
                        Color borderColor, prim.Size borderSize,
                        int fontSize, string fontType, Color fontColor, prim.Point point,
                        prim.Size size)
            : base(graphics, "select", "", point, size)
        {
            this.bind = bind;

            this.value = value;

            LAmouseOverState = new prim.MouseOverStateMachine();
            RAmouseOverState = new prim.MouseOverStateMachine();

            boxes = new List <Pane>();

            float triH = size.h;
            float triW = graphics.getWSquareSize(triH);

            float[] lVertices =
            {
                point.x + triW, point.y + triH,          0.0f, 1.0f, 1.0f,
                point.x + triW, point.y,                 0.0f, 1.0f, 0.0f,
                point.x,        point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };
            //Remember to add size.x to point.x
            float[] rVertices =
            {
                point.x + size.w,        point.y,                 0.0f, 1.0f, 1.0f,
                point.x + size.w,        point.y + triH,          0.0f, 1.0f, 0.0f,
                point.x + triW + size.w, point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };

            uint[] indices =
            {
                0, 1, 2
            };

            //leftArrow = new gfx.ColorTexture(graphics, borderColor, lVertices, indices);
            //rightArrow = new gfx.ColorTexture(graphics, borderColor, rVertices, indices);
            leftArrow  = new ArrowButton(graphics, "left", fontColor, new prim.Point(point), new prim.Size(triW, triH));
            rightArrow = new ArrowButton(graphics, "right", fontColor, new prim.Point(point.x + size.w, point.y), new prim.Size(triW, triH));

            selectPane = new Pane(graphics, Color.FromArgb(0, 0, 0, 0), borderColor, borderSize, new prim.Point(point.x + triW, point.y), new prim.Size(size.w - triW, size.h));

            for (int i = 0; i < 10; i++)
            {
                prim.Size  paneSize  = new prim.Size((this.size.w + this.leftArrow.size.w) * 0.1f, this.size.h);
                prim.Point panePoint = new prim.Point(leftArrow.size.w + point.x + paneSize.w * i, point.y);
                Pane       curPane   = new Pane(graphics, borderColor, borderColor, borderSize, panePoint, paneSize);
                boxes.Add(curPane);
            }
        }
Ejemplo n.º 13
0
        public void AddNode2(prim.Point pointA, prim.Point pointB)
        {
            float curArea = (pointB.x - pointA.x) * (pointB.y - pointA.y);

            if (curArea > minArea)
            {
                //upperLeft =
            }
            //prim.Point ulPoint = pointA;
            //prim.Point urPoint = new prim.Point(pointB.x / 2, pointA.y);
            //prim.Point llPoint = new prim.Point(pointA.x, pointB.y / 2);
            //prim.Point lrPoint = new prim.Point(pointB.x / 2, point.y / 2);
        }
Ejemplo n.º 14
0
        public StarField(gfx.Graphics graphics)
            : base(graphics, "starfield", new float[] { }, new uint[] { })
        {
            vertexState    = new prim.VertexStateMachine();
            this.counter   = 0;
            this.texHandle = GL.GenTexture();
            prim.Size  size = new prim.Size(graphics.getWSquareSize(0.05f), 0.05f);
            prim.Point pnt  = new prim.Point(0.0f, 0.0f - size.h);

            LoadStarfield();

            ToVAO();
        }
Ejemplo n.º 15
0
 public ObjectEntity(World world, MapInterface.ObjectTemplate temp, Graphics graphics, prim.Point point, bool isDynamic = false) : base()
 {
     this.point       = point;
     this.x           = point.x;
     this.y           = point.y;
     this.dx          = 0f;
     this.dy          = 0f;
     this.colEntities = new List <CollisionEntity>();
     this.instance    = temp;
     objectStrategy   = new ObjectStrategy();
     objectStrategy.InitTexture(ref world, ref body, this.point, ref this.size, ref texture, ref this.instance, graphics, isDynamic);
     //this.InitTexture(world, temp, graphics, isDynamic);
 }
Ejemplo n.º 16
0
 public TextField(gfx.Graphics graphics, string text,
                  int fontSize, string fontType, Color fontColor, prim.Point point)
     : base(graphics, "text field", "", point, new prim.Size())
 {
     this.text      = text;
     this.fontColor = fontColor;
     this.fontSize  = fontSize;
     this.fontType  = fontType;
     UpdateText();
     prim.Size cSize = new prim.Size(textLines[0].size);
     cSize.w = graphics.getWSquareSize(cSize.h) / 8;
     prim.Point cPoint = new prim.Point(point.x + textLines[0].size.w, textLines[0].point.y);
     this.cursorPane = new Pane(graphics, fontColor, Color.Transparent,
                                new prim.Size(), cPoint, cSize);
 }
Ejemplo n.º 17
0
        public Component(gfx.Graphics graphics, string type, string text, prim.Point point, prim.Size size)
        {
            this.graphics = graphics;

            this.type = type;
            this.text = text;

            this.bind  = "";
            this.value = "";

            this.signal = "";

            this.point         = point;
            this.size          = size;
            this.subComponents = new List <Component>();
        }
Ejemplo n.º 18
0
        public virtual void InitTexture(ref World world, ref Body body, prim.Point point, ref prim.Size size, ref ImageTexture texture, ref MapInterface.ObjectTemplate temp, Graphics graphics, bool isDynamic = false)
        {
            Bitmap bitmap = temp.images["default"][0].image;

            SetPoints(graphics, bitmap, ref texture, point, ref size);

            BodyDef    bodyDef = new BodyDef();
            PolygonDef polyBox = new PolygonDef();
            PolygonDef polyDef = new PolygonDef();

            bodyDef.Position.Set(point.x, point.y);
            polyDef.Density     = 1f;
            polyBox.Density     = 1f;
            bodyDef.Angle       = 0f;
            polyDef.VertexCount = temp.images["default"][0].collisionVectors.Count;
            polyBox.SetAsBox(size.w / 2, size.h / 2);
            List <prim.Point> points = new List <prim.Point>();

            foreach (MapInterface.Line line in temp.images["default"][0].collisionVectors)
            {
                float nx1 = ((float)line.x1 / bitmap.Width) * (float)size.w;
                float nx2 = ((float)line.x2 / bitmap.Width) * (float)size.w;
                float ny1 = ((float)line.y1 / bitmap.Height) * (float)size.h;
                float ny2 = ((float)line.y2 / bitmap.Height) * (float)size.h;
                points.Add(new prim.Point(nx1, ny1));
                points.Add(new prim.Point(nx2, ny2));
            }
            //TODO: Sort vertices in CCW order
            //Example. Top triangle point -> bottom right -> bottem left
            //points = GetDistinctPoints(points);
            //foreach (prim.Point curPoint in points)
            //{
            //    vCnt += 1;
            //    polyDef.Vertices[vCnt].Set(curPoint.x, curPoint.y);
            //}

            //bodyDef.FixedRotation = true;
            //body = world.CreateBody(bodyDef);
            //body.CreateShape(polyDef);

            AddCollisionPoints(ref world, ref temp, bodyDef, polyDef, points, ref body);

            if (isDynamic)
            {
                body.SetMassFromShapes();
            }
        }
Ejemplo n.º 19
0
        public List <gfx.ObjectEntity> getCursorAdjInstances()
        {
            prim.Point absMouse             = AbsMouse();
            List <gfx.ObjectEntity> results = new List <gfx.ObjectEntity>();

            foreach (gfx.ObjectEntity inst in this.map.mapInterface.objectInstances)
            {
                if (absMouse.x >= inst.point.x && absMouse.x <= inst.point.x + inst.size.w)
                {
                    if (absMouse.y >= inst.point.y && absMouse.y <= inst.point.y + inst.size.h)
                    {
                        results.Add(inst);
                    }
                }
            }
            return(results);
        }
Ejemplo n.º 20
0
        public override void Update(prim.Point point)
        {
            float[] newVertices =
            {
                point.x + size.w, point.y + size.h, 0.0f, 1.0f, 1.0f, // top right
                point.x + size.w, point.y,          0.0f, 1.0f, 0.0f, // bottom right
                point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
                point.x,          point.y + size.h, 0.0f, 0.0f, 1.0f  // top left
            };

            uint[] newIndices = // note that we start from 0!
            {
                0, 1, 3,        // first triangle
                1, 2, 3         // second triangle
            };

            this.vertices = newVertices;
            this.indices  = newIndices;
        }
Ejemplo n.º 21
0
        public void LoadMap(Graphics graphics, string path = "")
        {
            worldAABB = new AABB();
            worldAABB.LowerBound.Set(-5f, -5f);
            worldAABB.UpperBound.Set(5f, 5f);
            if (path == "")
            {
                mapInterface.Load();
            }
            else
            {
                mapInterface = new MapInterface.MapInterface(path);
            }
            //Offload Interface
            float gravityValue = mapInterface.objectTemplates["Global"].properties["Gravity"].getFloat();
            Vec2  gravity      = new Vec2();

            gravity.Set(0f, gravityValue);
            world = new World(worldAABB, gravity, false);
            world.SetContactListener(this);

            List <MapInterface.ObjectInstance> tempInstance = new List <MapInterface.ObjectInstance>(mapInterface.objectInstances);

            mapInterface.objectInstances.Clear();
            //Convert to entities
            foreach (MapInterface.ObjectInstance curInstance in tempInstance)
            {
                prim.Point pnt = new prim.Point(curInstance.x, curInstance.y);
                mapInterface.objectInstances.Add(new ObjectEntity(world, curInstance.instance, graphics, pnt));
            }
            //List<MapInterface.ObjectWall> tempWalls = new List<MapInterface.ObjectWall>(mapInterface.objectWalls);
            mapInterface.objectWalls.Clear();
            ////Convert to wall entities
            //foreach (MapInterface.ObjectWall curInstance in tempInstance)
            //{
            //    prim.Point pnt = new prim.Point(curInstance.x, curInstance.y);
            //    prim.Size size = new prim.Size(curInstance.w, curInstance.y);
            //    mapInterface.objectWalls.Add(new WallEntity(world, curInstance.instance, graphics, pnt, size));
            //}
        }
Ejemplo n.º 22
0
        public void NewTexture(Bitmap cursorBmp)
        {
            size = new prim.Size(cursorBmp.Width / (float)graphics.size.w,
                                 cursorBmp.Height / (float)graphics.size.h);
            point = graphics.mousePoint;

            float[] vertices =
            {
                point.x + size.w, point.y + size.h, 0.0f, 1.0f, 1.0f, // top right
                point.x + size.w, point.y,          0.0f, 1.0f, 0.0f, // bottom right
                point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
                point.x,          point.y + size.h, 0.0f, 0.0f, 1.0f  // top left
            };

            uint[] indices = // note that we start from 0!
            {
                0, 1, 3,     // first triangle
                1, 2, 3      // second triangle
            };

            cursorTexture = new gfx.ImageTexture(graphics, cursorBmp, vertices, indices);
        }
Ejemplo n.º 23
0
 public override void Update(prim.Point point, prim.Size newSize, bool repeat = true)
 {
     this.size = newSize;
     if (repeat)
     {
         float nx = size.w / bitmapSize.w;
         float ny = size.h / bitmapSize.h;
         Console.WriteLine(nx.ToString() + " , " + ny.ToString());
         float[] newVertices =
         {
             point.x + size.w, point.y + size.h, 0.0f, nx, ny,     // top right
             point.x + size.w, point.y,          0.0f, nx, 0.0f,   // bottom right
             point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
             point.x,          point.y + size.h, 0.0f, 0.0f, ny    // top left
         };
         this.vertices = newVertices;
         this.size     = new prim.Size(size.w / (float)graphics.size.w,
                                       size.h / (float)graphics.size.h);
     }
     else
     {
         Update(point);
     }
 }
Ejemplo n.º 24
0
 public void Update()
 {
     Pan();
     if (initState.currentState == "init")
     {
         Launch();
         initState.TransitionState("non init");
     }
     else
     {
         ipc.PollMessage();
         if (ipc.signal != "")
         {
             try
             {
                 string[] allParams = ipc.signal.Split(',');
                 if (allParams[0] == "exit")
                 {
                     this.signal = "exit";
                     ipc.Stop();
                 }
                 if (allParams[0] == "remove instance")
                 {
                     cursor = cursors["remove"];
                     mode   = "remove";
                 }
                 if (allParams[0] == "shape instance")
                 {
                     cursor = cursors["shape"];
                     string objKey = allParams[1];
                     curObj = map.mapInterface.objectTemplates[objKey];
                     Bitmap curTexture = map.mapInterface.objectTemplates[objKey].images["default"][0].image;
                     shapeTexture = new gfx.ImageTexture(this.graphics, curTexture);
                     mode         = "shape";
                 }
                 if (allParams[0] == "move instance")
                 {
                     cursor = cursors["move"];
                     mode   = "move";
                 }
                 if (allParams[0] == "instance details")
                 {
                     cursor = cursors["details"];
                     mode   = "details";
                 }
                 if (allParams[0] == "lock")
                 {
                     prevMode       = mode;
                     prevCursorName = cursor.name;
                     cursor         = cursors["locked"];
                     mode           = "locked";
                 }
                 if (allParams[0] == "unlock")
                 {
                     cursor = cursors[prevCursorName];
                     mode   = prevMode;
                 }
                 if (allParams[0] == "load map")
                 {
                     //TODO: Load Map
                     this.path = Directory.GetCurrentDirectory() + "/res/maps/" + allParams[1];
                     map.LoadMap(this.graphics, this.path);
                     Console.WriteLine("LOAD MAP");
                 }
                 if (allParams[0] == "save instances")
                 {
                     SaveInstances();
                 }
                 if (allParams[0] == "remove all instances")
                 {
                     LockClient();
                     map.mapInterface.objectInstances = new List <MapInterface.ObjectInstance>();
                     map.mapInterface.Save();
                     UnlockClient();
                     //Client must have the latest
                     ipc.SendMessage("reload map");
                 }
                 if (allParams[0] == "reload map")
                 {
                     Console.WriteLine("RELOAD MAP");
                 }
                 if (allParams[0] == "load instances")
                 {
                     //ipc.SendMessage("lock");
                     map.LoadMap(this.graphics);
                     //ipc.SendMessage("unlock");
                     //ipc.SendMessage("reload map");
                 }
                 if (allParams[0] == "save instances async")
                 {
                     map.mapInterface.Save();
                 }
                 if (allParams[0] == "place")
                 {
                     SaveInstances();
                     map.LoadMap(this.graphics);
                     string objKey = allParams[1];
                     curObj = map.mapInterface.objectTemplates[objKey];
                     Bitmap newImage = curObj.images["default"][0].image;
                     cursors["edit"].ChangeTexture(newImage);
                     cursor    = cursors["edit"];
                     this.mode = "place";
                 }
                 if (allParams[0] == "cursor")
                 {
                     cursor    = defaultCursor;
                     this.mode = "cursor";
                 }
             }
             catch (Exception ie)
             {
                 this.signal = "exit";
                 ipc.Stop();
             }
         }
         if (graphics.leftClick.currentState == "clicked")
         {
             if (this.mode == "place")
             {
                 prim.Point       pnt         = AbsMouse();
                 gfx.ObjectEntity objInstance = new gfx.ObjectEntity(map.world, curObj, graphics, AbsMouse());
                 map.mapInterface.objectInstances.Add(objInstance);
                 SaveInstances();
             }
             else if (this.mode == "remove")
             {
                 List <gfx.ObjectEntity> insts = getCursorAdjInstances();
                 if (insts.Count > 0)
                 {
                     map.mapInterface.objectInstances.Remove(insts[0]);
                 }
                 SaveInstances();
             }
             else if (this.mode == "move progress")
             {
                 this.mode = "move";
                 SaveInstances();
             }
             else if (this.mode == "shape progress")
             {
                 this.mode = "shape";
                 prim.Size      wallSize    = new prim.Size(shapeTexture.size);
                 prim.Point     wallPoint   = new prim.Point(startShapePoint);
                 gfx.WallEntity objInstance = new gfx.WallEntity(map.world, curObj, graphics, wallPoint, wallSize);
                 map.mapInterface.objectWalls.Add(objInstance);
                 shapeTexture = null;
             }
             else if (this.mode == "details")
             {
                 List <gfx.ObjectEntity> insts = getCursorAdjInstances();
                 if (insts.Count > 0)
                 {
                     SaveInstances();
                     int index = map.mapInterface.objectInstances.IndexOf(insts[0]);
                     ipc.SendMessage("launch details," + index.ToString());
                 }
             }
         }
         if (graphics.leftClick.currentState == "mouse down")
         {
             if (this.mode == "move")
             {
                 List <gfx.ObjectEntity> insts = getCursorAdjInstances();
                 if (insts.Count > 0)
                 {
                     heldObject = insts[0];
                     this.mode  = "move progress";
                 }
             }
             if (this.mode == "shape")
             {
                 this.mode       = "shape progress";
                 startShapePoint = new prim.Point(graphics.mousePoint);
             }
             if (this.mode == "shape progress")
             {
                 prim.Size newSize = new prim.Size(Math.Abs(startShapePoint.x - this.graphics.mousePoint.x),
                                                   Math.Abs(startShapePoint.y - this.graphics.mousePoint.y));
                 shapeTexture.Update(startShapePoint, newSize);
             }
             if (this.mode == "move progress")
             {
                 heldObject.UpdatePoint(AbsMouse());
                 heldObject.Update();
                 map.mapInterface.Save();
             }
         }
     }
     cursor.Update(AbsMouse());
 }
Ejemplo n.º 25
0
 public void UpdatePoint(prim.Point pnt)
 {
     body.SetXForm(new Vec2(pnt.x, pnt.y), 0f);
 }
Ejemplo n.º 26
0
        protected void SetPoints(Graphics graphics, Bitmap bitmap, ref ImageTexture texture, prim.Point point, ref prim.Size size)
        {
            if (size == null)
            {
                size = new prim.Size(bitmap.Width / graphics.size.w, bitmap.Height / graphics.size.h);
            }
            float[] vertices =
            {
                point.x + size.w, point.y + size.h, 0.0f, 1.0f, 1.0f, // top right
                point.x + size.w, point.y,          0.0f, 1.0f, 0.0f, // bottom right
                point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
                point.x,          point.y + size.h, 0.0f, 0.0f, 1.0f  // top left
            };

            uint[] indices = // note that we start from 0!
            {
                0, 1, 3,     // first triangle
                1, 2, 3      // second triangle
            };

            texture = new ImageTexture(graphics, bitmap, vertices, indices);
        }
Ejemplo n.º 27
0
 public void Update(prim.Point point)
 {
     cursorTexture.Update(point);
 }
Ejemplo n.º 28
0
 public QuadTree(prim.Point newPointA, prim.Point newPointB)
 {
     this.pointA = newPointA;
     this.pointB = newPointB;
 }
Ejemplo n.º 29
0
        public Select(gfx.Graphics graphics, string bind, string value,
                      Color borderColor, prim.Size borderSize,
                      int fontSize, string fontType, Color fontColor, prim.Point point,
                      prim.Size size, XmlNodeList choiceNodes)
            : base(graphics, "select", "", point, size)
        {
            this.bind = bind;

            choices      = new List <Choice>();
            choiceLabels = new List <Label>();

            selectIndex = 0;

            LAmouseOverState = new prim.MouseOverStateMachine();
            RAmouseOverState = new prim.MouseOverStateMachine();


            float triH = size.h;
            float triW = graphics.getWSquareSize(triH);

            float[] lVertices =
            {
                point.x + triW, point.y + triH,          0.0f, 1.0f, 1.0f,
                point.x + triW, point.y,                 0.0f, 1.0f, 0.0f,
                point.x,        point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };
            //Remember to add size.x to point.x
            float[] rVertices =
            {
                point.x + size.w,        point.y,                 0.0f, 1.0f, 1.0f,
                point.x + size.w,        point.y + triH,          0.0f, 1.0f, 0.0f,
                point.x + triW + size.w, point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };

            uint[] indices =
            {
                0, 1, 2
            };

            //leftArrow = new gfx.ColorTexture(graphics, borderColor, lVertices, indices);
            //rightArrow = new gfx.ColorTexture(graphics, borderColor, rVertices, indices);
            leftArrow  = new ArrowButton(graphics, "left", fontColor, new prim.Point(point), new prim.Size(triW, triH));
            rightArrow = new ArrowButton(graphics, "right", fontColor, new prim.Point(point.x + size.w, point.y), new prim.Size(triW, triH));



            foreach (XmlNode choiceNode in choiceNodes)
            {
                Choice choice = new Choice(choiceNode.Attributes["text"].Value,
                                           choiceNode.Attributes["value"].Value);
                choices.Add(choice);
                Label choiceLabel = new Label(graphics, choice.name, fontSize, fontType, fontColor, new prim.Point(point), new prim.Size(0, 0));
                choiceLabel.point.x = triW + (point.x + ((size.w - triW) / 2)) - (choiceLabel.size.w / 2);
                choiceLabel.point.y = (point.y + (size.h / 2)) - (choiceLabel.size.h / 2);
                choiceLabel.Update();
                choiceLabels.Add(choiceLabel);
            }

            SetValue(value);

            selectPane = new Pane(graphics, Color.FromArgb(0, 0, 0, 0), borderColor, borderSize, new prim.Point(point.x + triW, point.y), new prim.Size(size.w - triW, size.h));
        }
Ejemplo n.º 30
0
        public Pane(gfx.Graphics graphics, Color paneColor, Color borderColor, prim.Size borderSize, prim.Point point, prim.Size size)
            : base(graphics, "pane", "", point, size)
        {
            float[] vertices =
            {
                point.x + size.w, point.y + size.h, 0.0f, 1.0f, 1.0f, // top right
                point.x + size.w, point.y,          0.0f, 1.0f, 0.0f, // bottom right
                point.x,          point.y,          0.0f, 0.0f, 0.0f, // bottom left
                point.x,          point.y + size.h, 0.0f, 0.0f, 1.0f  // top left
            };
            uint[] indices =                                          // note that we start from 0!
            {
                0, 1, 3,                                              // first triangle
                1, 2, 3                                               // second triangle
            };
            Vector2 borderVec = graphics.normalizeSize(borderSize, this.size);

            paneTexture = new gfx.ColorTexture(graphics, paneColor, borderColor, borderVec, vertices, indices);
        }