Ejemplo n.º 1
0
        private void CreateWindows()
        {
            windows = new PhControl(0, 0, PhantomGame.Game.Resolution.Width, PhantomGame.Game.Resolution.Height);
            windows.Ghost = true;
            AddComponent(windows);

            main = new PhWindow(100, 100, 500, 500, "Main Menu");
            main.Ghost = true;
            int y = 30;
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Layers", StartSelectLayer));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Entities", StartSelectEntity));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Clear Map", ClearMap));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Save Map", SaveMap));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Open Map", OpenMap));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Close Menu", CloseMenu));
            main.AddComponent(new PhButton(10, y += 32, 480, 24, "Close Editor", CloseEditor));
            windows.AddComponent(main);

            layerWindow = new PhWindow(100, 100, 500, 500, "Layers");
            layerWindow.Ghost = true;
            for (int i = 0; i < layers.Count; i++)
                layerWindow.AddComponent(new PhButton(10, 30+i*32, 480, 24, layers[i].Name, SelectLayer));
            windows.AddComponent(layerWindow);

            tilesWindow = new PhWindow(100, 100, 500, 500, "Tiles");
            tilesWindow.Ghost = true;
            int x = 10;
            y = 30;
            tilesWindow.AddComponent(new PhButton(x, y, 160, 24, "<none>", SelectEntity));
            y += 32;
            for (int i = 0; i < MapLoader.TileList.Length; i++)
            {
                tilesWindow.AddComponent(new PhButton(x, y, 160, 24, MapLoader.ShortTypeName(MapLoader.TileList[i]), SelectEntity));
                y += 32;
                if (y > 500 - 32)
                {
                    x += 168;
                    y = 30;
                }
            }
            windows.AddComponent(tilesWindow);

            entitiesWindow = new PhWindow(100, 100, 500, 500, "Entities");
            entitiesWindow.Ghost = true;
            x = 10;
            y = 30;
            for (int i = 0; i < MapLoader.EntityList.Length; i++)
            {
                entitiesWindow.AddComponent(new PhButton(x, y, 160, 24, MapLoader.ShortTypeName(MapLoader.EntityList[i]), SelectEntity));
                y += 32;
                if (y > 500 - 32)
                {
                    x += 168;
                    y = 30;
                }
            }
            windows.AddComponent(entitiesWindow);
        }
Ejemplo n.º 2
0
        private void CreatePropertiesWindow(string name, Component component)
        {
            propertiesWindowTarget = component;
            propertiesWindow = new PhWindow(100, 100, 500, 500, name+ " Properties");

            propertiesWindow.AddComponent(new PhButton(300, 450, 80, 32, "OK", SaveProperties));
            propertiesWindow.AddComponent(new PhButton(400, 450, 80, 32, "Cancel", CloseProperties));

            int x = 100;
            int y = 30;
            if (component is Entity)
            {
                propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, (component as Entity).Position.X.ToString(), "X", PhTextEdit.ValueType.Float, null, null));
                y += 24;
                propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, (component as Entity).Position.Y.ToString(), "Y", PhTextEdit.ValueType.Float, null, null));
                y += 24;
                propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, MathHelper.ToDegrees((component as Entity).Orientation).ToString(), "Orientation", PhTextEdit.ValueType.Float, null, null));
                y += 24;
            }

            foreach (KeyValuePair<string, int> property in component.Properties.Ints)
            {
                if (property.Key[0] >= 'A' && property.Key[0] <= 'Z')
                {
                    propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, property.Value.ToString(), property.Key, PhTextEdit.ValueType.Int, null, null));
                    y+=24;
                    if (y>500-30) {
                        y = 30;
                        x += 200;
                    }
                }
            }

            foreach (KeyValuePair<string, float> property in component.Properties.Floats)
            {
                if (property.Key[0] >= 'A' && property.Key[0] <= 'Z')
                {
                    propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, property.Value.ToString(), property.Key, PhTextEdit.ValueType.Float, null, null));
                    y += 24;
                    if (y > 500 - 30)
                    {
                        y = 30;
                        x += 200;
                    }
                }
            }
            foreach (KeyValuePair<string, object> property in component.Properties.Objects)
            {
                if (property.Key[0] >= 'A' && property.Key[0] <= 'Z')
                {
                    if (property.Value is string)
                    {
                        propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, property.Value as String, property.Key, PhTextEdit.ValueType.String, null, null));
                        y += 24;
                    }
                    if (property.Value is Color)
                    {
                        string hex = "#" + ((Color)property.Value).A.ToString("X2") + ((Color)property.Value).R.ToString("X2") + ((Color)property.Value).G.ToString("X2") + ((Color)property.Value).B.ToString("X2");
                        propertiesWindow.AddComponent(new PhTextEdit(x, y, 100, 20, hex, property.Key, PhTextEdit.ValueType.Color, null, null));
                        y += 24;
                    }
                    if (y > 500 - 30)
                    {
                        y = 30;
                        x += 200;
                    }
                }
            }

            windows.AddComponent(propertiesWindow);
        }