コード例 #1
0
ファイル: EditorScreen.cs プロジェクト: BlaisePascalSi/PokeSi
        private void UpdateLocTileDataControls()
        {
            foreach (KeyValuePair<string, Control> pair in locTileDataPanel.SubControls)
            {
                if (pair.Key.StartsWith("addAnimation_"))
                {
                    Button button = (Button)pair.Value;
                    if (button.IsPressed())
                    {
                        lastLocTileDataOpenAnimationScreen = new ListPresenterScreen<Animation>(Manager, World.Resources, delegate() { return World.Resources.Animations; });
                        Manager.OpenScreen(lastLocTileDataOpenAnimationScreen);
                        lastLocTileDataButtonKey = pair.Key;
                        return;
                    }
                }
                if (pair.Key.StartsWith("addSprite_"))
                {
                    Button button = (Button)pair.Value;
                    if (button.IsPressed())
                    {
                        lastLocTileDataOpenSpriteScreen = new ListPresenterScreen<Sprite>(Manager, World.Resources, delegate() { return World.Resources.Sprites; });
                        Manager.OpenScreen(lastLocTileDataOpenSpriteScreen);
                        lastLocTileDataButtonKey = pair.Key;
                        return;
                    }
                }
            }

            if (lastLocTileDataOpenAnimationScreen != null && lastLocTileDataOpenAnimationScreen.IsSubmitted && lastLocTileDataButtonKey != null)
            {
                if (lastLocTileDataOpenAnimationScreen.SelectedItem != null)
                {
                    ListButton listButton = (ListButton)locTileDataPanel.SubControls[lastLocTileDataButtonKey.Split('_').Last()];
                    listButton.SelectValue(lastLocTileDataOpenAnimationScreen.SelectedItem);
                }
                lastLocTileDataOpenAnimationScreen = null;
                lastLocTileDataButtonKey = null;
            }
            if (lastLocTileDataOpenSpriteScreen != null && lastLocTileDataOpenSpriteScreen.IsSubmitted && lastLocTileDataButtonKey != null)
            {
                if (lastLocTileDataOpenSpriteScreen.SelectedItem != null)
                {
                    ListButton listButton = (ListButton)locTileDataPanel.SubControls[lastLocTileDataButtonKey.Split('_').Last()];
                    listButton.SelectValue(lastLocTileDataOpenSpriteScreen.SelectedItem);
                }
                lastLocTileDataOpenSpriteScreen = null;
                lastLocTileDataButtonKey = null;
            }
        }
コード例 #2
0
ファイル: FormScreen.cs プロジェクト: BlaisePascalSi/PokeSi
        public override void Update(GameTime gameTime, bool isInForeground)
        {
            base.Update(gameTime, isInForeground);

            if (!isInForeground)
                return;

            panel.Update(gameTime);

            foreach (KeyValuePair<string, Control> pair in panel.SubControls)
            {
                if (pair.Key.StartsWith("addAnimation_"))
                {
                    Button button = (Button)pair.Value;
                    if (button.IsPressed())
                    {
                        lastAnimSelectScreen = new ListPresenterScreen<Animation>(Manager, World.Resources, delegate() { return World.Resources.Animations; });
                        Manager.OpenScreen(lastAnimSelectScreen);
                        lastButtonKey = pair.Key;
                        return;
                    }
                }
                if (pair.Key.StartsWith("addSprite_"))
                {
                    Button button = (Button)pair.Value;
                    if (button.IsPressed())
                    {
                        lastSpriteSelectScreen = new ListPresenterScreen<Sprite>(Manager, World.Resources, delegate() { return World.Resources.Sprites; });
                        Manager.OpenScreen(lastSpriteSelectScreen);
                        lastButtonKey = pair.Key;
                        return;
                    }
                }
            }

            if (lastAnimSelectScreen != null && lastAnimSelectScreen.IsSubmitted && lastButtonKey != null)
            {
                if (lastAnimSelectScreen.SelectedItem != null)
                {
                    ListButton listButton = (ListButton)panel.SubControls[lastButtonKey.Split('_').Last()];
                    listButton.SelectValue(lastAnimSelectScreen.SelectedItem);
                }
                lastAnimSelectScreen = null;
                lastButtonKey = null;
            }
            if (lastSpriteSelectScreen != null && lastSpriteSelectScreen.IsSubmitted && lastButtonKey != null)
            {
                if (lastSpriteSelectScreen.SelectedItem != null)
                {
                    ListButton listButton = (ListButton)panel.SubControls[lastButtonKey.Split('_').Last()];
                    listButton.SelectValue(lastSpriteSelectScreen.SelectedItem);
                }
                lastSpriteSelectScreen = null;
                lastButtonKey = null;
            }

            if (submitButton.IsPressed())
            {
                foreach (KeyValuePair<string, Control> pair in panel.SubControls)
                {
                    if (Form.Datas.ContainsKey(pair.Key))
                    {
                        if (Form.Datas[pair.Key] is string)
                            Form.Datas[pair.Key] = ((TextBox)pair.Value).Text;
                        else if (Form.Datas[pair.Key] is int)
                            Form.Datas[pair.Key] = int.Parse(((TextBox)pair.Value).Text);
                        else if (Form.Datas[pair.Key] is float)
                            Form.Datas[pair.Key] = float.Parse(((TextBox)pair.Value).Text);
                        else if(Form.Datas[pair.Key] is Point)
                        {
                            Point point = new Point();
                            point.X = int.Parse(((TextBox)pair.Value).Text);
                            point.Y = int.Parse(((TextBox)panel.SubControls[pair.Key + "_Y"]).Text);
                            Form.Datas[pair.Key] = point;
                        }
                        else if (Form.Datas[pair.Key] is Enum)
                        {
                            Type enumType = Form.Datas[pair.Key].GetType();
                            ListButton control = (ListButton)pair.Value;
                            Form.Datas[pair.Key] = Enum.Parse(enumType, control.List[control.CurrentIndex]);
                        }
                        else if (Form.Datas[pair.Key] is Controller)
                        {
                            ListButton control = (ListButton)pair.Value;
                            Form.Datas[pair.Key] = Entity.Controllers.Get(control.List[control.CurrentIndex]);
                        }
                        else if (Form.Datas[pair.Key] is Sprite)
                        {
                            ListButton control = (ListButton)pair.Value;
                            Form.Datas[pair.Key] = World.Resources.GetSprite(control.List[control.CurrentIndex]);
                        }
                        else if (Form.Datas[pair.Key] is Animation)
                        {
                            ListButton control = (ListButton)pair.Value;
                            Form.Datas[pair.Key] = World.Resources.GetAnimation(control.List[control.CurrentIndex]);
                        }
                    }
                }
                IsSubmitted = true;
                Manager.CloseScreen();
            }
        }