示例#1
0
 public void setBottomWidget(CanvasWidget widget_)
 {
     if (widget == null)
     {
         widget = widget_;
     }
 }
示例#2
0
        public Widget makeTextBox(Action <TextBoxWidget> ac, string text = "")
        {
            CanvasWidget canvasWidget = new CanvasWidget()
            {
                HorizontalAlignment = WidgetAlignment.Center
            };
            RectangleWidget rectangleWidget = new RectangleWidget()
            {
                FillColor = Color.Black, OutlineColor = Color.White, Size = new Vector2(120, 30)
            };
            StackPanelWidget stack = new StackPanelWidget()
            {
                Direction = LayoutDirection.Vertical
            };
            TextBoxWidget textBox = new TextBoxWidget()
            {
                VerticalAlignment = WidgetAlignment.Center, Color = new Color(255, 255, 255), Margin = new Vector2(4f, 0f), Size = new Vector2(120, 30), MaximumLength = 256
            };

            textBox.FontScale    = 0.7f;
            textBox.Text         = text;
            textBox.TextChanged += ac;
            stack.Children.Add(textBox);
            canvasWidget.Children.Add(rectangleWidget);
            canvasWidget.Children.Add(stack);
            return(canvasWidget);
        }
示例#3
0
 public MotdWidget()
 {
     m_containerWidget = new CanvasWidget();
     Children.Add(m_containerWidget);
     MotdManager.MessageOfTheDayUpdated += MotdManager_MessageOfTheDayUpdated;
     MotdManager_MessageOfTheDayUpdated();
 }
示例#4
0
        public SliderWidget()
        {
            XElement node = ContentManager.Get <XElement>("Widgets/SliderContents");

            LoadChildren(this, node);
            m_canvasWidget      = Children.Find <CanvasWidget>("Slider.Canvas");
            m_labelCanvasWidget = Children.Find <CanvasWidget>("Slider.LabelCanvas");
            m_tabWidget         = Children.Find <Widget>("Slider.Tab");
            m_labelWidget       = Children.Find <LabelWidget>("Slider.Label");
            LoadProperties(this, node);
        }
示例#5
0
        public CheckboxWidget()
        {
            XElement node = ContentManager.Get <XElement>("Widgets/CheckboxContents");

            LoadChildren(this, node);
            m_canvasWidget    = Children.Find <CanvasWidget>("Checkbox.Canvas");
            m_rectangleWidget = Children.Find <RectangleWidget>("Checkbox.Rectangle");
            m_tickWidget      = Children.Find <RectangleWidget>("Checkbox.Tick");
            m_labelWidget     = Children.Find <LabelWidget>("Checkbox.Label");
            m_clickableWidget = Children.Find <ClickableWidget>("Checkbox.Clickable");
            LoadProperties(this, node);
        }
        public ListSelectionDialog(string title, IEnumerable items, float itemSize, Func <object, Widget> itemWidgetFactory, Action <object> selectionHandler)
        {
            m_selectionHandler = selectionHandler;
            XElement node = ContentManager.Get <XElement>("Dialogs/ListSelectionDialog");

            LoadContents(this, node);
            m_titleLabelWidget           = Children.Find <LabelWidget>("ListSelectionDialog.Title");
            m_listWidget                 = Children.Find <ListPanelWidget>("ListSelectionDialog.List");
            m_contentWidget              = Children.Find <CanvasWidget>("ListSelectionDialog.Content");
            m_titleLabelWidget.Text      = title;
            m_titleLabelWidget.IsVisible = !string.IsNullOrEmpty(title);
            m_listWidget.ItemSize        = itemSize;
            if (itemWidgetFactory != null)
            {
                m_listWidget.ItemWidgetFactory = itemWidgetFactory;
            }
            foreach (object item in items)
            {
                m_listWidget.AddItem(item);
            }
            int   num = m_listWidget.Items.Count;
            float num2;

            while (true)
            {
                if (num >= 0)
                {
                    num2 = MathUtils.Min((float)num + 0.5f, m_listWidget.Items.Count);
                    if (num2 * itemSize <= m_contentWidget.Size.Y)
                    {
                        break;
                    }
                    num--;
                    continue;
                }
                return;
            }
            m_contentWidget.Size = new Vector2(m_contentWidget.Size.X, num2 * itemSize);
        }
示例#7
0
        public Widget makeTextBox(string title)
        {
            CanvasWidget canvasWidget = new CanvasWidget()
            {
                Margin = new Vector2(10, 0)
            };
            RectangleWidget rectangleWidget = new RectangleWidget()
            {
                FillColor = Color.Black, OutlineColor = Color.White, Size = new Vector2(float.PositiveInfinity, 80)
            };
            StackPanelWidget stack = new StackPanelWidget()
            {
                Direction = LayoutDirection.Horizontal
            };
            LabelWidget label = new LabelWidget()
            {
                HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Near, Text = title, Margin = new Vector2(1f, 1f)
            };
            TextBoxWidget textBox = new TextBoxWidget()
            {
                VerticalAlignment = WidgetAlignment.Center, HorizontalAlignment = WidgetAlignment.Stretch, Color = new Color(255, 255, 255), Margin = new Vector2(4f, 0f), Size = new Vector2(float.PositiveInfinity, 80)
            };

            if (title == "用户名:")
            {
                txa = textBox;
            }
            if (title == "密  码:")
            {
                txb = textBox;
            }
            stack.Children.Add(label);
            stack.Children.Add(textBox);
            canvasWidget.Children.Add(rectangleWidget);
            canvasWidget.Children.Add(stack);
            return(canvasWidget);
        }
示例#8
0
        public EditMemeryDialogB(MemoryBankData memoryBankData, Action onCancel)
        {
            memory = memoryBankData;
            Data.Clear();
            Data.AddRange(memory.Data);
            CanvasWidget canvasWidget = new CanvasWidget()
            {
                Size = new Vector2(600f, float.PositiveInfinity), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center
            };
            RectangleWidget rectangleWidget = new RectangleWidget()
            {
                FillColor = new Color(0, 0, 0, 255), OutlineColor = new Color(128, 128, 128, 128), OutlineThickness = 2
            };
            StackPanelWidget stackPanel = new StackPanelWidget()
            {
                Direction = LayoutDirection.Vertical
            };
            LabelWidget labelWidget = new LabelWidget()
            {
                Text = "M 板编辑器", HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0, 10)
            };
            StackPanelWidget stackPanelWidget = new StackPanelWidget()
            {
                Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Near, Margin = new Vector2(10f, 10f)
            };

            Children.Add(canvasWidget);
            canvasWidget.Children.Add(rectangleWidget);
            canvasWidget.Children.Add(stackPanel);
            stackPanel.Children.Add(labelWidget);
            stackPanel.Children.Add(stackPanelWidget);
            stackPanelWidget.Children.Add(initData());
            stackPanelWidget.Children.Add(initButton());
            MainView      = stackPanel;
            this.onCancel = onCancel;
            lastvalue     = memory.Read(0);
        }
示例#9
0
        public LoginDialog()
        {
            CanvasWidget canvasWidget = new CanvasWidget()
            {
                Size = new Vector2(600f, 240f), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center
            };
            RectangleWidget rectangleWidget = new RectangleWidget()
            {
                FillColor = new Color(0, 0, 0, 255), OutlineColor = new Color(128, 128, 128, 128), OutlineThickness = 2
            };
            StackPanelWidget stackPanelWidget = new StackPanelWidget()
            {
                Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Near, Margin = new Vector2(10f, 10f)
            };

            Children.Add(canvasWidget);
            canvasWidget.Children.Add(rectangleWidget);
            canvasWidget.Children.Add(stackPanelWidget);
            MainView = stackPanelWidget;
            MainView.Children.Add(tip);
            MainView.Children.Add(makeTextBox("用户名:"));
            MainView.Children.Add(makeTextBox("密  码:"));
            MainView.Children.Add(makeButton());
        }
示例#10
0
        public static void Initialize()
        {
            RootWidget = new CanvasWidget();
            RootWidget.WidgetsHierarchyInput = new WidgetInput();
            LoadingScreen loadingScreen = new LoadingScreen();

            AddScreen("Loading", loadingScreen);
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Nag", new NagScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("MainMenu", new MainMenuScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Recipaedia", new RecipaediaScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("RecipaediaRecipes", new RecipaediaRecipesScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("RecipaediaDescription", new RecipaediaDescriptionScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Bestiary", new BestiaryScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("BestiaryDescription", new BestiaryDescriptionScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Help", new HelpScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("HelpTopic", new HelpTopicScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Settings", new SettingsScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsPerformance", new SettingsPerformanceScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsGraphics", new SettingsGraphicsScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsUi", new SettingsUiScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsCompatibility", new SettingsCompatibilityScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsAudio", new SettingsAudioScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("SettingsControls", new SettingsControlsScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Play", new PlayScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("NewWorld", new NewWorldScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("ModifyWorld", new ModifyWorldScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("WorldOptions", new WorldOptionsScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("GameLoading", new GameLoadingScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Game", new GameScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("TrialEnded", new TrialEndedScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("ExternalContent", new ExternalContentScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("CommunityContent", new CommunityContentScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Content", new ContentScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("ManageContent", new ManageContentScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Players", new PlayersScreen());
            });
            loadingScreen.AddLoadAction(delegate
            {
                AddScreen("Player", new PlayerScreen());
            });

            SwitchScreen("Loading");
        }
示例#11
0
        public EditColorDialog(Color color, Action <Color?> handler)
        {
            WidgetsList  children = Children;
            CanvasWidget obj      = new CanvasWidget
            {
                Size = new Vector2(660f, 420f),
                HorizontalAlignment = WidgetAlignment.Center,
                VerticalAlignment   = WidgetAlignment.Center,
                Children            =
                {
                    (Widget) new RectangleWidget
                    {
                        FillColor        = new Color(0, 0, 0, 255),
                        OutlineColor     = new Color(128, 128, 128, 128),
                        OutlineThickness = 2f
                    }
                }
            };
            WidgetsList      children2 = obj.Children;
            StackPanelWidget obj2      = new StackPanelWidget
            {
                Direction           = LayoutDirection.Vertical,
                Margin              = new Vector2(15f),
                HorizontalAlignment = WidgetAlignment.Center,
                Children            =
                {
                    (Widget) new LabelWidget
                    {
                        Text = "Edit Color",
                        HorizontalAlignment = WidgetAlignment.Center
                    },
                    (Widget) new CanvasWidget
                    {
                        Size = new Vector2(0f, float.PositiveInfinity)
                    }
                }
            };
            WidgetsList      children3 = obj2.Children;
            StackPanelWidget obj3      = new StackPanelWidget
            {
                Direction = LayoutDirection.Horizontal
            };
            WidgetsList      children4 = obj3.Children;
            StackPanelWidget obj4      = new StackPanelWidget
            {
                Direction         = LayoutDirection.Vertical,
                VerticalAlignment = WidgetAlignment.Center
            };
            WidgetsList      children5 = obj4.Children;
            StackPanelWidget obj5      = new StackPanelWidget
            {
                Direction           = LayoutDirection.Horizontal,
                HorizontalAlignment = WidgetAlignment.Far,
                Margin   = new Vector2(0f, 10f),
                Children =
                {
                    (Widget) new LabelWidget
                    {
                        Text              = "Red:",
                        Color             = Color.Gray,
                        VerticalAlignment = WidgetAlignment.Center,
                        Font              = ContentManager.Get <BitmapFont>("Fonts/Pericles")
                    },
                    (Widget) new CanvasWidget
                    {
                        Size = new Vector2(10f, 0f)
                    }
                }
            };
            WidgetsList  children6 = obj5.Children;
            SliderWidget obj6      = new SliderWidget
            {
                Size           = new Vector2(300f, 50f),
                IsLabelVisible = false,
                MinValue       = 0f,
                MaxValue       = 255f,
                Granularity    = 1f,
                SoundName      = ""
            };
            SliderWidget widget = obj6;

            m_sliderR = obj6;
            children6.Add(widget);
            children5.Add(obj5);
            WidgetsList      children7 = obj4.Children;
            StackPanelWidget obj7      = new StackPanelWidget
            {
                Direction           = LayoutDirection.Horizontal,
                HorizontalAlignment = WidgetAlignment.Far,
                Margin   = new Vector2(0f, 10f),
                Children =
                {
                    (Widget) new LabelWidget
                    {
                        Text              = "Green:",
                        Color             = Color.Gray,
                        VerticalAlignment = WidgetAlignment.Center,
                        Font              = ContentManager.Get <BitmapFont>("Fonts/Pericles")
                    },
                    (Widget) new CanvasWidget
                    {
                        Size = new Vector2(10f, 0f)
                    }
                }
            };
            WidgetsList  children8 = obj7.Children;
            SliderWidget obj8      = new SliderWidget
            {
                Size           = new Vector2(300f, 50f),
                IsLabelVisible = false,
                MinValue       = 0f,
                MaxValue       = 255f,
                Granularity    = 1f,
                SoundName      = ""
            };

            widget    = obj8;
            m_sliderG = obj8;
            children8.Add(widget);
            children7.Add(obj7);
            WidgetsList      children9 = obj4.Children;
            StackPanelWidget obj9      = new StackPanelWidget
            {
                Direction           = LayoutDirection.Horizontal,
                HorizontalAlignment = WidgetAlignment.Far,
                Margin   = new Vector2(0f, 10f),
                Children =
                {
                    (Widget) new LabelWidget
                    {
                        Text              = "Blue:",
                        Color             = Color.Gray,
                        VerticalAlignment = WidgetAlignment.Center,
                        Font              = ContentManager.Get <BitmapFont>("Fonts/Pericles")
                    },
                    (Widget) new CanvasWidget
                    {
                        Size = new Vector2(10f, 0f)
                    }
                }
            };
            WidgetsList  children10 = obj9.Children;
            SliderWidget obj10      = new SliderWidget
            {
                Size           = new Vector2(300f, 50f),
                IsLabelVisible = false,
                MinValue       = 0f,
                MaxValue       = 255f,
                Granularity    = 1f,
                SoundName      = ""
            };

            widget    = obj10;
            m_sliderB = obj10;
            children10.Add(widget);
            children9.Add(obj9);
            children4.Add(obj4);
            obj3.Children.Add(new CanvasWidget
            {
                Size = new Vector2(20f, 0f)
            });
            WidgetsList          children11   = obj3.Children;
            CanvasWidget         canvasWidget = new CanvasWidget();
            WidgetsList          children12   = canvasWidget.Children;
            BevelledButtonWidget obj11        = new BevelledButtonWidget
            {
                Size                = new Vector2(200f, 240f),
                AmbientLight        = 1f,
                HorizontalAlignment = WidgetAlignment.Center,
                VerticalAlignment   = WidgetAlignment.Center
            };
            BevelledButtonWidget widget2 = obj11;

            m_rectangle = obj11;
            children12.Add(widget2);
            WidgetsList children13 = canvasWidget.Children;
            LabelWidget obj12      = new LabelWidget
            {
                HorizontalAlignment = WidgetAlignment.Center,
                VerticalAlignment   = WidgetAlignment.Center,
                Font = ContentManager.Get <BitmapFont>("Fonts/Pericles")
            };
            LabelWidget widget3 = obj12;

            m_label = obj12;
            children13.Add(widget3);
            children11.Add(canvasWidget);
            children3.Add(obj3);
            obj2.Children.Add(new CanvasWidget
            {
                Size = new Vector2(0f, float.PositiveInfinity)
            });
            WidgetsList      children14 = obj2.Children;
            StackPanelWidget obj13      = new StackPanelWidget
            {
                Direction           = LayoutDirection.Horizontal,
                HorizontalAlignment = WidgetAlignment.Center
            };
            WidgetsList          children15 = obj13.Children;
            BevelledButtonWidget obj14      = new BevelledButtonWidget
            {
                Size = new Vector2(160f, 60f),
                Text = LanguageControl.Get("Usual", "ok")
            };
            ButtonWidget widget4 = obj14;

            m_okButton = obj14;
            children15.Add(widget4);
            obj13.Children.Add(new CanvasWidget
            {
                Size = new Vector2(50f, 0f)
            });
            WidgetsList          children16 = obj13.Children;
            BevelledButtonWidget obj15      = new BevelledButtonWidget
            {
                Size = new Vector2(160f, 60f),
                Text = "Cancel"
            };

            widget4        = obj15;
            m_cancelButton = obj15;
            children16.Add(widget4);
            children14.Add(obj13);
            children2.Add(obj2);
            children.Add(obj);
            m_handler = handler;
            m_color   = color;
            UpdateControls();
        }