AddArea() public method

public AddArea ( UIArea uiArea ) : void
uiArea UIArea
return void
Ejemplo n.º 1
0
        public TileChunkArea(UIManager.UIManager uiManager)
        {
            var tileChunkArea = uiManager.UIManagerAreas.TileChunkArea = new UIArea<TileChunk>(null, 700, 500, 390, 390) {Closable = true};
            tileChunkArea.Visible = false;

            uiManager.AddArea(tileChunkArea);
            tileChunkArea.AddControl(new TextArea(30, 25, "Tile Chunks") {Color = "blue"});

            tileChunkArea.AddControl(chunkPieceList = new ScrollBox(30, 70, 96 - 16, 3, 64) {BackColor = "rgb(50,60,127)"});

            TileChunk[] tileChunks = SonicManager.Instance.SonicLevel.TileChunks.Array();
            for (int index = 0; index < tileChunks.Length; index++) {
                var tileChunk = tileChunks[index];
                ImageButton<TileChunk> chunkButton = new ImageButton<TileChunk>(tileChunk, 0, 0, 0, 0);
                chunkButton.OnDraw = (cnv, x, y) => {
//                                         chunkButton.Data.DrawUI(cnv, new Point(x, y), new DoublePoint(0.5d, 0.5d), 0);
//                                         chunkButton.Data.DrawUI(cnv, new Point(x, y), new DoublePoint(0.5d, 0.5d), 1);
                                     };
                chunkButton.Font = UIManager.UIManager.SmallTextFont;
                chunkButton.Text = "Chunk #" + index;
                chunkButton.Click = (e) => { tileChunkArea.Data = tileChunk; };
                chunkPieceList.AddControl(chunkButton);
            }

            Image image = new Image(125, 70, 256, 256);
            int areaDrawScale = 2;
            image.OnDraw += (context, x, y) => {
                                if (tileChunkArea.Data == null) return;
//                                tileChunkArea.Data.DrawUI(context, new Point(x, y), new Point(areaDrawScale, areaDrawScale), 0);
//                                tileChunkArea.Data.DrawUI(context, new Point(x, y), new Point(areaDrawScale, areaDrawScale), 1);
                            };
            image.Click += (e) => {
                               if (tileChunkArea.Data == null) return;
//                               var tilePiece = tileChunkArea.Data.GetBlockAt(e.X / areaDrawScale, e.Y / areaDrawScale);

//                               uiManager.UIManagerAreas.TilePieceArea.Visible = false;
//                               uiManager.UIManagerAreas.TilePieceArea.Data = tilePiece;
//                               tilePieceList.ScrollIndex = Math.Max(uiManager.sonicManager.SonicLevel.TilePieces.IndexOf(tilePiece) - 1, 0);
                           };
            tileChunkArea.AddControl(image);

            buildTilePiece(uiManager);

            /*
                        var table=tileChunkArea.AddControl(new Table(10, 40, 350, 280));
                        var row = table.AddRow(new TableRow(50.Percent()));
                        var cell = row.AddCell(new TableCell(50.Percent(), 50.Percent()));
                        cell.AddControl(new Button(0, 0, 0, 0, "Text"));
                        cell = row.AddCell(new TableCell(50.Percent(), 50.Percent()));
                        cell.AddControl(new Button(0, 0, 0, 0, "Text1")); 



                        row = table.AddRow(new TableRow(100));
                        cell = row.AddCell(new TableCell(100, 100));
                        cell.AddControl(new Button(0, 0, 100, 100, "Text"));
                        cell = row.AddCell(new TableCell(100, 100){FullSize=false});
                        cell.AddControl(new Button(0, 0, 100, 50, "Text1"));
                        cell.AddControl(new Button(0, 50, 100, 50, "Text2"));*/
        }
Ejemplo n.º 2
0
        public ColorEditorArea(UIManager.UIManager uiManager)
        {
            var colorEditorArea = uiManager.UIManagerAreas.ColorEditorArea = new UIArea<ColorEditorAreaData>(new ColorEditorAreaData(), 650, 30, 960, 800) {Closable = true};

            colorEditorArea.Visible = false;
            uiManager.AddArea(colorEditorArea);

            colorEditorArea.Data.ColorEditor = new ColorEditingArea(30, 45, 680, 680) {ShowOffset = false};

            colorEditorArea.AddControl(colorEditorArea.Data.ColorEditor);
            colorEditorArea.AddControl(new Button(770, 70, 150, 22, "Show Outline") {
                                                                                            Color = "rgb(50,150,50)",
                                                                                            Click = (p) => { colorEditorArea.Data.ColorEditor.Editor.ShowOutline = !colorEditorArea.Data.ColorEditor.Editor.ShowOutline; }
                                                                                    });

            Button bt = null;
            colorEditorArea.AddControl(bt = new Button(770, 190, 150, 22, "Modify Hurt Map") {
                                                                                                     Color = "rgb(50,150,50)",
                                                                                                     Click = (p) => {
                                                                                                                 if (colorEditorArea.Data.ColorEditor.ShowHurtMap == false && colorEditorArea.Data.ColorEditor.ShowCollideMap == false) {
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowHurtMap = true;
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowCollideMap = false;
                                                                                                                     bt.Text = "Modify Collide Map";
                                                                                                                 } else if (colorEditorArea.Data.ColorEditor.ShowCollideMap == false) {
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowHurtMap = false;
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowCollideMap = true;
                                                                                                                     bt.Text = "Modify Pixel Map";
                                                                                                                 } else {
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowHurtMap = false;
                                                                                                                     colorEditorArea.Data.ColorEditor.ShowCollideMap = false;
                                                                                                                     bt.Text = "Modify Hurt Map";
                                                                                                                 }
                                                                                                             }
                                                                                             });

            colorEditorArea.AddControl(new TextArea(750, 150, ( (Func<string>) ( () => { return "Line Width:" + colorEditorArea.Data.ColorEditor.Editor.LineWidth; } ) )) {Color = "Black"});

            colorEditorArea.AddControl(new Button(900, 120, 14, 20, "^") {
                                                                                 Color = "rgb(50,150,50)",
                                                                                 Click = (p) => { colorEditorArea.Data.ColorEditor.Editor.LineWidth = Math.Max(colorEditorArea.Data.ColorEditor.Editor.LineWidth + 1, 1); }
                                                                         });
            colorEditorArea.AddControl(new Button(900, 145, 14, 20, "v") {
                                                                                 Color = "rgb(50,150,50)",
                                                                                 Click = (p) => { colorEditorArea.Data.ColorEditor.Editor.LineWidth = Math.Min(colorEditorArea.Data.ColorEditor.Editor.LineWidth - 1, 10); }
                                                                         });
            colorEditorArea.AddControl(colorEditorArea.Data.PaletteArea = new PaletteArea(770, 250) {Scale = new Point(45, 45), ShowCurrent = true});
            colorEditorArea.Data.ColorEditor.PaletteEditor = colorEditorArea.Data.PaletteArea;
            colorEditorArea.Data.Init = (frame) => {
                                            colorEditorArea.Data.ColorEditor.Scale = new Point(700 / frame.Width, 700 / frame.Height);
                                            colorEditorArea.Data.ColorEditor.Init(frame);
                                            colorEditorArea.Data.PaletteArea.Init(frame.Palette, false);
                                        };
        }
Ejemplo n.º 3
0
        public LevelManagerArea(UIManager.UIManager uiManager)
        {

            LevelManager = uiManager.UIManagerAreas.LevelManagerArea = new UIArea(Window.OuterWidth - 440, 100, 390, 390) { Closable = true };
            LevelManager.Visible = true;

            uiManager.AddArea(LevelManager);
            LevelManager.AddControl(new TextArea(30, 25, "Level Manager") { Color = "blue" });

            LevelManager.AddControl(new Button(50, 70, 120, 28, "Live Objects") { Click = (p) => { new LiveObjectsArea(uiManager); } });
            LevelManager.AddControl(new Button(50, 110, 120, 28, "Debug Animations")
            {
                Click = (p) =>
                {

                    SonicManager.Instance.TileChunkDebugDrawOptions.OutlineChunk = !SonicManager.Instance.TileChunkDebugDrawOptions.OutlineChunk;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowPaletteAnimationData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowPaletteAnimationData;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowBaseData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowBaseData;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowTileAnimationData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowTileAnimationData;

                }
            });
        }
Ejemplo n.º 4
0
        public ObjectFrameworkArea(UIManager.UIManager manager)
        {
            var size = 40 * 4;

            objectFrameworkArea = new UIArea<ObjectFrameworkData>(new ObjectFrameworkData() {ObjectFramework = new LevelObject("Foo")}, 540, 75, 850, 690) {Closable = true};
            objectFrameworkArea.Visible = false;
            manager.AddArea(objectFrameworkArea);
            manager.UIManagerAreas.ObjectFrameworkArea = this;

            objectFrameworkArea.AddControl(new TextArea(30, 25, "Object Framework") {Color = "blue"});

            objectFrameworkArea.AddControl(new TextArea(16, 60, "Assets") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38, 140, 25, "Add Asset") {
                                                                                             Color = "rgb(50,150,50)",
                                                                                             Click = (p) => {
                                                                                                         objectFrameworkArea.Data.ObjectFramework.Assets.Add(
                                                                                                                 new LevelObjectAsset("Asset " +
                                                                                                                                      ( objectFrameworkArea.Data.ObjectFramework.Assets.Count +
                                                                                                                                        1 )));
                                                                                                         Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                     }
                                                                                     });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Assets = new ScrollBox(30, 60 + 10, 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 1 ), "Pieces") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 1 ), 140, 25, "Add Piece") {
                                                                                                            Color = "rgb(50,150,50)",
                                                                                                            Click = (p) => {
                                                                                                                        objectFrameworkArea.Data.ObjectFramework.Pieces.Add(
                                                                                                                                new LevelObjectPiece("Piece " +
                                                                                                                                                     ( objectFrameworkArea.Data.ObjectFramework.
                                                                                                                                                                           Pieces.Count +
                                                                                                                                                       1 )));
                                                                                                                        Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                    }
                                                                                                    });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Pieces =
                    new ScrollBox(30, 60 + 10 + ( size * 1 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 2 ), "Piece Layouts") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 2 ), 140, 25, "Add Piece Layout") {
                                                                                                                   Color = "rgb(50,150,50)",
                                                                                                                   Click = (p) => {
                                                                                                                               objectFrameworkArea.Data.ObjectFramework.PieceLayouts.Add(
                                                                                                                                       new LevelObjectPieceLayout("Piece Layout " +
                                                                                                                                                                  ( objectFrameworkArea.Data.
                                                                                                                                                                                        ObjectFramework
                                                                                                                                                                                       .
                                                                                                                                                                                        PieceLayouts
                                                                                                                                                                                       .Count +
                                                                                                                                                                    1 )));
                                                                                                                               Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                           }
                                                                                                           });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.PieceLayouts =
                    new ScrollBox(30, 60 + 10 + ( size * 2 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 3 ), "Projectiles") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 3 ), 140, 25, "Add Projectile") {
                                                                                                                 Color = "rgb(50,150,50)",
                                                                                                                 Click = (p) => {
                                                                                                                             objectFrameworkArea.Data.ObjectFramework.Projectiles.Add(
                                                                                                                                     new LevelObjectProjectile(
                                                                                                                                             "Piece Projectile " +
                                                                                                                                             ( objectFrameworkArea.Data.ObjectFramework.Projectiles.
                                                                                                                                                                   Count + 1 )));
                                                                                                                             Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                         }
                                                                                                         });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Projectiles =
                    new ScrollBox(30, 60 + 10 + ( size * 3 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(320, 80 - 20, "Key: ") {Font = UIManager.UIManager.SmallTextFont, Color = "black"});
            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Key =
                    new TextBox(370, 60 - 20, 150, 25, "") {Color = "rgb(50,150,50)", Click = (p) => { objectFrameworkArea.Data.ObjectFramework.Key = objectFrameworkArea.Data.Key.Text; }});

            objectFrameworkArea.AddControl(new TextArea(320 + 205, 80 - 24, "Description: ") {Font = UIManager.UIManager.SmallTextFont, Color = "black"});
            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Description =
                    new TextBox(370 + 240, 60 - 20, 220, 25, "") {Color = "rgb(50,150,50)", Click = (p) => { objectFrameworkArea.Data.ObjectFramework.Description = objectFrameworkArea.Data.Description.Text; }});

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b1 = new Button(320, 95 - 20, 250, 25, "onInit") {
                                                                                                                             Color = "rgb(50,150,50)",
                                                                                                                             Click = (p) => {
                                                                                                                                         objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                         if (objectFrameworkArea.Data.b1.Toggled) {
                                                                                                                                             addCodeWindow(objectFrameworkArea.Data.ObjectFramework.InitScript,
                                                                                                                                                           () => { objectFrameworkArea.Data.ObjectFramework.InitScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                         } else
                                                                                                                                             ClearMainArea();
                                                                                                                                     }
                                                                                                                     });
            objectFrameworkArea.Data.b1.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b2 = new Button(580, 95 - 20, 250, 25, "onTick") {
                                                                                                                             Color = "rgb(50,150,50)",
                                                                                                                             Click = (p) => {
                                                                                                                                         objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                         if (objectFrameworkArea.Data.b2.Toggled) {
                                                                                                                                             addCodeWindow(objectFrameworkArea.Data.ObjectFramework.TickScript,
                                                                                                                                                           () => { objectFrameworkArea.Data.ObjectFramework.TickScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                         } else
                                                                                                                                             ClearMainArea();
                                                                                                                                     }
                                                                                                                     });
            objectFrameworkArea.Data.b2.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b3 = new Button(320, 130 - 20, 250, 25, "onCollide") {
                                                                                                                                 Color = "rgb(50,150,50)",
                                                                                                                                 Click = (p) => {
                                                                                                                                             objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                             objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                             objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                             if (objectFrameworkArea.Data.b3.Toggled) {
                                                                                                                                                 addCodeWindow(objectFrameworkArea.Data.ObjectFramework.CollideScript,
                                                                                                                                                               () => { objectFrameworkArea.Data.ObjectFramework.CollideScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                             } else
                                                                                                                                                 ClearMainArea();
                                                                                                                                         }
                                                                                                                         });
            objectFrameworkArea.Data.b3.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b4 = new Button(580, 130 - 20, 250, 25, "onHurtSonic") {
                                                                                                                                   Color = "rgb(50,150,50)",
                                                                                                                                   Click = (p) => {
                                                                                                                                               objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                               objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                               objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                               if (objectFrameworkArea.Data.b4.Toggled) {
                                                                                                                                                   addCodeWindow(objectFrameworkArea.Data.ObjectFramework.HurtScript,
                                                                                                                                                                 () => { objectFrameworkArea.Data.ObjectFramework.HurtScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                               } else
                                                                                                                                                   ClearMainArea();
                                                                                                                                           }
                                                                                                                           });
            objectFrameworkArea.Data.b4.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.MainPanel = new Panel<MainPanelData>(new MainPanelData(), 320, 150, 510, 510));
            //    setTimeout("        var sc = document.getElementById("picFieldUploader");sc.style.visibility = "hidden";sc.style.position="absolute";", 300);
        }
Ejemplo n.º 5
0
        public LiveObjectsArea(UIManager.UIManager uiManager)
        {
            var liveObjectsArea = uiManager.UIManagerAreas.LiveObjectsArea = new UIArea<LiveObjectsAreaData>(new LiveObjectsAreaData(), 947, 95, 770, 700) {Closable = true};
            liveObjectsArea.Visible = true;
            uiManager.AddArea(liveObjectsArea);
            liveObjectsArea.AddControl(new TextArea(30, 25, "Live Objects") {Color = "blue"});
            HScrollBox scl;
            liveObjectsArea.AddControl(scl = new HScrollBox(20, 60, 85, 8, 85) {BackColor = "rgb(50,150,50)"});

            liveObjectsArea.Data.Populate = (liveObjects) => {
                                                foreach (Element t in scl.Controls) {
                                                    ( (ImageButton<LivePopulateModel>) t ).Data.@checked = false;
                                                }

                                                foreach (var lo in liveObjects) {
                                                    var satisfied = false;
                                                    foreach (Element t in scl.Controls) {
                                                        if (lo.Index == ( (ImageButton<LivePopulateModel>) t )[email protected]) {
                                                            ( (ImageButton<LivePopulateModel>) t ).Data.@checked = true;
                                                            satisfied = true;
                                                            break;
                                                        }
                                                    }
                                                    if (!satisfied) {
                                                        var obj = lo;

                                                        ImageButton<LivePopulateModel> dm = null;
                                                        ImageButton<LivePopulateModel> imageButton = new ImageButton<LivePopulateModel>(new LivePopulateModel(), 0, 0, 0, 0);
                                                        imageButton.Text = obj.ObjectData.Description + "(" + obj.ObjectData.Key + ")";
                                                        imageButton.OnDraw = (canv, x, y) => { obj.Draw(canv, x + dm.Width / 2, y + dm.Height / 2, false); };
                                                        imageButton.Click = (p) => { liveObjectsArea.Data.DebugConsole.Data.Populate(obj); };
                                                        scl.AddControl(dm = imageButton);
                                                        dm.Data.@checked = true;
                                                        dm.Data.@object = obj;
                                                    }
                                                }
                                                for (var i = scl.Controls.Count - 1; i >= 0; i--) {
                                                    if (!( (ImageButton<LivePopulateModel>) scl.Controls[i] ).Data.@checked)
                                                        scl.Controls.RemoveAt(i);
                                                }
                                            };
            liveObjectsArea.AddControl(liveObjectsArea.Data.DebugConsole = new Panel<DebugConsoleData>(new DebugConsoleData(), 20, 200, 730, 450));

            liveObjectsArea.Data.DebugConsole.Data.Populate = (obj) => {
                                                                  liveObjectsArea.Data.DebugConsole.Clear();
                                                                  liveObjectsArea.Data.DebugConsole.AddControl(liveObjectsArea.Data.DebugConsole.Data.Watch = new ScrollBox(10, 15, 30, 12, 210) {BackColor = "rgb(50,150,50)"});

                                                                  var o = JsDictionary<string, object>.GetDictionary(obj);

                                                                  foreach (var pr in o) {
                                                                      if (true /*!Help.IsFunction(pr.Value)*/) {
                                                                          KeyValuePair<string, object> pr1 = pr;
                                                                          liveObjectsArea.Data.DebugConsole.Data.Watch.AddControl(new Button(0, 0, 0, 0, (Func<string>) ( () => pr1.Key + ": " + pr1.Value )) {Color = "rgb(50,190,90)"});
                                                                      }
                                                                  }

                                                                  foreach (LevelObjectInfo t in SonicManager.Instance.SonicLevel.Objects) {
                                                                      t.ConsoleLog = null;
                                                                  }

                                                                  obj.ConsoleLog = (txt) => {
                                                                                       liveObjectsArea.Data.DebugConsole.Data.Element.InnerHTML = txt.Join("\n");
                                                                                       liveObjectsArea.Data.DebugConsole.Data.Element.ScrollTop = liveObjectsArea.Data.DebugConsole.Data.Element.ScrollHeight;
                                                                                   };

                                                                  liveObjectsArea.Data.DebugConsole.AddControl(new HtmlBox(270, 15) {
                                                                                                                                            Width = 445,
                                                                                                                                            Height = 430,
                                                                                                                                            Init = () => {
                                                                                                                                                       var gm = liveObjectsArea.Data.DebugConsole.Data.Element;
                                                                                                                                                       if (gm != null)
                                                                                                                                                           gm.ParentNode.RemoveChild(gm);

                                                                                                                                                       jQuery.FromElement(Document.Body).Append(
                                                                                                                                                               @"<textarea id=""console"" name=""console"" style=""position:absolute;width:445px;height:430px;""></textarea>");
                                                                                                                                                       liveObjectsArea.Data.DebugConsole.Data.Element = Document.GetElementById("console");
                                                                                                                                                   },
                                                                                                                                            UpdatePosition = (x, y) => {
                                                                                                                                                                 var scroller = liveObjectsArea.Data.DebugConsole.Data.Element;
                                                                                                                                                                 if (scroller.Style.Left == x + "px" && scroller.Style.Top == y + "px")
                                                                                                                                                                     return;
                                                                                                                                                                 scroller.Style.Left = x + "px";
                                                                                                                                                                 scroller.Style.Top = y + "px";
                                                                                                                                                             },
                                                                                                                                            _Focus = () => {
                                                                                                                                                         var sc = liveObjectsArea.Data.DebugConsole.Data.Element;
                                                                                                                                                         if (sc != null)
                                                                                                                                                             sc.Style.Visibility = "visible";
                                                                                                                                                     },
                                                                                                                                            _Hide = () => {
                                                                                                                                                        var sc = liveObjectsArea.Data.DebugConsole.Data.Element;
                                                                                                                                                        sc.Blur();
                                                                                                                                                        //            Engine.uiCanvasItem.focus();
                                                                                                                                                        //            document.body.focus();

                                                                                                                                                        //            editor.onBlur();

                                                                                                                                                        if (sc != null) {
                                                                                                                                                            sc.Style.Left = "-100px";
                                                                                                                                                            sc.Style.Top = "-100px";
                                                                                                                                                            sc.Style.Visibility = "hidden";
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                    });
                                                              };
        }
Ejemplo n.º 6
0
        private void buildTilePiece(UIManager.UIManager uiManager)
        {
            var tilePieceArea = uiManager.UIManagerAreas.TilePieceArea = new UIArea<TilePiece>(null, 1100, 400, 390, 390) {Closable = true};
            tilePieceArea.Visible = false;

            uiManager.AddArea(tilePieceArea);
            tilePieceArea.AddControl(new TextArea(30, 25, "Tile Pieces") {Color = "blue"});

            bool showHeightMap = false;
            tilePieceArea.AddControl(new Button(100, 50, 125, 25, (Func<string>) ( () => showHeightMap ? "Hide Height Map" : "Show Height Map" )) {
                                                                                                                                                          Click = (e) => {
                                                                                                                                                                      if (tilePieceArea.Data == null) return;
                                                                                                                                                                      showHeightMap = !showHeightMap;
                                                                                                                                                                  }
                                                                                                                                                  });

            tilePieceList = new ScrollBox(10, 35, 96 - 16, 4, 64) {BackColor = "rgb(50,60,127)"};
            tilePieceArea.AddControl(tilePieceList);

            var tilePieces = SonicManager.Instance.SonicLevel.TilePieces.Array();
            for (int index = 0; index < tilePieces.Length; index++) {
                var tilePiece = tilePieces[index];
                ImageButton<TilePiece> tilePieceButton = new ImageButton<TilePiece>(tilePiece, 0, 0, 0, 0);
                tilePieceButton.OnDraw = (cnv, x, y) => {
                                             cnv.Save();
                                             cnv.Translate(x, y);
                                             cnv.Scale(4, 4);
//                                             tilePieceButton.Data.Draw(cnv, new Point(0, 0), ChunkLayer.Low, false, false, 0);
//                                             tilePieceButton.Data.Draw(cnv, new Point(0, 0), ChunkLayer.High, false, false, 0);

                                             if (showHeightMap) {
                                                 HeightMap hmap;
                                                 if (SonicManager.Instance.SonicLevel.CurHeightMap)
                                                     hmap = tilePiece.GetLayer1HeightMaps();
                                                 else
                                                     hmap = tilePiece.GetLayer2HeightMaps();

                                                 hmap.Draw(cnv, new Point(0, 0), false, false, 1, 0);
                                             }

                                             cnv.Restore();
                                         };
                tilePieceButton.Font = UIManager.UIManager.SmallTextFont;
                tilePieceButton.Text = "Tile Piece #" + index;
                tilePieceButton.Click = (e) => { tilePieceArea.Data = tilePiece; };
                tilePieceList.AddControl(tilePieceButton);
            }

            Image image = new Image(105, 120, 256, 256);
            image.OnDraw += (context, x, y) => {
                                if (tilePieceArea.Data == null) return;
                                context.Save();
                                context.Translate(x, y);
                                context.Scale(16, 16);
//                                tilePieceArea.Data.Draw(context, new Point(0, 0), ChunkLayer.Low, false, false, 0);
//                                tilePieceArea.Data.Draw(context, new Point(0, 0), ChunkLayer.High, false, false, 0);
                                context.Restore();
                            };

            tilePieceArea.AddControl(image);
        }
Ejemplo n.º 7
0
        public LevelSelectorArea(UIManager.UIManager manager)
        {
            var levelInformation = new UIArea(70, 70, 460, 420);
            levelInformation.Visible = true;
            manager.AddArea(levelInformation);

            levelInformation.AddControl(new TextArea(30, 25, "Level Selector") { Font = UIManager.UIManager.TextFont, Color = "blue" });
            levelInformation.AddControl(new TextArea(30, 52, ((Func<string>)(() => UIManager.UIManager.CurLevelName))) { Font = UIManager.UIManager.TextFont, Color = "black" });

            levelInformation.AddControl(new Button(320, 70, 100, 22, "Save Level") { Font = UIManager.UIManager.ButtonFont, Color = "rgb(50,150,50)" });

            levelInformation.AddControl(new Button(320, 105, 135, 22, "Load Empty Level")
            {
                Font = UIManager.UIManager.ButtonFont,
                Color = "rgb(50,150,50)",
                Click = (p) =>
                {
                    /*  levelManagerArea.visible = true;
loadingText.visible = true;
var index = 0;
var tim = function () {
var max = 188;
if (index == max) {
setTimeout(function () {
alert(_H.stringify(sonicManager.SonicLevel));
sonicManager.uiManager.loadGame(_H.stringify(sonicManager.SonicLevel), sonicManager.mainCanvas);
loadingText.visible = false;
}, 500);
return;
}
setTimeout(tim, 100);

_H.loadSprite("assets/Chunks/Tile" + index++ + ".png", function (image) {
loadingText.text = "Loading " + index + "/" + max;
sonicManager.importChunkFromImage(image);
if (index == max) {
sonicManager.inds = { done: true };
}
});

};
setTimeout(tim, 100);*/
                }
            });

            var ctls =
                    levelInformation.AddControl(new ScrollBox(30, 70, 25, 11, 250) { BackColor = "rgb(50, 60, 127)", });
            var loadLevel = (Action<string>)(name =>
            {
                UIManager.UIManager.UpdateTitle("Downloading " + name);
                SonicEngine.Instance.client.Emit("LoadLevel.Request", new DataObject<string>(name));
                ;
            });
            bool neverGot=true;
            SonicEngine.Instance.client.On<DataObject<string>>("LoadLevel.Response", LoadLevel);
            Window.SetTimeout(() => {
                if (neverGot) {
                    UIManager.UIManager.CurLevelName = "Connection Failed, static level loaded";
                    LoadLevel(new DataObject<string>(Window.Instance.Me().STATICLEVEL));
                }

                  

                              }, 3000);

            SonicEngine.Instance.client.On<DataObject<string[]>>("GetLevels.Response",
                                                                 data => {
                                                                     neverGot = false;
                                                                     bool load = true;
                                                                     foreach (var level in data.Data.OrderBy(a => a))
                                                                     {
                                                                         if (load)
                                                                         {
                                                                             //#if RELEASE
                                                                             //loadLevel(level);
                                                                             //#endif
                                                                             load = false;
                                                                         }
                                                                         string area = level;
                                                                         ctls.AddControl(new Button(0, 0, 0, 0, level)
                                                                         {
                                                                             Color = "rgb(50,190,90)",
                                                                             Click = (p) => { loadLevel(area); }
                                                                         });
                                                                     }
                                                                 });
            SonicEngine.Instance.client.Emit("GetLevels.Request", null);

            UIManager.UIManager.CurLevelName = "Level Not Loaded";
        }
        public ObjectFrameworkListArea(UIManager.UIManager uiManager)
        {
            Action<string> loadObject = null;

            var objectFrameworkListArea = uiManager.UIManagerAreas.ObjectFrameworkListArea = new UIArea(90, 500, 390, 300) {Closable = true};
            objectFrameworkListArea.Visible = true;

            uiManager.AddArea(objectFrameworkListArea);
            objectFrameworkListArea.AddControl(new TextArea(30, 25, "Object Frameworks") {Color = "blue"});
            ScrollBox fList;
            objectFrameworkListArea.AddControl(fList = new ScrollBox(30, 90, 25, 6, 315) {BackColor = "rgb(50,60,127)"});
            objectFrameworkListArea.AddControl(new Button(35, 50, 160, 25, "Create Framework") {
                                                                                                       Color = "rgb(50,150,50)",
                                                                                                       Click = (p) => {
                                                                                                                   uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(new LevelObject("SomeKey"));
                                                                                                                   uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                                                                                               }
                                                                                               });
            Action getObjects = () => {
                                    SonicEngine.Instance.client.Emit("GetAllObjects", "");
                                    SonicEngine.Instance.client.On<DataObject<string[]>>("GetAllObjects.Response",
                                                                                         (data) => {
                                                                                             var obj = data.Data;

                                                                                             fList.Controls = new List<Element>();
                                                                                             foreach (var itm in obj.OrderBy(a => a)) {
                                                                                                 Button d;
                                                                                                 string name = itm;
                                                                                                 fList.AddControl(d = new Button(0, 0, 0, 0, itm) {
                                                                                                                                                          Color = "rgb(50,190,90)",
                                                                                                                                                          Click = (p) => { loadObject(name); }
                                                                                                                                                  });
                                                                                             }
                                                                                         });
                                };

            objectFrameworkListArea.AddControl(new Button(200, 50, 160, 25, "Save Framework") {
                                                                                                      Color = "rgb(50,150,50)",
                                                                                                      Click = (p) => {
                                                                                                                  var oldTitle = UIManager.UIManager.CurLevelName;
                                                                                                                  UIManager.UIManager.UpdateTitle("Saving Object");

                                                                                                                  var k = uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.Key;
                                                                                                                  var o = uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.oldKey ??
                                                                                                                          uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.Key;
                                                                                                                  var v = Help.Stringify(uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework);

                                                                                                                  SonicEngine.Instance.client.Emit("SaveObject", new SaveObjectModel {Key = k, OldKey = o, Data = v});
                                                                                                                  SonicEngine.Instance.client.On<bool>("SaveObject.Response", (data) => { UIManager.UIManager.UpdateTitle(oldTitle); });

                                                                                                                  getObjects();
                                                                                                              }
                                                                                              });

            getObjects();
            loadObject = (name) => {
                             var objects = SonicManager.Instance.cachedObjects;
                             if (objects != null) {
                                 if (objects[name] != null) {
                                     uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(objects[name]);
                                     uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                     return;
                                 }
                             }

                             var oldTitle = UIManager.UIManager.CurLevelName;

                             UIManager.UIManager.UpdateTitle("Downloading Object:" + name);

                             SonicEngine.Instance.client.Emit("GetObject", new DataObject<string>(name));
                             SonicEngine.Instance.client.On<DataObject<string>>("GetObject.Response",
                                                                                (lvl) => {
                                                                                    UIManager.UIManager.UpdateTitle(oldTitle);
                                                                                    var d = ObjectManager.ExtendObject(jQuery.ParseJsonData<LevelObjectData>(lvl.Data));
                                                                                    uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(d);
                                                                                    uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                                                                });
                         };
        }