示例#1
0
        private static WObject CreateItemRenderer(WObject parent, out Model model, out Label amount)
        {
            WObject itemRenderer = new WObject("Item")
            {
                Parent = parent,
                Layer  = (ulong)Layers.UI,
            };


            model = itemRenderer.AddModule <Model>();
            model.Renderer.Material = ItemCache.AtlasMaterial;
            model.KeepRatio         = true;

            WObject labelRender = new WObject("Amount")
            {
                Parent = itemRenderer,
                Layer  = (ulong)Layers.UI
            };

            amount           = labelRender.AddModule <Label>();
            amount.Text      = "";
            amount.AutoSize  = true;
            amount.Aligns    = TextAligns.Down | TextAligns.Right;
            amount.MinAnchor = new Vector2D(0.05, -0.3);
            amount.MaxAnchor = new Vector2D(1.0, 0.3);

            return(itemRenderer);
        }
示例#2
0
        private void UpdateItem(ContainerItem item, int index)
        {
            Item aitem = item.Item;

            WObject itemRenderer = InventoryItemsRenders[index];
            Model   mod          = null;
            Label   amount       = null;

            if (itemRenderer == null)
            {
            }
            else
            {
                mod    = itemRenderer.GetModule <Model>();
                amount = InventoryItemsAmount[index];
            }

            itemRenderer.LocalRotation = aitem.InventoryRotation;
            itemRenderer.LocalScale    = aitem.InventoryScale;

            if (aitem.Identifier == "winecrash:air")
            {
                mod.Renderer.Mesh = null;
                amount.Text       = "";
            }
            else
            {
                mod.Renderer.Mesh = aitem.Model;
                amount.Text       = item.Amount > 1 ? item.Amount.ToString() : "";
            }



            amount.WObject.Rotation = Quaternion.Identity;
        }
示例#3
0
        private void CreatePlayerInventory()
        {
            Inventory = new WObject("Player Inventory")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };

            Image img = Inventory.AddModule <Image>();

            img.KeepRatio = true;
            img.Picture   = new Texture("assets/textures/gui/inventory.png", "Player Inventory", true);
            img.MinAnchor = new Vector2D(0.33, 0.0);
            img.MaxAnchor = new Vector2D(0.66, 1.0);
            img.Depth     = -1;

            WObject wobj = new WObject("Crafting Label")
            {
                Parent = Inventory,
                Layer  = (ulong)Layers.UI
            };

            LocalizedLabel lb = wobj.AddModule <LocalizedLabel>();

            lb.Localization = "#winecrash:ui.inventory.crafting";
            lb.AutoSize     = true;
            lb.Aligns       = TextAligns.Left;
            lb.MinAnchor    = new Vector2D(0.5, 0.90);
            lb.MaxAnchor    = new Vector2D(0.95, 0.965);
            lb.Color        = new Color256(0.35, 0.35, 0.35, 1.0);
            lb.Shadows      = false;

            Inventory.Enabled = false;
        }
示例#4
0
        public Entity Parse()
        {
            try
            {
                Entity entity = Entity.Get(this.GUID);

                if (entity != null)
                {
                    //Debug.Log($"Updating Entity [{entity.GetType().Name}] {GUID}");

                    entity.WObject.Position = Position;
                }
                else
                {
                    WObject ettWobj = new WObject("Entity " + GUID)
                    {
                        Position = Position,
                    };
                    entity            = (Entity)ettWobj.AddModule(this.EntityType);
                    entity.Identifier = GUID;

                    //Debug.Log($"Created Entity [{ent.GetType().Name}] {GUID}");
                }

                entity.Rotation           = Rotation;
                entity.RigidBody.Velocity = this.Velocity;

                return(entity);
            }
            catch (Exception e)
            {
                Debug.LogError("Error when trying to parse entity: " + e.Message);
                return(null);
            }
        }
示例#5
0
        protected override void Creation()
        {
            Instance       = this;
            this.FPSCamera = Camera.Main;
            this._Rb       = this.WObject.GetModule <RigidBody>();
            this._Bc       = this.WObject.GetModule <BoxCollider>();


            Cursor3D = new WObject("Block Cursor");
            MeshRenderer mr = Cursor3D.AddModule <MeshRenderer>();

            mr.Material = new Material(Shader.Find("Cursor"));
            mr.Material.SetData <Vector4>("color", new Color256(0.0D, 0.0D, 0.0D, 1.0D));
            mr.Material.SetData <float>("border", 0.1F);
            mr.Material.SetData <float>("opacity", 0.85F);
            mr.Mesh = Mesh.LoadFile("assets/models/Cube.obj", MeshFormats.Wavefront);
            //mr.Wireframe = true;
            Cursor3D.Scale *= 1.005F;

            /*HitSphere = new WObject("Debug hit sphere");
             * MeshRenderer hmr = HitSphere.AddModule<MeshRenderer>();
             * hmr.Material = new Material(Shader.Find("Unlit"));
             * hmr.Material.SetData<Vector4>("color", new Color256(0, 1, 0, 1));
             * hmr.Mesh = Mesh.LoadFile("assets/models/Skysphere.obj", MeshFormats.Wavefront);
             * hmr.Wireframe = true;
             * HitSphere.Scale *= 0.05F;*/

            Cursor3D.Enabled /*= HitSphere.Enabled*/ = false;

            for (int i = 0; i < 10; i++)
            {
                mr.Material.SetData <Texture>("albedo" + i, break_textures[i]);
            }
        }
示例#6
0
        static void CreateSkybox()
        {
            new Shader("assets/shaders/skybox/Skybox.vert", "assets/shaders/skybox/Skybox.frag");

            WObject      sky = new WObject("Skybox");
            MeshRenderer mr  = sky.AddModule <MeshRenderer>();

            sky.AddModule <DayNightCycle>();

            mr.Mesh    = Mesh.LoadFile("assets/models/Skysphere.obj", MeshFormats.Wavefront);
            mr.UseMask = false;

            mr.Material = new Material(Shader.Find("Skybox"));
            mr.Material.SetData <Vector4>("horizonColourDay", HorizonColourDay);
            mr.Material.SetData <Vector4>("horizonColourSunset", HorizonColourSunset);
            mr.Material.SetData <Vector4>("nightColour", NightColour);
            mr.Material.SetData <Vector4>("highAtmosphereColour", HighAtmosphereColour);
            mr.Material.SetData <Vector4>("groundAtmosphereColour", GroundAtmosphereColour);

            mr.Material.SetData <float>("sunSize", 0.1F);

            mr.Material.SetData <Vector4>("sunInnerColor", new Color256(1.0D, 1.0D, 1.0D, 1.0D));
            mr.Material.SetData <Vector4>("sunOuterColor", new Color256(245D / 255D, 234D / 255D, 181D / 255D, 1.0D));

            sky.Layer = 1L << 32;

            WObject sun = new WObject("Sun");

            sun.AddModule <DirectionalLight>();


            SkyboxCamera skycam = new WObject("Skybox Camera").AddModule <SkyboxCamera>();

            skycam.ReferenceCamera = Camera.Main;
        }
示例#7
0
        protected override void FirstFrame()
        {
            base.FirstFrame();

            if (ModelWObject)
            {
                ModelWObject.Enabled = !(Player.LocalPlayer != null && Player.LocalPlayer.Entity == this);

                if (!ModelWObject.Enabled && PlayerHandWobject == null) // local player
                {
                    PlayerHandWobject               = new WObject("FPS Hand");
                    PlayerHandWobject.Parent        = Camera.Main.WObject;
                    PlayerHandWobject.LocalPosition =
                        Vector3D.Left * 0.4 + Vector3D.Forward * 0.4 + Vector3D.Down * 0.75;
                    PlayerHandWobject.LocalRotation  = new Quaternion(180 + 45, -20, 0);
                    PlayerHandWobject.LocalRotation *= new Quaternion(0, -25, 0);
                    MeshRenderer mr = PlayerHandWobject.AddModule <MeshRenderer>();
                    mr.UseDepth  = false;
                    mr.DrawOrder = 1000;

                    mr.Mesh     = PlayerRightArmMesh;
                    mr.Material = SkinMaterial;
                }
            }
        }
示例#8
0
        protected override void Creation()
        {
            base.Creation();

            Vector3D scale = Vector3D.One * 0.25D;

            //WObject.LocalScale = scale;
            Collider.Extents     = scale / 2.0D;
            Collider.CastExtents = 0.85D;
            Collider.CastLength  = 0.05D;

            RendererWObject = new WObject("Renderer")
            {
                Parent        = this.WObject,
                LocalPosition = Vector3D.Zero,
                LocalScale    = scale,
                LocalRotation = Quaternion.Identity
            };

            Renderer = this.RendererWObject.AddModule <MeshRenderer>();
            Material mat = ItemCache.AtlasMaterial;

            Renderer.Material = mat;

            RigidBody.UseGravity = true;
            RigidBody.Drag       = 0.5D;
        }
    internal static int __GetHandle(this WObject obj)
    {
        if (object.ReferenceEquals(obj, null))
        {
            return(0);
        }

        return(obj.Handle);
    }
示例#10
0
        private static void Create()
        {
            _PanelWobject = new WObject("Main Loading Screen")
            {
                Parent = Canvas.Main.WObject
            };
            Image bg = _PanelWobject.AddModule <Image>();

            bg.Picture = Texture.GetOrCreate("assets/textures/icon.png");
            bg.Color   = Color256.White;
        }
示例#11
0
文件: World.cs 项目: Arekva/winecrash
        private static WObject GetOrCreateDimensionWObject(Dimension dimension)
        {
            if (WorldWObject == null)
            {
                WorldWObject = new WObject("World");
            }

            return(WorldWObject.FindChild(dimension.Identifier) ??
                   new WObject(dimension.Identifier)
            {
                Parent = WorldWObject
            });
        }
示例#12
0
        private void UpdateHotbarSelected(ContainerItem item, int index)
        {
            WObject wobj = PlayerEntity.PlayerHandWobject;

            Material material = ItemCache.AtlasMaterial;
            Mesh     mesh     = null;
            Item     aitem;

            if (item == null)
            {
                aitem = ItemCache.Get <Item>("winecrash:air");
            }
            else
            {
                aitem = item.Item;
            }

            if (aitem.Identifier == "winecrash:air")
            {
                material = Player.LocalPlayer.Entity.SkinMaterial;
                mesh     = PlayerEntity.PlayerRightArmMesh;
            }
            else
            {
                mesh = aitem.Model;
                ItemDisplayName(aitem);
            }

            wobj.LocalPosition = aitem.HandPosition;
            wobj.LocalRotation = aitem.HandRotation;
            wobj.LocalScale    = aitem.HandScale;

            MeshRenderer mr = wobj.GetModule <MeshRenderer>();

            mr.Material = material;
            mr.Mesh     = mesh;

            Image img = HotbarSelector.GetModule <Image>();

            Vector2D min = new Vector2D(-0.0055D, 0.01D);
            Vector2D max = new Vector2D(0.1265, 1.0725D);

            double magicNumber = 0.989D;

            min.X += (index / 9D) * magicNumber;
            max.X += (index / 9D) * magicNumber;

            img.MinAnchor = min;
            img.MaxAnchor = max;
        }
示例#13
0
        public PlayerEntity CreateEntity(WObject parent)
        {
            if (Entity != null)
            {
                return(Entity);
            }

            PlayerEntity pe = parent.AddOrGetModule <PlayerEntity>();

            pe.Identifier = GUID;
            this.Entity   = pe;

            return(pe);
        }
示例#14
0
        private static void CreateMenu()
        {
            MenuWobject    = new WObject("Main Menu");
            MenuCameraWobj = new WObject("Main Menu Camera Wobject")
            {
                Parent = MenuWobject
            };
            Camera MainMenuCamera = MenuCameraWobj.AddModule <Camera>();

            MenuBGWObject        = new WObject("Main Menu Background Object");
            MenuBGWObject.Parent = MenuWobject;
            MainMenuCamera.FOV   = 80.0D;
            MainMenuCamera.WObject.LocalRotation = new Quaternion(25, 0, 0);

            MenuBGWObject.AddModule <MenuBackgroundControler>();

            WObject bgPanel = new WObject("Background Panel")
            {
                Parent = MenuWobject
            };

            bgPanel.Parent = MenuWobject;

            LocalizedLabel lbVersion = bgPanel.AddModule <LocalizedLabel>();

            lbVersion.LocalizationArgs = new object[] { Winecrash.Version };
            lbVersion.Localization     = "#winecrash:ui.mainmenu.gameversion";
            lbVersion.Aligns           = TextAligns.Down | TextAligns.Left;
            lbVersion.AutoSize         = true;
            lbVersion.MinAnchor        = new Vector2F(0.0F, 0.0F);
            lbVersion.MaxAnchor        = new Vector2F(1.0F, 0.05F);
            lbVersion.Color            = Color256.White;
            lbVersion.Left             = 20.0D;

            Label lbCopyright = bgPanel.AddModule <Label>();

            lbCopyright.Text      = "Copyright Arekva 2020\nAll Rights Reserved";
            lbCopyright.Aligns    = TextAligns.Down | TextAligns.Right;
            lbCopyright.AutoSize  = true;
            lbCopyright.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbCopyright.MaxAnchor = new Vector2F(1.0F, 0.1F);
            lbCopyright.Color     = Color256.White;
            lbCopyright.Right     = 20.0D;


            CreateMain();
            CreateOptions();
            CreateMultiplayer();
        }
示例#15
0
        private void UpdateHotbarItem(ContainerItem item, int index)
        {
            Item aitem = item.Item;

            WObject itemRenderer = HotbarItemsRenders[index];
            Model   mod          = null;
            Label   amount       = null;

            if (itemRenderer == null)
            {
                itemRenderer             = HotbarItemsRenders[index] = CreateItemRenderer(Hotbar, out mod, out amount);
                itemRenderer.Name       += " (Hotbar)";
                mod.Depth                = 1000;
                amount.Depth             = 1000;
                HotbarItemsAmount[index] = amount;
            }
            else
            {
                mod    = itemRenderer.GetModule <Model>();
                amount = HotbarItemsAmount[index];
            }

            itemRenderer.LocalRotation = aitem.InventoryRotation;
            itemRenderer.LocalScale    = aitem.InventoryScale;

            if (aitem.Identifier == "winecrash:air")
            {
                mod.Renderer.Mesh = null;
                amount.Text       = "";
            }
            else
            {
                mod.Renderer.Mesh = aitem.Model;
                amount.Text       = item.Amount > 1 ? item.Amount.ToString() : "";
            }


            mod.MinAnchor = _ItemHotbarAnchors[index][0];
            mod.MaxAnchor = _ItemHotbarAnchors[index][1];


            amount.WObject.Rotation = Quaternion.Identity;

            if (index == Player.LocalPlayer.HotbarSelectedIndex)
            {
                UpdateHotbarSelected(item, index);
            }
        }
示例#16
0
        public static Task DisplayScene()
        {
            return(Task.Run(() =>
            {
                Camera.Main.ClearColor = new Color256(1.0D, 1.0D, 1.0D, 1.0D);

                LoadScene = new WObject("LoadScene");
                LoadScene.Parent = Canvas.Main.WObject;
                Image bg = LoadScene.AddModule <Image>();
                Image logo = LoadScene.AddModule <Image>();
                logo.Picture = new Texture("assets/textures/logo.png");
                logo.KeepRatio = true;
                logo.MinAnchor = new Vector2F(0.3F, 0.6F);
                logo.MaxAnchor = new Vector2F(0.7F, 0.8F);
            }));
        }
示例#17
0
        protected internal override void Creation()
        {
            this.ParentGUI = this.WObject.Parent?.GetModule <GUIModule>();

            WObject bgWobj = new WObject("Image")
            {
                Parent = this.WObject
            };

            this.Background = bgWobj.AddModule <Image>();

            WObject lbWobj = new WObject("Label")
            {
                Parent = bgWobj
            };

            this.Label      = lbWobj.AddModule <Label>();
            this.Label.Text = "Button";

            this.Label.Color      = Color256.Black;
            this.Background.Color = IdleColor;

            this.OnHover += () =>
            {
                this.Background.Color = this.Locked ? this.LockedColor : this.HoverColor;
            };

            this.OnUnhover += () =>
            {
                this.Background.Color = this.Locked ? this.LockedColor : this.IdleColor;
            };

            this.OnLock += () =>
            {
                this.Background.Color = this.LockedColor;
            };

            this.OnUnlock += () =>
            {
                this.Background.Color = this.Hovered ? this.HoverColor : this.IdleColor;
            };

            this.OnColorChanged += () =>
            {
                this.Background.Color = this.Locked ? this._LockedColor : (this.Hovered ? this._HoverColor : this._IdleColor);
            };
        }
示例#18
0
        private void CreateInventoryFocus()
        {
            GlobalInventoryBackground = new WObject("Inventory Background")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };

            Image img = GlobalInventoryBackground.AddModule <Image>();

            //img.Material = MenuBackgroundMaterial;
            //img.SetupMaterial();
            img.Picture = Texture.Blank;
            img.Color   = new Color256(0.2, 0.2, 0.2, 0.75);
            //GlobalInventoryBackground.GetModule<ImageRenderer>().DrawOrder = 1;
            img.Depth = 0;
            GlobalInventoryBackground.Enabled = false;
        }
示例#19
0
    private WWW load(string path)
    {
        WObject obj = null;

        if (IdelObj.Count > 0)
        {
            obj = IdelObj.Dequeue();
        }
        else
        {
            obj = new WObject(path);
        }
        StartCoroutine(obj.Load());
        WWW w = obj.mLoad();

        IdelObj.Enqueue(obj);
        return(w);
    }
示例#20
0
        private void CreateInventoryRenders()
        {
            for (int i = 0; i < InventoryItemsRenders.Length; i++)
            {
                WObject itemRenderer = InventoryItemsRenders[i] = CreateItemRenderer(Inventory, out Model mod, out Label amount);
                itemRenderer.Name += " (Inventory)";
                UIBoxCollider collider = _colliders[i] = itemRenderer.AddModule <UIBoxCollider>();
                collider.GUIModule = mod;
                Vector2D scales = ItemSlotScale;
                collider.Extents        = new Vector3D(scales, 10000);
                mod.Depth               = -1000;
                amount.Depth            = -1000;
                InventoryItemsAmount[i] = amount;

                mod.MinAnchor = _ItemInventoryAnchors[i][0];
                mod.MaxAnchor = _ItemInventoryAnchors[i][1];
            }
        }
示例#21
0
        public void TakePanorama()
        {
            Task.Run(async() =>
            {
                Camera camera            = Camera.Main;
                WObject camWobj          = camera.WObject;
                IWindow window           = Graphics.Window;
                Vector2I baseRes         = window.SurfaceFixedResolution;
                Quaternion baseRot       = camWobj.Rotation;
                double baseFov           = camera.FOV;
                CursorLockModes baseLock = Input.LockMode;

                PlayerController.CameraLocked = true;

                Input.LockMode = LockMode;
                camera.FOV     = FOV;
                window.SurfaceFixedResolution = Resolution;

                string finalFolder = Path.Combine(SaveDirectory, Time.ShortTimeForFile);

                Directory.CreateDirectory(finalFolder);

                foreach (var kvp in FaceDirections)
                {
                    string face    = kvp.Key;
                    Quaternion dir = kvp.Value;

                    camWobj.Rotation = dir;

                    await Task.Delay(250);

                    using (Bitmap map = window.Screenshot())
                        map.Save(Path.Combine(finalFolder, face + ".png"));
                }

                PlayerController.CameraLocked = false;
                window.SurfaceFixedResolution = baseRes;
                camWobj.Rotation = baseRot;
                camera.FOV       = baseFov;
                Input.LockMode   = baseLock;
            });
        }
示例#22
0
        protected override void Creation()
        {
            Mesh     mesh     = Mesh.LoadFile("assets/models/Arrow.obj");
            Shader   shader   = Shader.Find("Unlit");
            Material material = new Material(shader);
            Texture  texture  = new Texture("assets/textures/arrow.png");

            material.SetData("color", Color256.White);
            material.SetData("albedo", texture);
            material.SetData("tiling", Vector2D.One);

            WObject arrow = _arrow = new WObject("Arrow")
            {
                Parent = WObject.Find("Player Camera"),
                Layer  = (ulong)Layers.Default, LocalPosition = Vector3D.Forward, LocalScale = Vector3D.One * 0.025
            };
            MeshRenderer meshRenderer = arrow.AddModule <MeshRenderer>();

            meshRenderer.Material = material;
            meshRenderer.Mesh     = mesh;
        }
示例#23
0
        protected override void OnDelete()
        {
            if (Instance == this)
            {
                Instance = null;
            }
            Crosshair?.Delete();
            Crosshair = null;

            HotbarImage = null;
            HotbarSelector?.Delete();
            HotbarSelector = null;

            HotbarImage = null;
            Hotbar?.Delete();
            Hotbar = null;

            Inventory?.Delete();
            Inventory = null;

            GlobalInventoryBackground?.Delete();
            GlobalInventoryBackground = null;

            ItemNameLabel.WObject.Delete();
            ItemNameLabel = null;

            HotbarItemsAmount  = null;
            HotbarItemsRenders = null;

            HoveredTooltipWObject.Delete();
            HoveredTooltipWObject = null;
            HoveredTooltip        = null;

            Player.LocalPlayer.OnHotbarUpdate         -= UpdateHotbarItem;
            Player.LocalPlayer.OnHotbarSelectedChange -= UpdateHotbarSelected;
            Player.LocalPlayer.OnContainerToggle      -= TogglePlayerInventory;
            Player.LocalPlayer.OnContainerClose       -= PlayerCloseInventory;
            Player.LocalPlayer.OnContainerOpen        -= PlayerOpenInventory;
            Player.LocalPlayer.OnItemUpdate           -= UpdateItem;
        }
示例#24
0
        private static void CreateMenu()
        {
            MenuWobject          = new WObject("Main Menu");
            MenuBGWObject        = new WObject("Main Menu Background Object");
            MenuBGWObject.Parent = MenuWobject;
            MenuBGWObject.AddModule <MenuBackgroundControler>();

            WObject bgPanel = new WObject("Background Panel")
            {
                Parent = MenuWobject
            };

            bgPanel.Parent = MenuWobject;

            Label lbVersion = bgPanel.AddModule <Label>();

            lbVersion.Text      = "Winecrash Alpha 0.0.1";
            lbVersion.Aligns    = TextAligns.Down | TextAligns.Left;
            lbVersion.AutoSize  = true;
            lbVersion.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbVersion.MaxAnchor = new Vector2F(1.0F, 0.05F);
            lbVersion.Color     = Color256.White;
            lbVersion.Left      = 20.0D;

            Label lbCopyright = bgPanel.AddModule <Label>();

            lbCopyright.Text      = "Copyright Arekva 2020\nAll Rights Reserved";
            lbCopyright.Aligns    = TextAligns.Down | TextAligns.Right;
            lbCopyright.AutoSize  = true;
            lbCopyright.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbCopyright.MaxAnchor = new Vector2F(1.0F, 0.1F);
            lbCopyright.Color     = Color256.White;
            lbCopyright.Right     = 20.0D;


            CreateMain();
            CreateOptions();
        }
示例#25
0
        protected override void Creation()
        {
            base.Creation();


            WObject bgImageW = new WObject("Background Image")
            {
                Parent = this.WObject, Layer = (ulong)Layers.UI
            };

            BackgroundImage       = bgImageW.AddModule <Image>();
            BackgroundImage.Color = new Color256(0.0, 0.0, 0.0, 0.95);

            WObject labelW = new WObject("Label")
            {
                Parent = bgImageW, Layer = (ulong)Layers.UI
            };

            Label          = labelW.AddModule <Label>();
            Label.Text     = "Nullref";
            Label.AutoSize = true;
            Label.Aligns   = TextAligns.Middle;
            Offset         = new Vector2D(-10, 10);
        }
示例#26
0
        public static void CreateMultiplayer()
        {
            WObject mainPanel = MultiPanel = new WObject("Multi UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject multiTitle = new WObject("Multi Main Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel mainLb = multiTitle.AddModule <LocalizedLabel>();

            mainLb.Localization = "#winecrash:ui.mutliplayer.title";
            mainLb.MinAnchor    = new Vector2F(0.0F, 1.0F);
            mainLb.MaxAnchor    = new Vector2F(1.0F, 1.1F);
            mainLb.AutoSize     = true;
            mainLb.Aligns       = TextAligns.Middle;

            WObject error = new WObject("Multi Error Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel errLb = MultiErrorLabel = error.AddModule <LocalizedLabel>();

            errLb.Localization = "#winecrash:error";
            errLb.MinAnchor    = new Vector2F(0.0F, 0.82F);
            errLb.MaxAnchor    = new Vector2F(1.0F, 0.88F);
            errLb.AutoSize     = true;
            errLb.Color        = Color256.Red;
            errLb.Enabled      = false;

            WObject addressTif = new WObject("Multi Address Input")
            {
                Parent = btnPanel
            };

            GUI.LargeTextField taddress = addressTif.AddModule <LargeTextField>();
            taddress.MinAnchor    = new Vector2F(0.0F, 0.7F);
            taddress.MaxAnchor    = new Vector2F(1.0F, 0.8F);
            taddress.Localization = "#winecrash:ui.multiplayer.address";
            taddress.Text         = Game.LastAddress;


            WObject back = new WObject("Multi Back")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnBack = back.AddModule <GUI.SmallButton>();
            btnBack.Button.MinAnchor   = new Vector2F(0.0F, 0.5F);
            btnBack.Button.MaxAnchor   = new Vector2F(0.45F, 0.6F);
            btnBack.Label.Localization = "#winecrash:ui.back";
            btnBack.Button.OnClick    += () =>
            {
                HideMulti();
                ShowMain();
            };

            WObject connect = new WObject("Multi Connect")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnConnect = connect.AddModule <GUI.SmallButton>();
            btnConnect.Button.MinAnchor   = new Vector2F(0.55F, 0.5F);
            btnConnect.Button.MaxAnchor   = new Vector2F(1.0F, 0.6F);
            btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connect";

            void ShowConnectError(string reason)
            {
                errLb.LocalizationArgs = new[] { reason };
                errLb.Localization     = "#winecrash:error";
                errLb.Enabled          = true;
            }

            btnConnect.Button.OnClick += () =>
            {
                Task.Run(() =>
                {
                    errLb.LocalizationArgs = null;
                    errLb.Enabled          = false;

                    string address = "localhost";
                    int port       = Networking.DefaultPort;

                    string input     = taddress.Text;
                    Game.LastAddress = input;

                    if (string.IsNullOrEmpty(input) | string.IsNullOrWhiteSpace(input))
                    {
                        ShowConnectError(Game.Language.GetText("#winecrash:error.noaddress"));
                        return;
                    }

                    int separatorPos = input.IndexOf(':');
                    if (separatorPos > 0) // custom port
                    {
                        address = input.Substring(0, separatorPos);

                        if (int.TryParse(input.Substring(separatorPos + 1, input.Length - 1 - separatorPos), out port))
                        {
                            if (port < 0 || port > Networking.MaxPort)
                            {
                                ShowConnectError(Game.Language.GetText("#winecrash:error.invalidport"));
                                return;
                            }
                        }
                        else
                        {
                            ShowConnectError(Game.Language.GetText("#winecrash:error.invalidport"));
                            return;
                        }
                    }
                    else
                    {
                        address = input;
                    }

                    btnConnect.Button.Locked      = true;
                    btnBack.Button.Locked         = true;
                    taddress.Locked               = true;
                    btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connecting";

                    try
                    {
                        Program.Client.Connect(address, port);
                        Game.InvokePartyJoined(PartyType.Multiplayer);
                        MainMenu.Hide();
                    }
                    catch (SocketException e)
                    {
                        switch (e.SocketErrorCode)
                        {
                        case SocketError.HostNotFound:
                            ShowConnectError(Game.Language.GetText("#winecrash:error.socket.hostnotfound"));
                            break;

                        case SocketError.ConnectionRefused:
                            ShowConnectError(Game.Language.GetText("#winecrash:error.socket.connectionrefused"));
                            break;

                        case SocketError.TryAgain:
                            ShowConnectError(Game.Language.GetText(("#winecrash:error.socket.tryagain")));
                            break;

                        default:
                            ShowConnectError(e.Message);
                            break;
                        }
                    }
                    finally
                    {
                        btnConnect.Button.Locked      = false;
                        btnBack.Button.Locked         = false;
                        taddress.Locked               = false;
                        btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connect";
                    }
                });
            };
        }
示例#27
0
        public static void CreateOptions()
        {
            WObject panel = OptionPanel = new WObject("Main Menu Options")
            {
                Parent = MenuWobject
            };

            /*Image bgFullScreen = OptionPanel.AddModule<Image>();
             * bgFullScreen.Color = Color256.DarkGray * new Color256(1.0, 1.0, 1.0, 0.75);*/

            Image mainPanel = panel.AddModule <Image>();

            mainPanel.Color     = Color256.White * 0.0;//new Color256(1.0, 1.0, 1.0, 0.4);
            mainPanel.MinAnchor = new Vector2D(0.2, 0.05D);
            mainPanel.MaxAnchor = new Vector2D(0.8, 0.95D);
            mainPanel.MinSize   = new Vector3D(800.0D, 400.0D, double.NegativeInfinity);


            WObject tabsPanelWobj = new WObject("Options tab panel")
            {
                Parent = panel
            };
            Image tabsPanel = tabsPanelWobj.AddModule <Image>();

            tabsPanel.MinAnchor = new Vector2D(0.0, 0.85);
            tabsPanel.MaxAnchor = new Vector2D(1.0, 1.0);
            tabsPanel.Color     = new Color256(1.0, 1.0, 1.0, .0);

            WObject backOptions = new WObject("Back Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.TinyButton btnBack = backOptions.AddModule <GUI.TinyButton>();
            btnBack.Button.MinAnchor  = new Vector2D(0.0, 0.0);
            btnBack.Button.MaxAnchor  = new Vector2D(0.06, 1.0);
            btnBack.Button.Label.Text = "<";
            btnBack.Button.OnClick   += () => ShowMain();

            WObject gameOptions = new WObject("Game Options Panel")
            {
                Parent = panel
            };
            Image gameOptionsPanel = gameOptions.AddModule <Image>();

            gameOptionsPanel.MinAnchor = new Vector2D(0.0, 0.0);
            gameOptionsPanel.MaxAnchor = new Vector2D(1.0, 0.85);
            gameOptionsPanel.Color     = Color256.White;

            WObject gameOptionsTab = new WObject("Game Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnGame = gameOptionsTab.AddModule <GUI.SmallButton>();
            btnGame.Button.MinAnchor  = new Vector2D(WMath.Remap(0.00, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnGame.Button.MaxAnchor  = new Vector2D(WMath.Remap(0.30, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnGame.Button.Label.Text = "#winecrash:ui.settings.game";
            btnGame.Button.OnClick   += () =>
            {
                gameOptions.Enabled = true;
            };



            WObject controlsOptionsTab = new WObject("Controls Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnCtrls = controlsOptionsTab.AddModule <GUI.SmallButton>();
            btnCtrls.Button.MinAnchor  = new Vector2D(WMath.Remap(0.35, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnCtrls.Button.MaxAnchor  = new Vector2D(WMath.Remap(0.65, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnCtrls.Button.Label.Text = "#winecrash:ui.settings.inputs";

            WObject videoOptionsTab = new WObject("Controls Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnVideo = videoOptionsTab.AddModule <GUI.SmallButton>();
            btnVideo.Button.MinAnchor  = new Vector2D(WMath.Remap(0.70, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnVideo.Button.MaxAnchor  = new Vector2D(WMath.Remap(1.00, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnVideo.Button.Label.Text = "#winecrash:ui.settings.video";
        }
示例#28
0
        protected override void Creation()
        {
            Mesh   quad   = Mesh.LoadFile("assets/models/Quad.obj", MeshFormats.Wavefront);
            Shader shader = Shader.Find("Unlit");

            Task.Run(() =>
            {
                ForwardPlane               = new WObject("Menu BG Forward Plane");
                ForwardPlane.Parent        = this.WObject;
                ForwardPlane.LocalPosition = Vector3D.Forward * 0.5D;
                ForwardPlane.LocalRotation = new Quaternion(0, 90, 0);
                MeshRenderer mr            = ForwardPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+z.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                BackwardPlane               = new WObject("Menu BG Backward Plane");
                BackwardPlane.Parent        = this.WObject;
                BackwardPlane.LocalPosition = Vector3D.Backward * 0.5D;
                BackwardPlane.LocalRotation = new Quaternion(0, -90, 0);
                MeshRenderer mr             = BackwardPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-z.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                UpPlane               = new WObject("Menu BG Up Plane");
                UpPlane.Parent        = this.WObject;
                UpPlane.LocalPosition = Vector3D.Up * 0.5D;
                UpPlane.LocalRotation = new Quaternion(0, 90, -90);
                MeshRenderer mr       = UpPlane.AddModule <MeshRenderer>();
                mr.Mesh               = quad;
                mr.Material           = new Material(Shader.Find("Unlit"));
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+y.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
            Task.Run(() =>
            {
                DownPlane               = new WObject("Menu BG Down Plane");
                DownPlane.Parent        = this.WObject;
                DownPlane.LocalPosition = Vector3D.Down * 0.5D;
                DownPlane.LocalRotation = new Quaternion(180, -90, -90);
                MeshRenderer mr         = DownPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-y.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                EastPlane               = new WObject("Menu BG East Plane");
                EastPlane.Parent        = this.WObject;
                EastPlane.LocalPosition = Vector3D.Left * 0.5D;
                EastPlane.LocalRotation = new Quaternion(0, 0, 0);
                MeshRenderer mr         = EastPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+x.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
            Task.Run(() =>
            {
                WestPlane               = new WObject("Menu BG West Plane");
                WestPlane.Parent        = this.WObject;
                WestPlane.LocalPosition = Vector3D.Right * 0.5D;
                WestPlane.LocalRotation = new Quaternion(0, 180, 0);
                MeshRenderer mr         = WestPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-x.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
        }
 //////////////////////////////////////////////////////////////////////////
 private void DeleteEditorProps(WObject Obj)
 {
     Obj.DeleteEditorProp("OrigX");
     Obj.DeleteEditorProp("OrigY");
     Obj.DeleteEditorProp("OrigWidth");
     Obj.DeleteEditorProp("OrigHeight");
 }
示例#30
0
 public static extern int InsertWipeObject(int context, ref WObject wipeObject);
        //////////////////////////////////////////////////////////////////////////
        string GetIconKey(WObject Obj)
        {
            if (LayoutTree == null || LayoutTree.ImageList == null) return "";

            ImageList Img = LayoutTree.ImageList;
            if (Obj is WUIWindow) return "window";
            else if (Obj is WUIButton) return "button";
            else if (Obj is WUIEdit) return "editor";
            else if (Obj is WUIStatic) return "static";
            else if (Obj is WUIEntity) return "entity";
            else return "box";
        }
示例#32
0
        public static void CreateDisconnection()
        {
            WObject mainPanel = MultiDisconnectionPanel = new WObject("Multi Disconnect UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject multiTitle = new WObject("Multi Main Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel mainLb = multiTitle.AddModule <LocalizedLabel>();

            mainLb.Localization = "#winecrash:ui.multiplayer.disconnected";
            mainLb.MinAnchor    = new Vector2F(0.0F, 1.0F);
            mainLb.MaxAnchor    = new Vector2F(1.0F, 1.1F);
            mainLb.AutoSize     = true;
            mainLb.Aligns       = TextAligns.Middle;

            WObject error = new WObject("Multi Disconnected Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel reaLb = MultiDisconnectionReason = error.AddModule <LocalizedLabel>();

            reaLb.Localization = "#server_disconnection_unspecified";
            reaLb.MinAnchor    = new Vector2F(0.0F, 0.82F);
            reaLb.MaxAnchor    = new Vector2F(1.0F, 0.88F);
            reaLb.AutoSize     = true;
            reaLb.Aligns       = TextAligns.Up | TextAligns.Vertical;

            WObject back = new WObject("Multi Back")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnBack = back.AddModule <GUI.LargeButton>();
            btnBack.Button.MinAnchor   = new Vector2F(0.0F, 0.6F);
            btnBack.Button.MaxAnchor   = new Vector2F(1.0F, 0.7F);
            btnBack.Label.Localization = "#winecrash:ui.back";
            btnBack.Button.OnClick    += () =>
            {
                HideDisconnection();
                ShowMain();
            };
        }
示例#33
0
        private static void CreateMain()
        {
            WObject mainPanel = MainMenuPanel = new WObject("Main UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject logo = new WObject("Game Text Logo")
            {
                Parent = mainPanel
            };
            Image logoImage = logo.AddModule <Image>();

            logoImage.Picture   = new Texture("assets/textures/logo.png");
            logoImage.MinAnchor = new Vector2F(0.0F, 0.8F);
            logoImage.MaxAnchor = new Vector2F(1.0F, 1.0F);
            logoImage.KeepRatio = true;

            Label lbTip = mainPanel.AddModule <Label>();

            lbTip.ParentGUI = logoImage;
            lbTip.Text      = "Minecraft";
            lbTip.Color     = new Color256(1.0, 1.0, 0.0, 1.0);
            lbTip.Aligns    = TextAligns.Middle;
            lbTip.AutoSize  = true;
            lbTip.MinAnchor = new Vector2F(0.7F, 0.0F);
            lbTip.MaxAnchor = new Vector2F(1.1F, 0.4F);
            lbTip.Rotation  = -20.0D;


            MenuTip tip = MenuWobject.AddModule <MenuTip>();

            tip.ReferenceLabel = lbTip;
            lbTip.Text         = tip.SelectRandom();


            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject single = new WObject("Singleplayer Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnSingle = single.AddModule <GUI.LargeButton>();
            btnSingle.Button.MinAnchor   = new Vector2F(0.0F, 0.9F);
            btnSingle.Button.MaxAnchor   = new Vector2F(1.0F, 1.0F);
            btnSingle.Label.Localization = "#winecrash:ui.mainmenu.singleplayer";
            btnSingle.Button.Locked      = false;
            //btnSingle.Button.OnClick += () => { Graphics.Window.InvokeUpdate(() => Program.RunGameDebug()); };
            btnSingle.Button.OnClick += () =>
            {
                Game.InvokePartyJoined(PartyType.Singleplayer);
                Task.Run(() =>
                {
                    //Parallel.ForEach()
                    //IntegratedServer server = IntegratedServer.CurrentIntegratedServer = new IntegratedServer(new Player("Arthur"));
                    //server.Run();
                });
            };

            WObject mult = new WObject("Multiplayer Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnMult = mult.AddModule <GUI.LargeButton>();
            btnMult.Button.MinAnchor   = new Vector2F(0.0F, 0.7F);
            btnMult.Button.MaxAnchor   = new Vector2F(1.0F, 0.8F);
            btnMult.Label.Localization = "#winecrash:ui.mainmenu.multiplayer";
            btnMult.Button.Locked      = true;
            btnMult.Button.OnClick    += () =>
            {
                ShowMulti();
            };

            WObject mods = new WObject("Mods Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnMods = mods.AddModule <GUI.LargeButton>();
            btnMods.Button.MinAnchor   = new Vector2F(0.0F, 0.5F);
            btnMods.Button.MaxAnchor   = new Vector2F(1.0F, 0.6F);
            btnMods.Label.Localization = "#winecrash:ui.mainmenu.addons";
            btnMods.Button.Locked      = true;

            WObject options = new WObject("Options Button")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnOptions = options.AddModule <GUI.SmallButton>();
            btnOptions.Button.MinAnchor   = new Vector2F(0.0F, 0.2F);
            btnOptions.Button.MaxAnchor   = new Vector2F(0.45F, 0.3F);
            btnOptions.Label.Localization = "#winecrash:ui.mainmenu.settings";
            btnOptions.Button.OnClick    += () => ShowOptions();
            btnOptions.Button.Locked      = false;

            WObject quit = new WObject("Quit Button")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnQuit = quit.AddModule <GUI.SmallButton>();
            btnQuit.Button.MinAnchor   = new Vector2F(0.55F, 0.2F);
            btnQuit.Button.MaxAnchor   = new Vector2F(1.0F, 0.3F);
            btnQuit.Label.Localization = "#winecrash:ui.mainmenu.quit";
            btnQuit.Button.OnClick    += () => Engine.Stop();
        }
 //////////////////////////////////////////////////////////////////////////
 public NativePropProxy(WObject NativeObject)
 {
     _NativeObject = NativeObject;
 }