Пример #1
0
        private void setupPortrait()
        {
            Icon = GuiRoot.RootItem.AddChild(new Gui.Widgets.EmployeePortrait()
            {
                Rect = SpeakerBorder.Rect
            }) as Gui.Widgets.EmployeePortrait;

            var sprite = _employee.GetRoot().GetComponent <LayeredSprites.LayeredCharacterSprite>();

            if (sprite != null)
            {
                Icon.Sprite          = sprite.GetLayers();
                Icon.AnimationPlayer = new AnimationPlayer(sprite.GetAnimation(_employee.Creature.CurrentCharacterMode.ToString() + "FORWARD"));
            }
            else
            {
                Icon.Sprite          = null;
                Icon.AnimationPlayer = null;
            }

            var label = Icon.AddChild(new Widget()
            {
                Text                = _employee.Stats.FullName + "\n(" + (_employee.Stats.Title ?? _employee.Stats.CurrentClass.Name) + ")",
                Font                = "font10",
                TextColor           = Color.White.ToVector4(),
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Center,
                AutoLayout          = AutoLayout.DockBottom
            });

            Icon.Layout();
        }
Пример #2
0
        public override void OnEnter()
        {
            DwarfGame.GumInputMapper.GetInputQueue();


            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);

            var panel = GuiRoot.RootItem.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.FloatCenter,
                MinimumSize = new Point((int)(GuiRoot.RenderData.VirtualScreen.Width * 0.75f), (int)(GuiRoot.RenderData.VirtualScreen.Height * 0.75f)),
                Border      = "border-fancy"
            });

            panel.AddChild(new Widget
            {
                Text       = "Exit Designer",
                Border     = "border-button",
                AutoLayout = AutoLayout.FloatBottomRight,
                OnClick    = (sender, args) => StateManager.PopState()
            });

            SpriteFrame = panel.AddChild(new DwarfCorp.Gui.Widgets.EmployeePortrait
            {
                MinimumSize = new Point(48 * 6, 40 * 6),
                MaximumSize = new Point(48 * 6, 40 * 6),
                AutoLayout  = AutoLayout.DockLeft
            }) as DwarfCorp.Gui.Widgets.EmployeePortrait;

            SpriteFrame.Sprite = new LayeredSprites.LayerStack();
            foreach (Animation animation in AnimationLibrary.LoadNewLayeredAnimationFormat(ContentPaths.dwarf_animations))
            {
                var proxyAnim = SpriteFrame.Sprite.ProxyAnimation(animation);
                proxyAnim.Loops = true;
                Animations.Add(proxyAnim);
            }

            SpriteFrame.AnimationPlayer = new AnimationPlayer();
            SpriteFrame.AnimationPlayer.ChangeAnimation(Animations[0], AnimationPlayer.ChangeAnimationOptions.ResetAndPlay);

            AddSelector(panel, "body");
            AddSelector(panel, "face");
            AddSelector(panel, "nose");
            AddSelector(panel, "beard");
            AddSelector(panel, "hair");
            AddSelector(panel, "tool");
            AddSelector(panel, "hat");
            AddSelector(panel, "minecart");

            var anim = panel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(2, 2, 2, 2)
            });

            anim.AddChild(new Widget
            {
                Text                = "animation",
                MinimumSize         = new Point(64, 0),
                AutoLayout          = AutoLayout.DockLeft,
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Center
            });

            var animCombo = anim.AddChild(new Gui.Widgets.ComboBox
            {
                Items                  = Animations.Select(a => a.Name).ToList(),
                Border                 = "border-thin",
                AutoLayout             = AutoLayout.DockTop,
                OnSelectedIndexChanged = (sender) => SpriteFrame.AnimationPlayer.ChangeAnimation(Animations.First(a => a.Name == (sender as Gui.Widgets.ComboBox).SelectedItem),
                                                                                                 AnimationPlayer.ChangeAnimationOptions.ResetAndPlay),
                ItemsVisibleInPopup = 12,
            }) as Gui.Widgets.ComboBox;

            animCombo.SelectedIndex = animCombo.Items.IndexOf("WalkingFORWARD");

            GuiRoot.RootItem.Layout();

            IsInitialized = true;

            base.OnEnter();
        }