コード例 #1
0
ファイル: LinearLayout.cs プロジェクト: vvoland/TextRPG
        public void TestCenter()
        {
            var pos   = new Vector2(5, 5);
            var size  = new Vector2(11, 11);
            var pivot = Vector2f.Center;

            //-----------
            //-----------
            //-----------
            //-----------
            //-xxx-xxxxx-
            //-x-x-C---x-
            //-xxx-xxxxx-
            //-----------
            //-----------
            //-----------
            //-----------


            LinearLayout layout = new LinearLayout(LayoutDirection.Horizontal, pos, pivot);

            layout.Add(Rectangle3);
            layout.Add(Rectangle5);
            layout.Size = size;

            Assert.AreEqual(new Vector2(-3, 0), Rectangle3.Position);
            Assert.AreEqual(new Vector2(2, 0), Rectangle5.Position);
        }
コード例 #2
0
ファイル: LayerList.cs プロジェクト: thyawan/storybrew
        private void refreshLayers()
        {
            layersLayout.ClearWidgets();
            foreach (var osbLayer in Project.OsbLayers)
            {
                Label osbLayerLabel;
                layersLayout.Add(osbLayerLabel = new Label(Manager)
                {
                    StyleName = "listHeader",
                    Text      = osbLayer.ToString(),
                });

                var ol = osbLayer;
                osbLayerLabel.HandleDrop = data =>
                {
                    if (data is EditorStoryboardLayer droppedLayer)
                    {
                        var dndLayer = layerManager.Layers.FirstOrDefault(l => l.Guid == droppedLayer.Guid);
                        if (dndLayer != null)
                        {
                            layerManager.MoveToOsbLayer(dndLayer, ol);
                        }
                        return(true);
                    }
                    return(false);
                };

                buildLayers(osbLayer, true);
                buildLayers(osbLayer, false);
            }
        }
コード例 #3
0
ファイル: FormTest.cs プロジェクト: SchmobertRitz/EMP-Unity
    void Start()
    {
        form         = new Form();
        form.Spacing = 5;

        Label labelNamespace = new Label("Component Namespace:");

        labelNamespace.Width = 150;
        TextField    txtNamespace       = new TextField();
        LinearLayout componentNamespace = LinearLayout.Horizontal().Add(labelNamespace).Add(txtNamespace);

        componentNamespace.Height = 30;
        form.Add(componentNamespace);

        Label labelComponentName = new Label("Name of Component:");

        labelComponentName.Width = 150;
        TextField    txtComponentName = new TextField();
        LinearLayout componentName    = LinearLayout.Horizontal().Add(labelComponentName).Add(txtComponentName);

        componentName.Height = 30;
        form.Add(componentName);

        form.Add(new Label("Generate following folders in component:"));

        LinearLayout toggles = LinearLayout.Horizontal();
        LinearLayout left    = LinearLayout.Vertical();

        left.Width = 100;
        left.Add(new Toggle(true, "Scripts"));
        left.Add(new Toggle(true, "Meshes"));
        left.Add(new Toggle(true, "Materials"));

        LinearLayout right = LinearLayout.Vertical();

        right.Width = 100;
        right.Add(new Toggle(true, "Prefabs"));
        right.Add(new Toggle(true, "Ressoures"));

        toggles.Add(left).Add(right);
        form.Add(toggles);

        LinearLayout buttonContainer = LinearLayout.Horizontal();

        form.Add(buttonContainer);

        Button button = new Button("Ok", _ => { });

        button.Width = 100;
        buttonContainer.Add(new View()).Add(button);
        form.Add(buttonContainer);
    }
コード例 #4
0
ファイル: LayerList.cs プロジェクト: starrodkirby86/storybrew
        private void refreshLayers()
        {
            layersLayout.ClearWidgets();
            foreach (var osbLayer in Project.OsbLayers)
            {
                layersLayout.Add(new Label(Manager)
                {
                    StyleName = "listHeader",
                    Text      = osbLayer.ToString(),
                });

                buildLayers(osbLayer, true);
                buildLayers(osbLayer, false);
            }
        }
コード例 #5
0
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create Subfolders"));

            LinearLayout lyButton = LinearLayout.Horizontal();
            Button       button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);

            Label lblSubfolders = new Label("Subfolders:");

            lblSubfolders.Width = 150;

            GridLayout lyCheckboxes = new GridLayout(3, GridLayout.EOrientation.Vertical);

            foreach (string folder in new string[] { "Scripts", "Scenes", "Prefabs", "Resources", "Textures", "Materials", "Meshes" })
            {
                Toggle toggle = new Toggle(false, folder);
                subfolders.Add(toggle);
                lyCheckboxes.Add(toggle);
            }

            form.Add(lyCheckboxes);
            form.Add(new View());
            form.Add(lyButton);
        }
コード例 #6
0
        private void updateFields()
        {
            configFieldsLayout.ClearWidgets();
            if (effect == null)
            {
                return;
            }

            foreach (var field in effect.Config.SortedFields)
            {
                configFieldsLayout.Add(new LinearLayout(Manager)
                {
                    AnchorFrom = BoxAlignment.Centre,
                    AnchorTo   = BoxAlignment.Centre,
                    Horizontal = true,
                    Fill       = true,
                    Children   = new Widget[]
                    {
                        new Label(Manager)
                        {
                            StyleName  = "listItem",
                            Text       = field.DisplayName,
                            AnchorFrom = BoxAlignment.TopLeft,
                            AnchorTo   = BoxAlignment.TopLeft,
                        },
                        buildFieldEditor(field),
                    }
                });
            }
        }
コード例 #7
0
ファイル: EffectList.cs プロジェクト: Endaris/storybrew
 private void refreshEffects()
 {
     effectsLayout.ClearWidgets();
     foreach (var effect in project.Effects.OrderBy(e => e.Name))
     {
         effectsLayout.Add(createEffectWidget(effect));
     }
 }
コード例 #8
0
ファイル: LinearLayout.cs プロジェクト: vvoland/TextRPG
        public void RendersItsChildren()
        {
            var t1           = Substitute.For <GUIWidget>();
            var t2           = Substitute.For <GUIWidget>();
            var t3           = Substitute.For <GUIWidget>();
            var fakeRenderer = Substitute.For <RenderSystem>();

            var layout = new LinearLayout(LayoutDirection.Horizontal, Vector2.Zero, Vector2f.Center);

            layout.Add(t1);
            layout.Add(t2);
            layout.Add(t3);
            layout.Render(fakeRenderer);

            fakeRenderer.Received().Render(t1);
            fakeRenderer.Received().Render(t2);
            fakeRenderer.Received().Render(t3);
        }
コード例 #9
0
        protected BaseValueCell(AContext context, Cell cell) : base(context, cell)
        {
            RemoveAccessoryStack();
            _Hint           = BaseTextView.Create <HintView>(ContentView, this, Resource.Id.CellHint);
            _CellValueStack = ValueStack();

            _Value = InstanceCreator.Create <TCell>(this, AndroidContext);
            // _Value = InstanceCreator<BaseCellView, AContext, TCell>.Create(this, AndroidContext);
            _CellValueStack.Add(_Value, Extensions.Layout.Match, Extensions.Layout.Wrap, GravityFlags.Fill | GravityFlags.Center);
        }
コード例 #10
0
        private void InitUI()
        {
            GUI = new GUISystem();
            string text = string.Format("You are in the {0}\nWhat do you want to do?", Location.DisplayName);

            CityText           = new Label(text, GetScreenPoint(0.5f, 0.25f));
            ButtonsLayout      = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.75f), Vector2f.Center);
            ButtonsLayout.Size = GetScreenPoint(0.5f, 0.35f);

            foreach (var interactable in Location.Interactables)
            {
                var button = new GUIButton(Vector2.Zero, interactable.MenuText, () => interactable.Interact(Game));
                ButtonsLayout.Add(button);
                GUI.Add(button);
            }
            var travel = new GUIButton(Vector2.Zero, "Travel", () => Travel());

            ButtonsLayout.Add(travel);
            GUI.Add(travel);
        }
コード例 #11
0
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create Folder"));

            Label lblNamespace = new Label("Namespace:");

            lblNamespace.Width = 150;
            txtNamespace       = new TextField(transitiveSourceInfo.@namespace);
            LinearLayout lyNamespace = LinearLayout.Horizontal().Add(lblNamespace).Add(txtNamespace);

            lyNamespace.Height = 30;

            Label lblFolder = new Label("Folder:");

            lblFolder.Width = 150;
            txtFolderName   = new TextField();
            LinearLayout lyFolder = LinearLayout.Horizontal().Add(lblFolder).Add(txtFolderName);

            lyFolder.Height          = 30;
            lblError                 = new Label("");
            lblError.style.fontStyle = FontStyle.Bold;

            LinearLayout lyButton = LinearLayout.Horizontal();
            Button       button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);

            Label lblSubfolders = new Label("Create subfolders:");

            lblSubfolders.Width = 150;

            GridLayout lyCheckboxes = new GridLayout(3, GridLayout.EOrientation.Vertical);

            foreach (string folder in new string[] { "Scripts", "Scenes", "Prefabs", "Resources", "Textures", "Materials", "Meshes" })
            {
                Toggle toggle = new Toggle(false, folder);
                subfolders.Add(toggle);
                lyCheckboxes.Add(toggle);
            }

            LinearLayout lySubfolders = LinearLayout.Horizontal().Add(lblSubfolders).Add(lyCheckboxes);

            form.Add(lyNamespace);
            form.Add(lyFolder);
            form.Add(lblError);
            form.Add(lySubfolders);
            form.Add(lyButton);

            form.RequestFocusForView = txtFolderName;
        }
コード例 #12
0
ファイル: ViewCharacter.cs プロジェクト: vvoland/TextRPG
        private void Init()
        {
            Frame           = new Frame(Vector2.Zero, Size);
            Frame.Pivot     = Vector2f.Zero;
            Frame.Character = 'x';
            Frame.Color     = Color.DarkGray;

            var layoutStart = new Vector2(Size.X / 2, 1);

            Layout      = new LinearLayout(LayoutDirection.Vertical, layoutStart, new Vector2f(0.5f, 0.0f));
            Layout.Size = Size.Expand(-2, -2);

            Header       = new Label(Pad("Character"));
            Header.Color = Color.DarkBlue;
            Layout.Add(new GUIAdapter(Header));

            CharacterName = new Label("");
            Layout.Add(new GUIAdapter(CharacterName));

            Health = new Label("");
            Layout.Add(new GUIAdapter(Health));

            Gold       = new Label("");
            Gold.Color = Color.DarkYellow;
            Layout.Add(new GUIAdapter(Gold));

            Exp       = new Label("");
            Exp.Color = Color.DarkCyan;
            Layout.Add(new GUIAdapter(Exp));

            Stats = new Label("");
            Layout.Add(new GUIAdapter(Stats));

            Refresh();
        }
コード例 #13
0
ファイル: ViewTrade.cs プロジェクト: vvoland/TextRPG
        private void InitUI()
        {
            GUI                 = new GUISystem();
            Greeting            = new Label(Text, GetScreenPoint(0.5f, 0.25f));
            ProductsLayout      = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.75f), Vector2f.Center);
            ProductsLayout.Size = GetScreenPoint(0.4f, 0.4f);

            foreach (var group in Vendor.GroupedProducts)
            {
                Item   item   = group.Item1;
                int    count  = group.Item2;
                string text   = GetItemLabel(item, count);
                var    button = new GUIButton(Vector2.Zero, text, () => TryBuy(item));
                ProductsLayout.Add(button);
                GUI.Add(button);
            }

            var leave = new GUIButton(Vector2.Zero, "Back", () => Game.PopView());

            ProductsLayout.Add(leave);
            GUI.Add(leave);
        }
コード例 #14
0
ファイル: ViewMainMenu.cs プロジェクト: vvoland/TextRPG
        private void Init()
        {
            GUI = new GUISystem();

            Title = new Label(@" _____         _    ____________ _____
|_   _|       | |   | ___ \ ___ \  __ \
  | | _____  _| |_  | |_/ / |_/ / |  \/
  | |/ _ \ \/ / __| |    /|  __/| | __ 
  | |  __/>  <| |_  | |\ \| |   | |_\ \
  \_/\___/_/\_\\__| \_| \_\_|    \____/", GetScreenPoint(0.5f, 0.25f), Vector2f.Center, Color.DarkGray);

            Author = new Label("by Pawel Gronowski", Vector2.Zero, Vector2f.Center, Color.DarkBlue);
            Help   = new Label("TAB: Switch button\nENTER: Activate", Vector2.Zero, Vector2f.Center, Color.DarkGreen);

            MenuLayout         = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.5f), Vector2f.Center);
            MenuLayout.Size    = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y);
            MenuLayout.Spacing = 2;

            ButtonsLayout         = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.5f), Vector2f.Center);
            ButtonsLayout.Spacing = 5;
            ContinueGame          = new GUIButton(Vector2.Zero, "Continue Game", () => ActionContinueGame());
            NewGame = new GUIButton(Vector2.Zero, "New Game", () => ActionNewGame());
            Quit    = new GUIButton(Vector2.Zero, "Quit", () => Game.Running = false);

            // TODO: Enable when game saving/loading is done
            // ButtonsLayout.Add(ContinueGame);
            // GUI.Add(ContinueGame);
            ButtonsLayout.Add(NewGame);
            ButtonsLayout.Add(Quit);
            ButtonsLayout.Size = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y / 4);

            MenuLayout.Add(new GUIAdapter(Title));
            MenuLayout.Add(new GUIAdapter(Author));
            MenuLayout.Add(new GUIAdapter(Help));
            MenuLayout.Add(ButtonsLayout);

            GUI.Add(NewGame);
            GUI.Add(Quit);
        }
コード例 #15
0
ファイル: ViewCombat.cs プロジェクト: vvoland/TextRPG
        private void Init()
        {
            GUI = new GUISystem();

            Description          = new Label("");
            Description.Position = GetScreenPoint(0.5f, 0.05f);
            Description.Pivot    = new Vector2f(0.5f, 0);

            Log          = new Label("");
            Log.Position = GetScreenPoint(0.5f, 0.75f);
            Log.Size     = GetScreenPoint(0.5f, 0.25f);
            Log.Pivot    = new Vector2f(0.5f, 1.0f);

            Actions  = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.25f), Vector2f.Center);
            NextTurn = new GUIButton(Vector2.Zero, "Next Turn", () => Tick());
            Retreat  = new GUIButton(Vector2.Zero, "Retreat", () => DoRetreat());
            Quit     = new GUIButton(Vector2.Zero, "Close", () => DoClose());
            Actions.Add(NextTurn);
            Actions.Add(Retreat);
            GUI.Add(NextTurn);
            GUI.Add(Retreat);

            Refresh();
        }
コード例 #16
0
ファイル: ViewCombat.cs プロジェクト: vvoland/TextRPG
 private void Tick()
 {
     ++Turn;
     Combat.Tick();
     Refresh();
     if (Combat.IsFinished)
     {
         GUI.Remove(NextTurn);
         GUI.Remove(Retreat);
         Actions.Remove(NextTurn);
         Actions.Remove(Retreat);
         Actions.Add(Quit);
         GUI.Add(Quit);
     }
 }
コード例 #17
0
        public ViewMessage(GameSystem game, RenderSystem renderer,
                           string text,
                           IList <MenuOption> options)
            : base(game, renderer)
        {
            GUI           = new GUISystem();
            Text          = new Label(text, GetScreenPoint(0.5f, 0.25f));
            ButtonsLayout = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.6f), Vector2f.Center);

            foreach (var option in options)
            {
                var button = new GUIButton(Vector2.Zero, option.Text, option.Callback);
                ButtonsLayout.Add(button);
                GUI.Add(button);
            }
        }
コード例 #18
0
        public ViewChooseProfession(GameSystem game, RenderSystem renderer) : base(game, renderer)
        {
            GUI    = new GUISystem();
            Header = new Label("What is your profession?", GetScreenPoint(0.5f, 0.25f));

            ProfessionsLayout         = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.5f), Vector2f.Center);
            ProfessionsLayout.Size    = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y / 3);
            ProfessionsLayout.Spacing = 3;
            foreach (var profession in Professions.All)
            {
                var button = new GUIButton(
                    Vector2.Zero,
                    profession.Name,
                    () => ChooseProfession(profession)
                    );
                ProfessionsLayout.Add(button);
                GUI.Add(button);
            }
        }
コード例 #19
0
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create C# Class"));

            Label lblNamespace = new Label("Namespace:");

            lblNamespace.Width = 150;
            txtNamespace       = new TextField(sourcesInfo.@namespace);
            LinearLayout lyNamespace = LinearLayout.Horizontal().Add(lblNamespace).Add(txtNamespace);

            lyNamespace.Height = 30;

            Label lblClassName = new Label("Class name:");

            lblClassName.Width = 150;
            txtClassName       = new TextField();
            LinearLayout lyClassName = LinearLayout.Horizontal().Add(lblClassName).Add(txtClassName);

            lyClassName.Height = 30;

            form.Add(lyNamespace);
            form.Add(lyClassName);
            form.Add(lblError        = new Label(""));
            lblError.style.fontStyle = FontStyle.Bold;

            form.Add(tglHeaderComment = new Toggle(true, "Generate source code header comment"));
            form.Add(tglLogger        = new Toggle(true, "Generate logger"));

            LinearLayout lyButton = LinearLayout.Horizontal();
            Button       button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);
            form.Add(lyButton);

            form.RequestFocusForView = txtClassName;
        }
コード例 #20
0
        public LGView Clone()
        {
            LGView ret = (LGView)MemberwiseClone();

            ret.lc       = lc;
            ret.luaId    = luaId;
            ret.subviews = new List <LGView>();
            foreach (LGView v in subviews)
            {
                ret.subviews.Add(v.Clone());
            }

            ret.Setup();
            ret.view = (FrameworkElement)LuaViewInflator.Clone(ret.view, view);
            if (ret.view.GetType() == typeof(LinearLayout))
            {
                LinearLayout ll = (LinearLayout)ret.view;
                foreach (LGView cloned in ret.subviews)
                {
                    ll.Add(cloned.view);
                }
            }
            return(ret);
        }
コード例 #21
0
        private void refreshAssemblies()
        {
            assembliesLayout.ClearWidgets();
            foreach (var assembly in selectedAssemblies.OrderBy(id => isSystemAssembly(id) ? $"_{id}" : getAssemblyName(id)))
            {
                Widget assemblyRoot;
                Label  nameLabel;
                Button statusButton, editButton, removeButton;

                assembliesLayout.Add(assemblyRoot = new LinearLayout(WidgetManager)
                {
                    AnchorFrom  = BoxAlignment.Centre,
                    AnchorTo    = BoxAlignment.Centre,
                    Horizontal  = true,
                    FitChildren = true,
                    Fill        = true,
                    Children    = new Widget[]
                    {
                        new LinearLayout(WidgetManager)
                        {
                            StyleName = "condensed",
                            Children  = new Widget[]
                            {
                                nameLabel = new Label(WidgetManager)
                                {
                                    StyleName  = "listItem",
                                    Text       = getAssemblyName(assembly),
                                    AnchorFrom = BoxAlignment.Left,
                                    AnchorTo   = BoxAlignment.Left,
                                },
                            },
                        },
                        statusButton = new Button(WidgetManager)
                        {
                            StyleName  = "icon",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                            Displayed  = false,
                        },
                        editButton = new Button(WidgetManager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.PencilSquare,
                            Tooltip    = "Change file",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                        },
                        removeButton = new Button(WidgetManager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.Times,
                            Tooltip    = "Remove",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                        },
                    }
                });

                var ass = assembly;

                editButton.OnClick   += (sender, e) => changeReferencedAssembly(ass);
                removeButton.OnClick += (sender, e) => WidgetManager.ScreenLayerManager.ShowMessage($"Remove {getAssemblyName(ass)}?", () => removeReferencedAssembly(ass), true);
            }
        }
コード例 #22
0
        private void refreshEffects()
        {
            effectsLayout.ClearWidgets();
            foreach (var effect in project.Effects.OrderBy(e => e.Name))
            {
                Widget effectRoot;
                Label  nameLabel, detailsLabel;
                Button renameButton, statusButton, configButton, editButton, removeButton;
                effectsLayout.Add(effectRoot = new LinearLayout(Manager)
                {
                    AnchorFrom  = BoxAlignment.Centre,
                    AnchorTo    = BoxAlignment.Centre,
                    Horizontal  = true,
                    FitChildren = true,
                    Fill        = true,
                    Children    = new Widget[]
                    {
                        renameButton = new Button(Manager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.Pencil,
                            Tooltip    = "Rename",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                        },
                        new LinearLayout(Manager)
                        {
                            StyleName = "condensed",
                            Children  = new Widget[]
                            {
                                nameLabel = new Label(Manager)
                                {
                                    StyleName  = "listItem",
                                    Text       = effect.Name,
                                    AnchorFrom = BoxAlignment.Left,
                                    AnchorTo   = BoxAlignment.Left,
                                },
                                detailsLabel = new Label(Manager)
                                {
                                    StyleName  = "listItemSecondary",
                                    Text       = getEffectDetails(effect),
                                    AnchorFrom = BoxAlignment.Left,
                                    AnchorTo   = BoxAlignment.Left,
                                },
                            },
                        },
                        statusButton = new Button(Manager)
                        {
                            StyleName  = "icon",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                            Displayed  = false,
                        },
                        configButton = new Button(Manager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.Gear,
                            Tooltip    = "Configure",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                        },
                        editButton = new Button(Manager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.PencilSquare,
                            Tooltip    = "Edit script",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                            Disabled   = effect.Path == null,
                        },
                        removeButton = new Button(Manager)
                        {
                            StyleName  = "icon",
                            Icon       = IconFont.Times,
                            Tooltip    = "Remove",
                            AnchorFrom = BoxAlignment.Centre,
                            AnchorTo   = BoxAlignment.Centre,
                            CanGrow    = false,
                        },
                    },
                });

                updateStatusButton(statusButton, effect);

                var ef = effect;

                EventHandler changedHandler;
                effect.OnChanged += changedHandler = (sender, e) =>
                {
                    nameLabel.Text    = ef.Name;
                    detailsLabel.Text = getEffectDetails(ef);
                    updateStatusButton(statusButton, ef);
                };
                effectRoot.OnHovered += (sender, e) =>
                {
                    ef.Highlight = e.Hovered;
                    OnEffectPreselect?.Invoke(e.Hovered ? ef : null);
                };
                effectRoot.OnClickDown += (sender, e) =>
                {
                    OnEffectSelected?.Invoke(ef);
                    return(true);
                };
                effectRoot.OnDisposed += (sender, e) =>
                {
                    ef.Highlight  = false;
                    ef.OnChanged -= changedHandler;
                };

                statusButton.OnClick += (sender, e) => Manager.ScreenLayerManager.ShowMessage($"Status: {ef.Status}\n\n{ef.StatusMessage}");
                renameButton.OnClick += (sender, e) => Manager.ScreenLayerManager.ShowPrompt("Effect name", $"Pick a new name for {ef.Name}", ef.Name, (newName) =>
                {
                    ef.Name = newName;
                    refreshEffects();
                });
                editButton.OnClick   += (sender, e) => openEffectEditor(ef);
                configButton.OnClick += (sender, e) =>
                {
                    if (!effectConfigUi.Displayed || effectConfigUi.Effect != ef)
                    {
                        effectConfigUi.Effect    = ef;
                        effectConfigUi.Displayed = true;
                    }
                    else
                    {
                        effectConfigUi.Displayed = false;
                    }
                };
                removeButton.OnClick += (sender, e) => Manager.ScreenLayerManager.ShowMessage($"Remove {ef.Name}?", () => project.Remove(ef), true);
            }
        }
コード例 #23
0
        public override void Load()
        {
            base.Load();

            WidgetManager.Root.Add(mainLayout = new LinearLayout(WidgetManager)
            {
                StyleName    = "panel",
                AnchorTarget = WidgetManager.Root,
                AnchorFrom   = BoxAlignment.Centre,
                AnchorTo     = BoxAlignment.Centre,
                Padding      = new FourSide(16),
                Children     = new Widget[]
                {
                    new ScrollArea(WidgetManager, new Label(WidgetManager)
                    {
                        Text       = message,
                        AnchorFrom = BoxAlignment.Centre,
                    })
                    {
                        ScrollsHorizontally = true,
                    },
                    buttonsLayout = new LinearLayout(WidgetManager)
                    {
                        Horizontal = true,
                        AnchorFrom = BoxAlignment.Centre,
                    },
                },
            });

            var yesButton = new Button(WidgetManager)
            {
                Text       = noAction != null ? "Yes" : "Ok",
                AnchorFrom = BoxAlignment.Centre,
            };

            yesButton.OnClick += (sender, e) =>
            {
                Exit();
                yesAction?.Invoke();
            };
            buttonsLayout.Add(yesButton);

            if (noAction != null)
            {
                var noButton = new Button(WidgetManager)
                {
                    Text       = "No",
                    AnchorFrom = BoxAlignment.Centre,
                };
                noButton.OnClick += (sender, e) =>
                {
                    Exit();
                    noAction.Invoke();
                };
                buttonsLayout.Add(noButton);
            }

            if (cancelable)
            {
                var cancelButton = new Button(WidgetManager)
                {
                    Text       = "Cancel",
                    AnchorFrom = BoxAlignment.Centre,
                };
                cancelButton.OnClick += (sender, e) => Exit();
                buttonsLayout.Add(cancelButton);
            }
        }