Esempio n. 1
0
        public TitleWorld(
            I2DRenderUtilities twodRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IBackgroundCubeEntityFactory backgroundCubeEntityFactory,
            ISkin skin)
            : base(twodRenderUtilities, assetManagerProvider, backgroundCubeEntityFactory, skin)
        {
            this.Title = this.AssetManager.Get<LanguageAsset>("language.TYCHAIA");

            this.AddMenuItem(
                this.AssetManager.Get<LanguageAsset>("language.SINGLEPLAYER"),
                () =>
                {
                    this.TargetWorld = this.GameContext.CreateWorld<IWorldFactory>(x => x.CreateConnectWorld(true, GetLANIPAddress(), 9091));
                });
            this.AddMenuItem(
                this.AssetManager.Get<LanguageAsset>("language.MULTIPLAYER"),
                () =>
                {
                    this.TargetWorld = this.GameContext.CreateWorld<IWorldFactory>(x => x.CreateMultiplayerWorld());
                });
            this.AddMenuItem(
                this.AssetManager.Get<LanguageAsset>("language.EXIT"),
                () =>
                {
                    if (this.GameContext != null)
                        this.GameContext.Game.Exit();
                });
        }
Esempio n. 2
0
 /// <summary>
 /// The update.
 /// </summary>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <param name="gameTime">
 /// The game time.
 /// </param>
 /// <param name="stealFocus">
 /// The steal focus.
 /// </param>
 public override void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
 {
     foreach (var kv in this.GetChildLocations(skin, layout))
     {
         kv.Key.Update(skin, kv.Value, gameTime, ref stealFocus);
     }
 }
Esempio n. 3
0
        public InventoryUIEntity(
            IGameUIFactory gameUIFactory,
            IViewportMode viewportMode,
            ISkin skin)
            : base(skin)
        {
            this.m_ViewportMode = viewportMode;
            this.SidebarWidth = 300;

            this.m_InventoryManager = gameUIFactory.CreateInventoryManager();

            this.m_SplitHorizontal = new HorizontalContainer();
            this.m_LeftBar = gameUIFactory.CreateLeftBar();
            this.m_CentreContainer = new VerticalContainer();
            this.m_RightBar = gameUIFactory.CreateRightBar();
            this.m_StatusBarSpacing = new HorizontalContainer();
            this.m_StatusBar = gameUIFactory.CreateStatusBar();

            this.m_RightBar.SetChild(this.m_InventoryManager);

            this.m_SplitHorizontal.AddChild(this.m_LeftBar, "0");
            this.m_SplitHorizontal.AddChild(this.m_CentreContainer, "*");
            this.m_SplitHorizontal.AddChild(this.m_RightBar, "0");
            this.m_StatusBarSpacing.AddChild(new EmptyContainer(), "*");
            this.m_StatusBarSpacing.AddChild(this.m_StatusBar, "640");
            this.m_StatusBarSpacing.AddChild(new EmptyContainer(), "*");
            this.m_CentreContainer.AddChild(new EmptyContainer(), "*");
            this.m_CentreContainer.AddChild(this.m_StatusBarSpacing, "64");

            this.Canvas = new Canvas();
            this.Canvas.SetChild(this.m_SplitHorizontal);
        }
Esempio n. 4
0
 /// <summary>
 /// The draw.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
 {
     skin.DrawFixedContainer(context, layout, this);
     if (this.Child != null)
     {
         this.Child.Draw(context, skin, this.AbsoluteRectangle);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// The draw.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 public override void Draw(IRenderContext context, ISkin skin, Rectangle layout)
 {
     skin.DrawHorizontalContainer(context, layout, this);
     foreach (var kv in this.ChildrenWithLayouts(layout).OrderByDescending(x => x.Key.Order))
     {
         kv.Key.Draw(context, skin, kv.Value);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// The draw.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 public override void Draw(IRenderContext context, ISkin skin, Rectangle layout)
 {
     skin.DrawMainMenu(context, layout, this);
     foreach (var kv in this.GetChildLocations(skin, layout))
     {
         kv.Key.Draw(context, skin, kv.Value);
     }
 }
Esempio n. 7
0
        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List<IEntity>();

            var startServer = new Button();
            startServer.Text = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();
            joinGame.Text = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();
            exitGame.Text = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Perspective" }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Server IP address:" }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();
            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
Esempio n. 8
0
        /// <summary>
        /// Requests that the UI container handle the specified event or return false.
        /// </summary>
        /// <param name="skin">
        /// The UI skin.
        /// </param>
        /// <param name="layout">
        /// The layout for the element.
        /// </param>
        /// <param name="context">
        /// The current game context.
        /// </param>
        /// <param name="event">
        /// The event that was raised.
        /// </param>
        /// <returns>
        /// Whether or not this UI element handled the event.
        /// </returns>
        public bool HandleEvent(ISkin skin, Rectangle layout, IGameContext context, Event @event)
        {
            if (this.Child != null)
            {
                return this.Child.HandleEvent(skin, this.AbsoluteRectangle, context, @event);
            }

            return false;
        }
Esempio n. 9
0
        public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            if (context.Is3DContext)
                return;

            this.m_2DRenderUtilities.RenderRectangle(
                context,
                layout,
                Color.Yellow,
                filled: true);
        }
Esempio n. 10
0
 protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func <ISkin> getBeatmapSkin)
 {
     CreateTest(() =>
     {
         AddStep("setup skins", () =>
         {
             skinManager.CurrentSkinInfo.Value = gameCurrentSkin.ToLiveUnmanaged();
             currentBeatmapSkin = getBeatmapSkin();
         });
     });
 }
Esempio n. 11
0
        private Drawable setupSkinHierarchy(Drawable child, ISkin skin)
        {
            var legacySkinProvider    = new SkinProvidingContainer(skins.GetSkin(DefaultLegacySkin.Info));
            var testSkinProvider      = new SkinProvidingContainer(skin);
            var legacySkinTransformer = new SkinProvidingContainer(new CatchLegacySkinTransformer(testSkinProvider));

            return(legacySkinProvider
                   .WithChild(testSkinProvider
                              .WithChild(legacySkinTransformer
                                         .WithChild(child))));
        }
Esempio n. 12
0
        private static Texture getAnimationFrame(ISkin skin, TaikoMascotAnimationState state, int frameIndex)
        {
            var texture = skin.GetTexture($"pippidon{state.ToString().ToLower()}{frameIndex}");

            if (frameIndex == 0 && texture == null)
            {
                texture = skin.GetTexture($"pippidon{state.ToString().ToLower()}");
            }

            return(texture);
        }
Esempio n. 13
0
        /// <summary>
        /// Requests that the UI container handle the specified event or return false.
        /// </summary>
        /// <param name="skin">
        /// The UI skin.
        /// </param>
        /// <param name="layout">
        /// The layout for the element.
        /// </param>
        /// <param name="context">
        /// The current game context.
        /// </param>
        /// <param name="event">
        /// The event that was raised.
        /// </param>
        /// <returns>
        /// Whether or not this UI element handled the event.
        /// </returns>
        public bool HandleEvent(ISkin skin, Rectangle layout, IGameContext context, Event @event)
        {
            foreach (var kv in this.ChildrenWithLayouts(layout))
            {
                if (kv.Key.HandleEvent(skin, kv.Value, context, @event))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 14
0
        public ManiaLegacySkinTransformer(ISkin skin, IBeatmap beatmap)
            : base(skin)
        {
            this.beatmap = (ManiaBeatmap)beatmap;

            isLegacySkin  = new Lazy <bool>(() => GetConfig <SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null);
            hasKeyTexture = new Lazy <bool>(() =>
            {
                string keyImage = this.GetManiaSkinConfig <string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value ?? "mania-key1";
                return(this.GetAnimation(keyImage, true, true) != null);
            });
        }
Esempio n. 15
0
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        /// <param name="stealFocus">
        /// The steal focus.
        /// </param>
        public void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
        {
            if (this.m_Child != null)
            {
                this.m_Child.Update(skin, layout, gameTime, ref stealFocus);
            }

            if (this.Modal)
            {
                stealFocus = true;
            }
        }
Esempio n. 16
0
        public EditorBeatmap(IBeatmap playableBeatmap, ISkin beatmapSkin = null)
        {
            PlayableBeatmap = playableBeatmap;
            BeatmapSkin     = beatmapSkin;

            beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);

            foreach (var obj in HitObjects)
            {
                trackStartTime(obj);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Creates a new <see cref="LegacyBeatmapEncoder"/>.
        /// </summary>
        /// <param name="beatmap">The beatmap to encode.</param>
        /// <param name="skin">The beatmap's skin, used for encoding combo colours.</param>
        public LegacyBeatmapEncoder(IBeatmap beatmap, [CanBeNull] ISkin skin)
        {
            this.beatmap = beatmap;
            this.skin    = skin;

            onlineRulesetID = beatmap.BeatmapInfo.Ruleset.OnlineID;

            if (onlineRulesetID < 0 || onlineRulesetID > 3)
            {
                throw new ArgumentException("Only beatmaps in the osu, taiko, catch, or mania rulesets can be encoded to the legacy beatmap format.", nameof(beatmap));
            }
        }
Esempio n. 18
0
        public TvControl(ISkin skin, IViewport viewport, TState initialState, string name = null)
        {
            _component = new TvComponent <TState>(initialState, name ?? $"TvControl_<$>");
            Metadata   = new TvControlMetadata(this, _component.ComponentId);
            var typename   = GetType().Name.ToLowerInvariant();
            var genericIdx = typename.IndexOf('`');

            ControlType  = genericIdx != -1 ? typename.Substring(0, genericIdx) : typename;
            CurrentStyle = skin.GetControlStyle(this);
            State        = initialState;
            _component.AddViewport(viewport);
            AddElements();
        }
        public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin)
        {
            Ruleset = ruleset;
            Beatmap = beatmap;

            InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin is LegacySkin ? GetLegacyRulesetTransformedSkin(beatmapSkin) : beatmapSkin)
            {
                Child = Content = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };
        }
Esempio n. 20
0
        public override void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            if (!context.Is3DContext)
            {
                this.m_2DRenderUtilities.RenderRectangle(
                    context,
                    layout,
                    Color.Green,
                    filled: true);
            }

            base.Draw(context, skin, layout);
        }
Esempio n. 21
0
 public Visualizer(ISkin actualSkin, AudioPlayer player, PlayerProperties properties)
 {
     this.actualSkin                  = actualSkin;
     this.player                      = player;
     this.properties                  = properties;
     player.actualSkin                = this.actualSkin;
     player.properties                = this.properties;
     player.playerStarted            += Messenger;
     player.songListChanged          += Messenger;
     player.songStarted              += Messenger;
     player.properties.playerLocked  += Messenger;
     player.properties.volumeChanged += Messenger;
 }
Esempio n. 22
0
        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            skin.DrawForm(context, layout, this);
            foreach (var kv in this.LabelsWithLayouts(layout))
            {
                kv.Key.Draw(context, skin, kv.Value);
            }

            foreach (var kv in this.ChildrenWithLayouts(layout))
            {
                kv.Key.Draw(context, skin, kv.Value);
            }
        }
Esempio n. 23
0
        public virtual void Delete(long id)
        {
            ISkin skin = skinService.GetById(id, ctx.owner.obj.Id);

            if (skin == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            skinService.Delete(skin);
            redirect(My);
        }
Esempio n. 24
0
        public SkinProvidingContainer(ISkin skin)
        {
            this.skin = skin;

            RelativeSizeAxes = Axes.Both;

            noFallbackLookupProxy = new NoFallbackProxy(this);

            if (skin is ISkinSource source)
            {
                source.SourceChanged += TriggerSourceChanged;
            }
        }
Esempio n. 25
0
 public void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
 {
     var buttonLayout = new Rectangle(
         layout.Center.X - 100,
         layout.Bottom - (this.m_Children.Count * 75) - 30,
         200,
         50);
     foreach (var button in this.m_Children)
     {
         button.Update(skin, buttonLayout, gameTime, ref stealFocus);
         buttonLayout.Y += 75;
     }
 }
Esempio n. 26
0
 public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
 {
     var buttonLayout = new Rectangle(
         layout.Center.X - 100,
         layout.Bottom - (this.m_Children.Count * 75) - 30,
         200,
         50);
     foreach (var button in this.m_Children)
     {
         button.Draw(context, skin, buttonLayout);
         buttonLayout.Y += 75;
     }
 }
Esempio n. 27
0
        public static Drawable GetAnimation(this ISkin source, string componentName, WrapMode wrapModeS, WrapMode wrapModeT, bool animatable, bool looping, bool applyConfigFrameRate = false,
                                            string animationSeparator = "-",
                                            bool startAtCurrentTime   = true, double?frameLength = null)
        {
            Texture texture;

            if (animatable)
            {
                var textures = getTextures().ToArray();

                if (textures.Length > 0)
                {
                    var animation = new SkinnableTextureAnimation(startAtCurrentTime)
                    {
                        DefaultFrameLength = frameLength ?? getFrameLength(source, applyConfigFrameRate, textures),
                        Loop = looping,
                    };

                    foreach (var t in textures)
                    {
                        animation.AddFrame(t);
                    }

                    return(animation);
                }
            }

            // if an animation was not allowed or not found, fall back to a sprite retrieval.
            if ((texture = source.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
            {
                return new Sprite {
                           Texture = texture
                }
            }
            ;

            return(null);

            IEnumerable <Texture> getTextures()
            {
                for (int i = 0; true; i++)
                {
                    if ((texture = source.GetTexture($"{componentName}{animationSeparator}{i}", wrapModeS, wrapModeT)) == null)
                    {
                        break;
                    }

                    yield return(texture);
                }
            }
        }
        public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, string animationSeparator = "-")
        {
            const double default_frame_time = 1000 / 60d;

            Texture texture;

            Texture getFrameTexture(int frame) => source.GetTexture($"{componentName}{animationSeparator}{frame}");

            TextureAnimation animation = null;

            if (animatable)
            {
                for (int i = 0;; i++)
                {
                    if ((texture = getFrameTexture(i)) == null)
                    {
                        break;
                    }

                    if (animation == null)
                    {
                        animation = new TextureAnimation
                        {
                            DefaultFrameLength = default_frame_time,
                            Repeat             = looping
                        }
                    }
                    ;

                    animation.AddFrame(texture);
                }
            }

            if (animation != null)
            {
                return(animation);
            }

            if ((texture = source.GetTexture(componentName)) != null)
            {
                return new Sprite
                       {
                           Texture = texture
                       }
            }
            ;

            return(null);
        }
    }
}
Esempio n. 29
0
        public LegacyScoreCounter(ISkin skin)
            : base(6)
        {
            Anchor = Anchor.TopRight;
            Origin = Anchor.TopRight;

            this.skin = skin;

            // base class uses int for display, but externally we bind to ScoreProcessor as a double for now.
            Current.BindValueChanged(v => base.Current.Value = (int)v.NewValue);

            Scale  = new Vector2(0.96f);
            Margin = new MarginPadding(10);
        }
Esempio n. 30
0
        private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNoteLayer layer)
        {
            return(new LayerContainer
            {
                RelativeSizeAxes = Axes.Both,
                Name = name,
                Children = new[]
                {
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Head";
                        d.Anchor = Anchor.CentreLeft;
                        d.Origin = Anchor.Centre;
                    }),
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Body";
                        d.Anchor = Anchor.Centre;
                        d.Origin = Anchor.Centre;
                        d.Size = Vector2.One;
                        d.FillMode = FillMode.Stretch;
                        d.RelativeSizeAxes = Axes.X;
                        d.Depth = 1;

                        d.Height = d.Texture?.DisplayHeight ?? 0;
                    }),
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Tail";
                        d.Anchor = Anchor.CentreRight;
                        d.Origin = Anchor.Centre;
                    }),
                }
            });
        }
Esempio n. 31
0
 /// <summary>
 /// The update.
 /// </summary>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <param name="gameTime">
 /// The game time.
 /// </param>
 /// <param name="stealFocus">
 /// The steal focus.
 /// </param>
 public void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
 {
     this.m_ToggleButton.Update(
         skin,
         new Rectangle(layout.X, layout.Y, layout.Width, 24),
         gameTime,
         ref stealFocus);
     if (this.m_Instance != null && this.m_Instance.State == SoundState.Stopped)
     {
         this.m_ToggleButton.Text = "Play";
         this.m_Instance.Stop();
         this.m_Instance = null;
     }
 }
        private static double getFrameLength(ISkin source, bool applyConfigFrameRate, Texture[] textures)
        {
            if (applyConfigFrameRate)
            {
                var iniRate = source.GetConfig<LegacySetting, int>(LegacySetting.AnimationFramerate);

                if (iniRate?.Value > 0)
                    return 1000f / iniRate.Value;

                return 1000f / textures.Length;
            }

            return default_frame_time;
        }
Esempio n. 33
0
        //---------------------------------------------------------------------------------------

        public void ApplySystemSkin(IMember member, int skinId)
        {
            member.TemplateId = skinId;
            db.update(member, "TemplateId");

            // 清空自定义设置
            ISkin customSkin = getByMember(member.Id);

            if (customSkin != null)
            {
                customSkin.Body = "";
                db.update(customSkin, "Body");
            }
        }
Esempio n. 34
0
        public void InitTiles(int[,] data, ISkin skin)
        {
            List <TileUserControl> list = new List <TileUserControl>();

            for (int i = 0; i < data.Length; i++)
            {
                TileUserControl con = new TileUserControl(skin)
                {
                    Dock = DockStyle.Fill
                };
                list.Add(con);
            }
            controls = list.ToArray();
            tableLayoutPanel1.Controls.AddRange(controls);
        }
Esempio n. 35
0
        /// <summary>
        /// The get children with layouts.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{TreeEntry}"/>.
        /// </returns>
        public IEnumerable <TreeEntry> GetChildrenWithLayouts(ISkin skin, Rectangle layout)
        {
            var tree = this.BuildEntryGraph(layout);
            var list = this.NormalizeTree(tree, true);

            for (var i = 0; i < list.Count; i++)
            {
                list[i].Layout = new Rectangle(
                    layout.X + (list[i].SegmentCount - 1) * skin.HeightForTreeItem,
                    layout.Y + i * skin.HeightForTreeItem,
                    layout.Width - (list[i].SegmentCount - 1) * skin.HeightForTreeItem,
                    skin.HeightForTreeItem);
                yield return(list[i]);
            }
        }
Esempio n. 36
0
        public static Piece GetPiece(this ISkin skin, TileType type)
        {
            if (type == TileType.Empty)
            {
                return(null);
            }

            var res = skin.Pieces.FirstOrDefault(x => x != null && x.TileTypes.Contains(type));//?.First();

            if (res == null)
            {
                Debug.LogWarning(Enum.GetName(typeof(TileType), type) + " does not exist in " + skin.Name);
            }
            return(res);
        }
Esempio n. 37
0
        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        public virtual void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            this.TextWidth = (int)Math.Ceiling(skin.MeasureText(context, this.Text).X);
            skin.DrawMenuItem(context, layout, this);

            var childrenLayout = this.GetMenuListLayout(skin, layout);

            if (this.Active && childrenLayout != null)
            {
                skin.DrawMenuList(context, childrenLayout.Value, this);
                foreach (var kv in this.GetMenuChildren(skin, layout))
                {
                    kv.Key.Draw(context, skin, kv.Value);
                }
            }
        }
Esempio n. 38
0
        private static double getFrameLength(ISkin source, bool applyConfigFrameRate, Texture[] textures)
        {
            if (applyConfigFrameRate)
            {
                var iniRate = source.GetConfig <GlobalSkinConfiguration, int>(GlobalSkinConfiguration.AnimationFramerate);

                if (iniRate?.Value > 0)
                {
                    return(1000f / iniRate.Value);
                }

                return(1000f / textures.Length);
            }

            return(default_frame_time);
        }
        protected ISkin GetLegacyRulesetTransformedSkin(ISkin legacySkin)
        {
            if (legacySkin == null)
            {
                return(null);
            }

            var rulesetTransformed = Ruleset.CreateLegacySkinProvider(legacySkin, Beatmap);

            if (rulesetTransformed != null)
            {
                return(rulesetTransformed);
            }

            return(legacySkin);
        }
Esempio n. 40
0
        public String GetUserSkin(IMember user, int queryStringSkinId, String cssVersion)
        {
            int   skinId = getSkinId(user, queryStringSkinId);
            ISkin skin   = GetById(skinId);

            String skinPath = skin.GetSkinPath() + "?v=" + cssVersion;
            String result   = string.Format("<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" />", skinPath);

            if (skin.MemberId > 0)
            {
                result += Environment.NewLine;
                result += string.Format("<style>{0}</style>", skin.Body);
                result += Environment.NewLine;
            }
            return(result);
        }
Esempio n. 41
0
        public virtual void Create()
        {
            ISkin skin = validate(null);

            if (ctx.HasErrors)
            {
                run(Add); return;
            }

            skin.MemberId = ctx.owner.obj.Id;
            //skin.MemberUrl = ctx.owner.obj.Url;
            //skin.MemberName = ctx.owner.obj.Name;

            skinService.Insert(skin);
            redirect(My);
        }
Esempio n. 42
0
        public virtual void Edit(long id)
        {
            target(Update, id);
            set("lnkList", to(My));

            ISkin skin = skinService.GetById(id, ctx.owner.obj.Id);

            if (skin == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            set("skin.Name", skin.Name);
            set("skin.Body", skin.Body);
        }
Esempio n. 43
0
        public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            if (context.Is3DContext)
                return;

            this.m_2DRenderUtilities.RenderRectangle(
                context,
                layout,
                Color.Black,
                filled: true);

            if (this.Player == null)
                return;

            this.RenderBar(
                context,
                layout,
                0,
                this.Player.MaxHealth,
                this.Player.Health,
                Color.Red,
                "No Health");

            this.RenderBar(
                context,
                layout,
                14,
                this.Player.MaxStamina,
                this.Player.Stamina,
                Color.Yellow,
                "No Stamina");

            this.RenderBar(
                context,
                layout,
                28,
                this.Player.MaxMana,
                this.Player.Mana,
                Color.Blue,
                "No Mana");
        }
Esempio n. 44
0
        public MenuWorld(
            I2DRenderUtilities twodRenderUtilities, 
            IAssetManagerProvider assetManagerProvider, 
            IBackgroundCubeEntityFactory backgroundCubeEntityFactory, 
            ISkin skin)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.AssetManager = assetManagerProvider.GetAssetManager();
            this.m_BackgroundCubeEntityFactory = backgroundCubeEntityFactory;
            this.m_TitleFont = this.AssetManager.Get<FontAsset>("font.Title");
            this.m_PlayerModel = this.AssetManager.Get<ModelAsset>("model.Character");
            this.m_PlayerModelTexture = this.AssetManager.Get<TextureAsset>("model.CharacterTex");

            this.Entities = new List<IEntity>();

            this.m_CanvasEntity = new CanvasEntity(skin) { Canvas = new Canvas() };
            this.m_CanvasEntity.Canvas.SetChild(this.m_TitleMenu = new TitleMenu());

            // Don't add the canvas to the entities list; that way we can explicitly
            // order it's depth.
        }
Esempio n. 45
0
        public LoadWorld(
            I2DRenderUtilities twodRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IBackgroundCubeEntityFactory backgroundCubeEntityFactory,
            ILevelAPI levelAPI,
            ISkin skin)
            : base(twodRenderUtilities, assetManagerProvider, backgroundCubeEntityFactory, skin)
        {
            var assetManager = assetManagerProvider.GetAssetManager();
            var returnText = assetManager.Get<LanguageAsset>("language.RETURN");

            this.AddMenuItem(returnText, () => { this.TargetWorld = this.GameContext.CreateWorld<TitleWorld>(); });

            // Get all available levels.
            foreach (var levelRef in levelAPI.GetAvailableLevels())
            {
                this.AddMenuItem(
                    new LanguageAsset(levelRef, levelRef),
                    () => { this.TargetWorld = this.GameContext.CreateWorld<TychaiaGameWorld>(); });
            }
        }
Esempio n. 46
0
        public MultiplayerWorld(ISkin skin)
        {
            this.Entities = new List<IEntity>();

            this.m_ServersListView = new ListView();
            this.m_ServersListView.AddChild(new ServerListItem { Text = "Loading servers...", Valid = false });
            this.m_ServersListView.SelectedItemChanged += this.ServersListViewOnSelectedItemChanged;

            var backButton = new Button { Text = "Back" };
            backButton.Click += (sender, args) => this.m_GameContext.SwitchWorld<TitleWorld>();

            var buttonContainer = new HorizontalContainer();
            buttonContainer.AddChild(new EmptyContainer(), "*");
            buttonContainer.AddChild(backButton, "100");
            buttonContainer.AddChild(new EmptyContainer(), "*");

            var verticalContainer = new VerticalContainer();
            verticalContainer.AddChild(new EmptyContainer(), "*");
            verticalContainer.AddChild(this.m_ServersListView, "370");
            verticalContainer.AddChild(new EmptyContainer(), "10");
            verticalContainer.AddChild(buttonContainer, "24");
            verticalContainer.AddChild(new EmptyContainer(), "*");

            var horizontalContainer = new HorizontalContainer();
            horizontalContainer.AddChild(new EmptyContainer(), "*");
            horizontalContainer.AddChild(verticalContainer, "300");
            horizontalContainer.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontalContainer);

            this.m_CanvasEntity = new CanvasEntity(skin, canvas);

            this.m_QueryServersThread = new Thread(this.QueryServers) { Name = "Query Servers", IsBackground = true };
            this.m_QueryServersThread.Start();
        }
Esempio n. 47
0
 /// <summary>
 /// The update.
 /// </summary>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <param name="gameTime">
 /// The game time.
 /// </param>
 /// <param name="stealFocus">
 /// The steal focus.
 /// </param>
 public void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
 {
     foreach (var kv in this.GetChildrenWithLayouts(skin, layout))
     {
         kv.Item.Update(skin, kv.Layout.Value, gameTime, ref stealFocus);
     }
 }
Esempio n. 48
0
 public int? GetDesiredWidth(ISkin skin)
 {
     return null;
 }
Esempio n. 49
0
        /// <summary>
        /// Requests that the UI container handle the specified event or return false.
        /// </summary>
        /// <param name="skin">
        /// The UI skin.
        /// </param>
        /// <param name="layout">
        /// The layout for the element.
        /// </param>
        /// <param name="context">
        /// The current game context.
        /// </param>
        /// <param name="event">
        /// The event that was raised.
        /// </param>
        /// <returns>
        /// Whether or not this UI element handled the event.
        /// </returns>
        public bool HandleEvent(ISkin skin, Rectangle layout, IGameContext context, Event @event)
        {
            foreach (var kv in this.GetChildrenWithLayouts(skin, layout))
            {
                if (kv.Item.HandleEvent(skin, kv.Layout.Value, context, @event))
                {
                    return true;
                }
            }

            var keyPressEvent = @event as KeyPressEvent;
            if (keyPressEvent != null)
            {
                var upPressed = keyPressEvent.Key == Keys.Up;
                var downPressed = keyPressEvent.Key == Keys.Down;
                if (this.SelectedItem != null && (upPressed || downPressed))
                {
                    var list = this.m_Items.Select(x => new ListEntry { Item = x }).ToList();
                    var current = list.IndexOf(list.First(x => this.SelectedItem == x.Item));
                    if (upPressed)
                    {
                        current -= 1;
                    }
                    else if (downPressed)
                    {
                        current += 1;
                    }

                    if (current >= 0 && current < list.Count)
                    {
                        this.SelectedItem = list[current].Item;

                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 50
0
        /// <summary>
        /// The get children with layouts.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        public IEnumerable<ListEntry> GetChildrenWithLayouts(ISkin skin, Rectangle layout)
        {
            var list = this.m_Items.Select(x => new ListEntry { Item = x }).ToList();
            var current = layout.Y;
            for (var i = 0; i < list.Count; i++)
            {
                list[i].Layout = new Rectangle(
                    layout.X + skin.ListHorizontalPadding,
                    current + skin.ListVerticalPadding,
                    layout.Width - skin.ListHorizontalPadding * 2,
                    skin.HeightForTreeItem);
                yield return list[i];

                var desiredSize = list[i].Item as IHasDesiredSize;
                if (desiredSize != null && desiredSize.GetDesiredHeight(skin) != null)
                {
                    current += desiredSize.GetDesiredHeight(skin).Value;
                }
                else
                {
                    current += skin.HeightForTreeItem;
                }
            }
        }
Esempio n. 51
0
 public int? GetDesiredHeight(ISkin skin)
 {
     var current = 0;
     foreach (var item in this.m_Items)
     {
         var desiredSize = item as IHasDesiredSize;
         if (desiredSize != null && desiredSize.GetDesiredHeight(skin) != null)
         {
             current += desiredSize.GetDesiredHeight(skin).Value;
         }
         else
         {
             current += skin.HeightForTreeItem;
         }
     }
     return current;
 }
Esempio n. 52
0
 /// <summary>
 /// The get children with layouts.
 /// </summary>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{TreeEntry}"/>.
 /// </returns>
 public IEnumerable<TreeEntry> GetChildrenWithLayouts(ISkin skin, Rectangle layout)
 {
     var tree = this.BuildEntryGraph(layout);
     var list = this.NormalizeTree(tree, true);
     for (var i = 0; i < list.Count; i++)
     {
         list[i].Layout = new Rectangle(
             layout.X + (list[i].SegmentCount - 1) * skin.HeightForTreeItem,
             layout.Y + i * skin.HeightForTreeItem,
             layout.Width - (list[i].SegmentCount - 1) * skin.HeightForTreeItem,
             skin.HeightForTreeItem);
         yield return list[i];
     }
 }
Esempio n. 53
0
 /// <summary>
 /// The draw.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="skin">
 /// The skin.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 public void Draw(IRenderContext context, ISkin skin, Rectangle layout)
 {
     skin.DrawListView(context, layout, this);
     foreach (var kv in this.GetChildrenWithLayouts(skin, layout))
     {
         kv.Item.Draw(context, skin, kv.Layout.Value);
     }
 }
Esempio n. 54
0
        /// <summary>
        /// The get active children layouts.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        public IEnumerable<Rectangle> GetActiveChildrenLayouts(ISkin skin, Rectangle layout)
        {
            yield return layout;
            if (!this.Active)
            {
                yield break;
            }

            var childrenLayout = this.GetMenuListLayout(skin, layout);
            if (childrenLayout == null)
            {
                yield break;
            }

            yield return childrenLayout.Value;
            foreach (var kv in this.GetMenuChildren(skin, layout))
            {
                foreach (var childLayout in kv.Key.GetActiveChildrenLayouts(skin, kv.Value))
                {
                    yield return childLayout;
                }
            }
        }
Esempio n. 55
0
        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        public virtual void Draw(IRenderContext context, ISkin skin, Rectangle layout)
        {
            this.TextWidth = (int)Math.Ceiling(skin.MeasureText(context, this.Text).X);
            skin.DrawMenuItem(context, layout, this);

            var childrenLayout = this.GetMenuListLayout(skin, layout);
            if (this.Active && childrenLayout != null)
            {
                skin.DrawMenuList(context, childrenLayout.Value, this);
                foreach (var kv in this.GetMenuChildren(skin, layout))
                {
                    kv.Key.Draw(context, skin, kv.Value);
                }
            }
        }
Esempio n. 56
0
        /// <summary>
        /// The get menu children.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        public IEnumerable<KeyValuePair<MenuItem, Rectangle>> GetMenuChildren(ISkin skin, Rectangle layout)
        {
            var childLayout = this.GetMenuListLayout(skin, layout);
            if (childLayout == null)
            {
                yield break;
            }

            var accumulated = 0;
            foreach (var child in this.m_Items)
            {
                yield return
                    new KeyValuePair<MenuItem, Rectangle>(
                        child,
                        new Rectangle(
                            childLayout.Value.X,
                            childLayout.Value.Y + accumulated,
                            childLayout.Value.Width,
                            skin.MenuItemHeight));
                accumulated += skin.MenuItemHeight;
            }
        }
Esempio n. 57
0
        /// <summary>
        /// The get menu list layout.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <returns>
        /// The <see cref="Rectangle?"/>.
        /// </returns>
        public Rectangle? GetMenuListLayout(ISkin skin, Rectangle layout)
        {
            // The location of the child items depends on whether we're owned
            // by a main menu or not.
            if (this.m_Items.Count == 0)
            {
                return null;
            }

            var maxWidth = this.m_Items.Max(x => x.TextWidth) + skin.AdditionalMenuItemWidth;
            var maxHeight = this.m_Items.Count * skin.MenuItemHeight;
            if (this.Parent is MainMenu)
            {
                return new Rectangle(layout.X, layout.Y + layout.Height, maxWidth, maxHeight);
            }

            return new Rectangle(layout.X + layout.Width, layout.Y, maxWidth, maxHeight);
        }
Esempio n. 58
0
 /// <summary>
 /// Requests that the UI container handle the specified event or return false.
 /// </summary>
 /// <param name="skin">
 /// The UI skin.
 /// </param>
 /// <param name="layout">
 /// The layout for the element.
 /// </param>
 /// <param name="context">
 /// The current game context.
 /// </param>
 /// <param name="event">
 /// The event that was raised.
 /// </param>
 /// <returns>
 /// Whether or not this UI element handled the event.
 /// </returns>
 public bool HandleEvent(ISkin skin, Rectangle layout, IGameContext context, Event @event)
 {
     return this.Active;
 }
Esempio n. 59
0
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="skin">
        /// The skin.
        /// </param>
        /// <param name="layout">
        /// The layout.
        /// </param>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        /// <param name="stealFocus">
        /// The steal focus.
        /// </param>
        public virtual void Update(ISkin skin, Rectangle layout, GameTime gameTime, ref bool stealFocus)
        {
            var mouse = Mouse.GetState();
            var leftPressed = mouse.LeftChanged(this) == ButtonState.Pressed;

            if (layout.Contains(mouse.X, mouse.Y))
            {
                this.Hovered = true;
                this.HoverCountdown = 5;
                if (leftPressed)
                {
                    if (this.Click != null)
                    {
                        this.Click(this, new EventArgs());
                    }

                    this.Active = true;
                }
            }

            var deactivate = true;
            foreach (var activeLayout in this.GetActiveChildrenLayouts(skin, layout))
            {
                if (activeLayout.Contains(mouse.X, mouse.Y))
                {
                    deactivate = false;
                    break;
                }
            }

            this.Hovered = !deactivate;
            if (leftPressed)
            {
                this.Active = !deactivate;
            }

            if (this.HoverCountdown == 0)
            {
                this.Hovered = false;
            }

            if (!(this.Parent is MainMenu))
            {
                this.Active = this.Hovered;
            }

            if (this.Active)
            {
                foreach (var kv in this.GetMenuChildren(skin, layout))
                {
                    kv.Key.Update(skin, kv.Value, gameTime, ref stealFocus);
                }

                this.Focus();
            }

            // If the menu item is active, we steal focus from any further updating by our parent.
            if (this.Active)
            {
                stealFocus = true;
            }
        }
Esempio n. 60
0
        public ConnectWorld(
            IKernel kernel, 
            I2DRenderUtilities twodRenderUtilities, 
            IAssetManagerProvider assetManagerProvider, 
            IBackgroundCubeEntityFactory backgroundCubeEntityFactory, 
            ISkin skin, 
            IProfiler profiler,
            IPersistentStorage persistentStorage,
            bool startServer, 
            IPAddress address, 
            int port)
            : base(twodRenderUtilities, assetManagerProvider, backgroundCubeEntityFactory, skin)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_PersistentStorage = persistentStorage;

            this.m_DefaultFont = assetManagerProvider.GetAssetManager().Get<FontAsset>("font.Default");
            this.m_Address = address;
            this.m_Port = port;
            TychaiaClient client = null;
            byte[] initial = null;
            Action cleanup = () =>
            {
                kernel.Unbind<INetworkAPI>();
                kernel.Unbind<IClientNetworkAPI>();
                if (client != null)
                {
                    client.Close();
                }

                this.TerminateExistingProcess();
            };

            if (startServer)
            {
                this.m_Actions = new Action[]
                {
                    () => this.m_Message = "Closing old process...", () => this.TerminateExistingProcess(),
                    () => this.m_Message = "Starting server...", () => this.StartServer(),
                    () => this.m_Message = "Creating client...", () => client = new TychaiaClient(port + 2, port + 3),
                    () => client.AttachProfiler(profiler),
                    () => this.m_Message = "Connecting to server...",
                    () => client.Connect(new DualIPEndPoint(address, port, port + 1)),
                    () => this.m_Message = "Binding node to kernel...",
                    () => kernel.Bind<INetworkAPI>().ToMethod(x => client),
                    () => kernel.Bind<IClientNetworkAPI>().ToMethod(x => client), () => this.m_Message = "Joining game...",
                    () => this.m_UniqueClientIdentifier = this.JoinGame(client), () => this.m_Message = "Retrieving initial game state...",
                    () => initial = client.LoadInitialState(), () => this.m_Message = "Starting client...",
                    () => this.m_PerformFinalAction = true
                };
            }
            else
            {
                this.m_Actions = new Action[]
                {
                    () => this.m_Message = "Creating client...", () => client = new TychaiaClient(port + 2, port + 3),
                    () => client.AttachProfiler(profiler),
                    () => this.m_Message = "Connecting to server...",
                    () => client.Connect(new DualIPEndPoint(address, port, port + 1)),
                    () => this.m_Message = "Binding node to kernel...",
                    () => kernel.Bind<INetworkAPI>().ToMethod(x => client),
                    () => kernel.Bind<IClientNetworkAPI>().ToMethod(x => client),
                    () => this.m_Message = "Joining game...",
                    () => this.m_UniqueClientIdentifier = this.JoinGame(client), () => this.m_Message = "Retrieving initial game state...",
                    () => initial = client.LoadInitialState(), () => this.m_Message = "Starting client...",
                    () => this.m_PerformFinalAction = true
                };
            }

            this.m_FinalAction =
                () =>
                this.TargetWorld =
                this.GameContext.CreateWorld<IWorldFactory>(x => x.CreateTychaiaGameWorld(this.m_UniqueClientIdentifier, cleanup));

            var thread = new Thread(this.Run) { IsBackground = true };
            thread.Start();

            AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
            {
                if (this.m_Process != null)
                {
                    try
                    {
                        this.m_Process.Kill();
                        this.m_Process = null;
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            };
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                if (this.m_Process != null)
                {
                    try
                    {
                        this.m_Process.Kill();
                        this.m_Process = null;
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            };
        }