Пример #1
0
        public override void Start()
        {
            var cache = GetSubsystem<ResourceCache>();
            var graphics = GetSubsystem<Graphics>();
            var ui = GetSubsystem<UI>();


            graphics.SetWindowIcon(cache.Get<Image>("Textures/AtomicIcon48.png"));
            graphics.WindowTitle = "Atomic Game Engine Feature Example";

            // Subscribe to Esc key:
            SubscribeToEvent<KeyDownEvent>(e => { if (e.Key == Constants.KEY_ESCAPE) BackToSelector(); });

            // Say Hello

            var layout = new UILayout();
            layout.Rect = UIView.Rect;

            layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_CENTER;
            layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_CENTER;

            var fontDesc = new UIFontDescription();
            fontDesc.Id = "Vera";
            fontDesc.Size = 24;

            var label = new UITextField();
            label.FontDescription = fontDesc;
            label.Text = "Hello World, from the Atomic Game Engine";
            layout.AddChild(label);

            UIView.AddChild(layout);

        }
Пример #2
0
        public SampleHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            buttonView = new UIView();
            Visible    = false;

            // Button images
            bSampleButton = new UIImage(TextureAssets.Item[ItemID.Paintbrush].Value);

            // Button tooltips
            bSampleButton.Tooltip = "Sample Tooltip";

            // Button EventHandlers
            bSampleButton.onLeftClick  += bSampleButton_onLeftClick;
            bSampleButton.onRightClick += (s, e) =>
            {
                // Sample handling
            };

            // Register mousedown
            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) =>
            {
                justMouseDown = true;
                mouseDown     = false;             /*startTileX = -1; startTileY = -1;*/
            };

            // ButtonView
            buttonView.AddChild(bSampleButton);

            Width             = 200f;
            Height            = 55f;
            buttonView.Height = Height;
            Anchor            = AnchorPosition.Top;
            AddChild(buttonView);
            Position = new Vector2(Hotbar.xPosition, hiddenPosition);
            CenterXAxisToParentCenter();
            float num = spacing;

            for (int i = 0; i < buttonView.children.Count; i++)
            {
                buttonView.children[i].Anchor   = AnchorPosition.Left;
                buttonView.children[i].Position = new Vector2(num, 0f);
                buttonView.children[i].CenterYAxisToParentCenter();
                buttonView.children[i].Visible         = true;
                buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += buttonView.children[i].Width + spacing;
            }

            Resize();
        }
Пример #3
0
    public static void ViewCode(String filename, UIWidget layoutParent)
    {
        var      cache  = GetSubsystem <ResourceCache> ();
        UIWindow window = new UIWindow();

        window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
        window.SetText("Code Viewer");
        window.Load("Scenes/view_code.ui.txt");
        File   filex = cache.GetFile(filename);
        string textx = filex.ReadText();

        filex.Close();
        UIWidget coder = window.GetWidget("viewCodeText");

        coder.SetText(textx);
        window.ResizeToFitContent();
        myuivew.AddChild(window);
        window.Center();
        UIWidget someok = window.GetWidget("viewCodeOK");

        someok.SubscribeToEvent <WidgetEvent> (someok, ev => {
            if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
            {
                UIWindow mywindow = (UIWindow)FindTheWindowParent(ev.Target);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
        });
    }
Пример #4
0
    public override void Start()
    {
        view = new UIView()
        {
            X = 0,
            Y = 0
        };

        fontDescription = new UIFontDescription()
        {
            Size = 22,
            Id   = "Anonymous Pro"
        };

        layout = new UILayout()
        {
            Axis           = UI_AXIS.UI_AXIS_Y,
            Rect           = view.Rect,
            LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_CENTER
        };

        view.AddChild(layout);

        CreateSceneLoadButton("Clear");
        CreateSceneLoadButton("Empty");
        CreateSceneLoadButton("Scene");

        // Setup debug hud to display metrics
        GetSubsystem <UI>().ShowDebugHud(true);
        GetSubsystem <UI>().SetDebugHudProfileMode(DebugHudProfileMode.DEBUG_HUD_PROFILE_METRICS);
    }
Пример #5
0
        // Recalculate buttons.
        void ServiceAddedOrRemoved(HEROsModService modifiedService)
        {
            // Clear existing icons in the Hotbar
            _iconView.RemoveAllChildren();
            // For each service, add its icon to the hotbar
            float xPos = Spacing;

            for (int i = 0; i < HEROsMod.ServiceController.Services.Count; i++)
            {
                HEROsModService service = HEROsMod.ServiceController.Services[i];
                if (service.HotbarIcon == null || !service.HasPermissionToUse)
                {
                    continue;
                }
                if (service.IsHotbar)
                {
                    service.Hotbar.buttonView.RemoveAllChildren();
                    service.Hotbar.test();
                }
                if (service.IsInHotbar /* && service.HotbarParent.buttonView != null*/)
                {
                    //ErrorLogger.Log("adding " + service.Name);
                    //ErrorLogger.Log("adding 1" + service.HotbarParent.ChildCount);
                    //ErrorLogger.Log("adding 3" + service.HotbarParent.buttonView.ChildCount);

                    UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon;
                    //icon.Anchor = AnchorPosition.Left;
                    //icon.X = xPos;
                    //icon.Y = 0;
                    //xPos += icon.Width + Spacing;
                    service.HotbarParent.buttonView.AddChild(icon);
                    //_iconView.AddChild(icon);
                    //icon.CenterYAxisToParentCenter();

                    service.HotbarParent.test();

                    //ModUtils.DebugText("added " + service.Name);
                }
                else
                {
                    UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon;
                    icon.Anchor = AnchorPosition.Left;
                    icon.X      = xPos;
                    icon.Y      = 0;
                    xPos       += icon.Width + Spacing;
                    _iconView.AddChild(icon);
                    icon.CenterYAxisToParentCenter();
                }
            }
            if (_iconView.ChildCount > 0)
            {
                this.Width      = _iconView.GetLastChild().X + _iconView.GetLastChild().Width + Spacing;
                _iconView.Width = this.Width;
            }
            collapseButton.CenterXAxisToParentCenter();
            collapseArrow.Position = collapseButton.Position;
        }
Пример #6
0
        private void PopulateSortView()
        {
            if (DefaultSorts == null)
            {
                DefaultSorts = new Sort[]
                {
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortItemID"))
                    {
                        Tooltip = HeroText("SortName.ItemID")
                    }, (x, y) => x.type.CompareTo(y.type)),
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortValue"))
                    {
                        Tooltip = HeroText("SortName.Value")
                    }, (x, y) => x.value.CompareTo(y.value)),
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortAZ"))
                    {
                        Tooltip = HeroText("SortName.Alphabetical")
                    }, (x, y) => x.Name.CompareTo(y.Name)),
                };
            }
            List <Sort> sorts = DefaultSorts.ToList();

            if (SelectedCategory != null)
            {
                if (SelectedCategory.ParentCategory != null)
                {
                    foreach (var item in SelectedCategory.ParentCategory.Sorts)
                    {
                        sorts.Add(item);
                    }
                }
                foreach (var item in SelectedCategory.Sorts)
                {
                    sorts.Add(item);
                }
            }

            AvailableSorts = sorts.ToArray();

            _sortView.RemoveAllChildren();
            _sortView.X = _spacer.X + _spacer.Width;
            float xPos = 0;

            for (int i = 0; i < AvailableSorts.Length; i++)
            {
                UIImage button = AvailableSorts[i].button;
                button.Width = 20;
                int x = i / 1;
                int y = i % 1;
                button.X = Spacing + x * (button.Width + Spacing);
                button.Y = Spacing + y * (button.Height + Spacing);
                xPos     = button.X + button.Width + Spacing;
                _sortView.AddChild(button);
            }
            _sortView.Width = xPos;
        }
Пример #7
0
        private void PopulateFilterView()
        {
            if (Filters == null)
            {
                Filters = new Filter[]
                {
                    new Filter(new UIImage(HEROsMod.instance.GetTexture("Images/filterMod"))
                    {
                        Tooltip = HeroText("FilterName.ModFilter")
                    }, x => x.modItem != null),
                };
            }
            //Category[] categories = Categories;
            //if (SelectedCategory != null)
            //{
            //	categories = SelectedCategory.SubCategories.ToArray();
            //	if (categories.Length == 0) return;
            //}

            _filterView.RemoveAllChildren();
            float xPos = 0;

            for (int i = 0; i < Filters.Length; i++)
            {
                Filter f = Filters[i];

                UIImage button = Filters[i].button;
                if (f.enabled)
                {
                    button.ForegroundColor = Color.White;
                }
                else
                {
                    button.ForegroundColor = Color.Gray;
                }

                //button.Tag = categories[i];
                //button.AutoSize = false;
                button.Width = 20;
                int x = i / 1;
                int y = i % 1;
                button.X = Spacing + x * (button.Width + Spacing);
                button.Y = Spacing + y * (button.Height + Spacing);
                //button.onLeftClick += (s, e) => {
                //	f.enabled = !f.enabled;
                //	Main.NewText(f.button.Tooltip + " " + f.enabled);
                //};
                //button.onLeftClick += (s, e) => Main.NewText(((UIImage)s).Tooltip);
                xPos = button.X + button.Width + Spacing;
                _filterView.AddChild(button);
            }
            _filterView.Width = xPos;
            _spacer.X         = _filterView.X + _filterView.Width;
        }
Пример #8
0
        void InitWindow()
        {
            var layout = new UILayout();

            layout.Axis = UI_AXIS.UI_AXIS_Y;

            var checkBox = new UICheckBox();

            checkBox.Id = "Checkbox";

            layout.AddChild(checkBox);

            var button = new UIButton();

            button.Text = "Button";
            button.Id   = "Button";

            layout.AddChild(button);

            var edit = new UIEditField();

            layout.AddChild(edit);
            edit.Id = "EditField";

            window          = new UIWindow();
            window.Settings = UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_TITLEBAR | UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON;

            window.Text = "Hello Atomic GUI!";

            window.AddChild(layout);

            window.ResizeToFitContent();

            UIView.AddChild(window);
            window.Center();

            SubscribeToEvent <WidgetEvent>(window, e =>
            {
                if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                {
                    var target = e.Target;
                    if (target != null)
                    {
                        window.Text = $"Hello: {target.Id}";
                    }
                }
            });

            SubscribeToEvent <WidgetDeletedEvent>(window, e =>
            {
                BackToSelector();
            });
        }
Пример #9
0
        public TestHotbarWindow()
        {
            this.buttonView                     = new UIView();
            base.Visible                        = false;
            bStampTiles                         = new UIImage(Main.itemTexture[ItemID.Paintbrush]);
            bEyeDropper                         = new UIImage(Main.itemTexture[ItemID.EmptyDropper]);
            bFlipHorizontal                     = new UIImage(Main.itemTexture[ItemID.PadThai]);
            bFlipVertical                       = new UIImage(Main.itemTexture[ItemID.Safe]);
            bToggleTransparentSelection         = new UIImage(Main.buffTexture[BuffID.Invisibility]);
            bStampTiles.Tooltip                 = "    Paint Tiles";
            bEyeDropper.Tooltip                 = "    Eye Dropper";
            bFlipHorizontal.Tooltip             = "    Flip Horizontal";
            bFlipVertical.Tooltip               = "    Flip Vertical";
            bToggleTransparentSelection.Tooltip = "    Toggle Transparent Selection: On";
            buttonView.AddChild(bStampTiles);
            buttonView.AddChild(bEyeDropper);
            buttonView.AddChild(bFlipHorizontal);
            buttonView.AddChild(bFlipVertical);
            buttonView.AddChild(bToggleTransparentSelection);
            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Position.X, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #10
0
        public SampleSelector()
        {
            sampleRef = null;

            var rootLayout = new UILayout();

            rootLayout.Axis = UI_AXIS.UI_AXIS_Y;
            rootLayout.Rect = UIView.Rect;
            UIView.AddChild(rootLayout);

            SubscribeToEvent <KeyDownEvent>(e =>
            {
                if (e.Key == Constants.KEY_ESCAPE)
                {
                    GetSubsystem <Engine>().Exit();
                }
            });

#if ATOMIC_DESKTOP || ATOMIC_MOBILE
            var sampleTypes = typeof(Sample).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Sample)) && t != typeof(Sample)).ToArray();
            foreach (var sample in sampleTypes)
            {
                var button = new UIButton();
                button.Text = sample.Name;

                button.SubscribeToEvent <WidgetEvent>(button, e =>
                {
                    // We're only interested in clicks
                    if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                    {
                        return;
                    }

                    // set the event as handled, as the UI is about to go away
                    e.Handled = true;

                    // Goodbye UI
                    UIView.RemoveChild(rootLayout);

                    sampleRef = (Sample)Activator.CreateInstance(sample);
                    sampleRef.Start();

                    UnsubscribeFromEvent <KeyDownEvent>();
                });


                rootLayout.AddChild(button);
            }
#endif
        }
Пример #11
0
    public override void Start()
    {
        Scene scene = AtomicNET.GetSubsystem <Player>().LoadScene("Scenes/Scene.scene");

        Vector <Camera> cameras = new Vector <Camera>();

        scene.GetComponents(cameras, true);

        Graphics graphics   = GetSubsystem <Graphics>();
        Renderer renderer   = GetSubsystem <Renderer>();
        int      numCameras = cameras.Count;

        views = new UIView[numCameras];
        renderer.SetNumViewports((uint)numCameras);
        int viewportWidth = graphics.Width / numCameras;

        for (int i = 0; i < numCameras; ++i)
        {
            Viewport viewport = new Viewport(scene, cameras[i]);
            viewport.Rect = new IntRect(
                i * viewportWidth, 0,
                (i + 1) * viewportWidth, graphics.Height);
            renderer.SetViewport((uint)i, viewport);

            UIView   view   = new UIView();
            UILayout layout = new UILayout()
            {
                // See for a layout cheatsheet: https://github.com/AtomicGameEngine/AtomicGameEngine/wiki/Turbobadger-Layout-Cheat-Sheet

                // Specifies which y position widgets in a AXIS_X layout should have, or which x position widgets in a AXIS_Y layout should have.
                LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM,

                // Specifies how widgets should be moved horizontally in a AXIS_X layout(or vertically in a AXIS_Y layout) if there is extra space available.
                LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM,

                Rect = viewport.Rect
            };
            layout.AddChild(new UITextField()
            {
                FontDescription = fontDescription,
                Text            = cameras[i].Node.Name
            });
            view.AddChild(layout);
            views[i] = view;
        }
    }
Пример #12
0
        private void PopulateSortView()
        {
            List <Sort> sorts = DefaultSorts.ToList();

            if (SelectedCategory != null)
            {
                if (SelectedCategory.ParentCategory != null)
                {
                    foreach (var item in SelectedCategory.ParentCategory.Sorts)
                    {
                        sorts.Add(item);
                    }
                }
                foreach (var item in SelectedCategory.Sorts)
                {
                    sorts.Add(item);
                }
            }

            AvailableSorts = sorts.ToArray();

            _sortView.RemoveAllChildren();
            _sortView.X = _spacer.X + _spacer.Width;
            float xPos = 0;

            for (int i = 0; i < AvailableSorts.Length; i++)
            {
                UIImage button = AvailableSorts[i].button;
                button.Width = 20;
                int x = i / 1;
                int y = i % 1;
                button.X = Spacing + x * (button.Width + Spacing);
                button.Y = Spacing + y * (button.Height + Spacing);
                xPos     = button.X + button.Width + Spacing;
                _sortView.AddChild(button);
            }
            _sortView.Width = xPos;
        }
Пример #13
0
        public Hotbar(CheatSheet mod)
        {
            this.mod        = mod;
            this.buttonView = new UIView();
            //	this.timeWindow = new TimeControlWindow();
            //	this.npcSpawnWindow = new NPCSpawnerWindow();
            //	this.weatherWindow = new WeatherControlWindow();
            //	this.timeWindow.Visible = false;
            //	this.npcSpawnWindow.Visible = false;
            //	this.weatherWindow.Visible = false;
            //	this.AddChild(this.timeWindow);
            //	this.AddChild(this.npcSpawnWindow);
            //	this.AddChild(this.weatherWindow);
            Hotbar.loginTexture  = mod.GetTexture("UI/Images.login");           // UIView.GetEmbeddedTexture("Images.login.png");
            Hotbar.logoutTexture = mod.GetTexture("UI/Images.logout");          //UIView.GetEmbeddedTexture("Images.logout.png");
            //	this.bLogin = new UIImage(Hotbar.loginTexture);
            //		bLogin = new UIImage(mod.GetTexture("UI/Images.login"));
            base.Visible = false;
            base.UpdateWhenOutOfBounds = true;
            //	Hotbar.groupWindow = new GroupManagementWindow();
            this.button = new UIImage(mod.GetTexture("UI/Images.CollapseBar.CollapseButtonHorizontal"));            //new UIImage(UIView.GetEmbeddedTexture("Images.CollapseBar.CollapseButtonHorizontal.png"));
            this.button.UpdateWhenOutOfBounds = true;
            this.arrow = new UIImage(mod.GetTexture("UI/Images.CollapseBar.CollapseArrowHorizontal"));              //new UIImage(UIView.GetEmbeddedTexture("Images.CollapseBar.CollapseArrowHorizontal.png"));

            //		bToggleEnemies = new UIImage(mod.GetTexture("UI/Images.npcIcon"));
            //		bToggleBlockReach = new UIImage(Main.itemTexture[407]);
            //		bFlyCamera = new UIImage(Main.itemTexture[493]);
            //		bRevealMap = new UIImage(mod.GetTexture("UI/Images.canIcon"));// Hotbar.mapTexture);
            //		bWaypoints = new UIImage(mod.GetTexture("UI/Images.waypointIcon"));
            //		bGroupManager = new UIImage(mod.GetTexture("UI/Images.manageGroups"));
            //		bOnlinePlayers = new UIImage(mod.GetTexture("UI/Images.connectedPlayers"));
            //		bTime = new UIImage(mod.GetTexture("UI/Images.sunIcon"));
            //		bWeatherWindow = new UIImage(Main.npcHeadTexture[2]);// WeatherControlWindow.rainTexture);
            //		bBackupWorld = new UIImage(mod.GetTexture("UI/Images.UIKit.saveIcon"));
            //		bCTFSettings = new UIImage(mod.GetTexture("UI/Images.CTF.redFlag"));

            //	Main.instance.LoadNPC(NPCID.KingSlime);

            bToggleItemBrowser        = new UIImage(Main.itemTexture[ItemID.WorkBench]);
            bToggleNPCBrowser         = new UIImage(mod.GetTexture("UI/Images.npcIcon"));
            bToggleClearMenu          = new UIImage(Main.itemTexture[ItemID.TrashCan]);
            bToggleRecipeBrowser      = new UIImage(Main.itemTexture[ItemID.CookingPot]);
            bToggleExtendedCheat      = new UIImage(Main.itemTexture[ItemID.CellPhone]);
            bTogglePaintTools         = new UIImage(Main.itemTexture[ItemID.Paintbrush]);
            bCycleExtraAccessorySlots = new UIImage(Main.itemTexture[ItemID.DemonHeart]);
            bVacuum              = new UIImage(mod.GetTexture("UI/Images.bVacuum"));
            bToggleNPCButcherer  = new UIImage(Main.itemTexture[ItemID.Skull]);
            bToggleQuickTeleport = new UIImage(Main.itemTexture[ItemID.WoodenDoor]);
            //bToggleEventManager = new UIImage(Main.itemTexture[ItemID.PirateMap]);

            this.arrow.UpdateWhenOutOfBounds = true;
            this.button.Anchor      = AnchorPosition.Top;
            this.arrow.Anchor       = AnchorPosition.Top;
            this.arrow.SpriteEffect = SpriteEffects.FlipVertically;
            this.AddChild(this.button);
            this.AddChild(this.arrow);
            this.button.Position = new Vector2(0f, -this.button.Height);
            this.button.CenterXAxisToParentCenter();
            //Do i need this?		this.button.X -= 40;
            this.arrow.Position     = this.button.Position;
            this.arrow.onLeftClick += new EventHandler(this.button_onLeftClick);
            //		this.bBackupWorld.onLeftClick += new EventHandler(this.bBackupWorld_onLeftClick);
            //		this.bToggleBlockReach.Tooltip = "Toggle Block Reach";
            //		this.bToggleEnemies.Tooltip = "Toggle Enemy Spawns";
            //		this.bFlyCamera.Tooltip = "Toggle Fly Cam";
            //		this.bRevealMap.Tooltip = "Reveal Map";
            //		this.bWaypoints.Tooltip = "Open Waypoints Window";
            //		this.bGroupManager.Tooltip = "Open Group Management";
            //		this.bOnlinePlayers.Tooltip = "View Connected Players";
            //		this.bTime.Tooltip = "Set Time";
            //		this.bWeatherWindow.Tooltip = "Control Rain";
            //		this.bLogin.Tooltip = "Login";
            //		this.bCTFSettings.Tooltip = "Capture the Flag Settings";
            //		this.bBackupWorld.Tooltip = "Backup World";
            this.bToggleItemBrowser.Tooltip   = CSText("ShowItemBrowser");
            this.bToggleClearMenu.Tooltip     = CSText("ShowClearMenu");
            this.bToggleNPCBrowser.Tooltip    = CSText("ShowNPCBrowser");
            bToggleRecipeBrowser.Tooltip      = CSText("ShowRecipeBrowser");
            bToggleExtendedCheat.Tooltip      = CSText("ShowModExtensionCheats");
            bTogglePaintTools.Tooltip         = CSText("ShowPaintTools");
            bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": ?";
            bVacuum.Tooltip              = CSText("VacuumItems");
            bToggleNPCButcherer.Tooltip  = CSText("ShowNPCButcherer");
            bToggleQuickTeleport.Tooltip = CSText("ShowQuickWaypoints");
            //		bToggleEventManager.Tooltip = "Show Event Manager";

            //		this.bToggleBlockReach.Opacity = Hotbar.disabledOpacity;
            //		this.bFlyCamera.Opacity = Hotbar.disabledOpacity;
            //		this.bToggleEnemies.Opacity = Hotbar.disabledOpacity;
            //		this.bToggleBlockReach.onLeftClick += new EventHandler(this.bToggleBlockReach_onLeftClick);
            //		this.bFlyCamera.onLeftClick += new EventHandler(this.bFlyCamera_onLeftClick);
            //		this.bToggleEnemies.onLeftClick += new EventHandler(this.bToggleEnemies_onLeftClick);
            //			this.bRevealMap.onLeftClick += new EventHandler(this.bRevealMap_onLeftClick);
            //			this.bWaypoints.onLeftClick += new EventHandler(this.bWaypoints_onLeftClick);
            //		this.bGroupManager.onLeftClick += new EventHandler(this.bGroupManager_onLeftClick);
            //		this.bOnlinePlayers.onLeftClick += new EventHandler(this.bOnlinePlayers_onLeftClick);
            //		this.bCTFSettings.onLeftClick += new EventHandler(this.bCTFSettings_onLeftClick);
            //		this.bLogin.onLeftClick += new EventHandler(this.bLogin_onLeftClick);
            //		this.bTime.onLeftClick += new EventHandler(this.bTime_onLeftClick);
            //		this.bWeatherWindow.onLeftClick += new EventHandler(this.bWeatherWindow_onLeftClick);
            this.bToggleItemBrowser.onLeftClick += new EventHandler(this.bToggleItemBrowser_onLeftClick);
            this.bToggleClearMenu.onLeftClick   += new EventHandler(this.bClearItems_onLeftClick);
            this.bToggleClearMenu.onRightClick  += (s, e) =>
            {
                QuickClearHotbar.HandleQuickClear();
            };
            this.bToggleNPCBrowser.onLeftClick         += new EventHandler(this.bToggleNPCBrowser_onLeftClick);
            this.bToggleRecipeBrowser.onLeftClick      += new EventHandler(this.bToggleRecipeBrowser_onLeftClick);
            this.bToggleExtendedCheat.onLeftClick      += new EventHandler(this.bToggleExtendedCheat_onLeftClick);
            this.bTogglePaintTools.onLeftClick         += new EventHandler(this.bTogglePaintTools_onLeftClick);
            this.bCycleExtraAccessorySlots.onLeftClick += (s, e) =>
            {
                CheatSheetPlayer cheatSheetPlayer = Main.LocalPlayer.GetModPlayer <CheatSheetPlayer>();
                cheatSheetPlayer.numberExtraAccessoriesEnabled = (cheatSheetPlayer.numberExtraAccessoriesEnabled + 1) % (CheatSheetPlayer.MaxExtraAccessories + 1);
                bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": " + cheatSheetPlayer.numberExtraAccessoriesEnabled;
            };
            this.bCycleExtraAccessorySlots.onRightClick += (s, e) =>
            {
                CheatSheetPlayer cheatSheetPlayer = Main.LocalPlayer.GetModPlayer <CheatSheetPlayer>();
                cheatSheetPlayer.numberExtraAccessoriesEnabled = cheatSheetPlayer.numberExtraAccessoriesEnabled == 0 ? 0 : (cheatSheetPlayer.numberExtraAccessoriesEnabled - 1) % (CheatSheetPlayer.MaxExtraAccessories + 1);
                bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": " + cheatSheetPlayer.numberExtraAccessoriesEnabled;
            };
            this.bVacuum.onLeftClick              += new EventHandler(this.bVacuum_onLeftClick);
            this.bToggleNPCButcherer.onLeftClick  += new EventHandler(this.bButcher_onLeftClick);
            this.bToggleNPCButcherer.onRightClick += (s, e) =>
            {
                NPCButchererHotbar.HandleButcher();
            };
            this.bToggleQuickTeleport.onLeftClick  += new EventHandler(this.bToggleQuickTeleport_onLeftClick);
            this.bToggleQuickTeleport.onRightClick += (s, e) =>
            {
                //QuickTeleportHotbar.TeleportPlayer(Main.LocalPlayer, new Vector2(Main.spawnTileX, Main.spawnTileY), true);
                QuickTeleportHotbar.HandleTeleport();
            };
            //		this.bToggleEventManager.onLeftClick += new EventHandler(this.bToggleEventManager_onLeftClick);

            //		this.buttonView.AddChild(this.bToggleBlockReach);
            //		this.buttonView.AddChild(this.bFlyCamera);
            //		this.buttonView.AddChild(this.bToggleEnemies);
            //		this.buttonView.AddChild(this.bRevealMap);
            //		this.buttonView.AddChild(this.bWaypoints);
            //		this.buttonView.AddChild(this.bTime);
            //			this.buttonView.AddChild(this.bWeatherWindow);
            //			this.buttonView.AddChild(this.bGroupManager);
            //			this.buttonView.AddChild(this.bOnlinePlayers);
            //			this.buttonView.AddChild(this.bCTFSettings);
            //			this.buttonView.AddChild(this.bLogin);
            //			this.buttonView.AddChild(this.bBackupWorld);

            buttonView.AddChild(bToggleItemBrowser);
            buttonView.AddChild(bToggleNPCBrowser);
            buttonView.AddChild(bToggleRecipeBrowser);
            buttonView.AddChild(bToggleExtendedCheat);
            buttonView.AddChild(bToggleClearMenu);
            buttonView.AddChild(bTogglePaintTools);
            buttonView.AddChild(bCycleExtraAccessorySlots);
            buttonView.AddChild(bVacuum);
            buttonView.AddChild(bToggleNPCButcherer);
            buttonView.AddChild(bToggleQuickTeleport);
            //			buttonView.AddChild(bToggleEventManager);
            buttonView.AddChild(SpawnRateMultiplier.GetButton(mod));
            buttonView.AddChild(MinionSlotBooster.GetButton(mod));
            buttonView.AddChild(LightHack.GetButton(mod));
            buttonView.AddChild(GodMode.GetButton(mod));
            //	buttonView.AddChild(FullBright.GetButton(mod));
            //			buttonView.AddChild(BossDowner.GetButton(mod));
            buttonView.AddChild(ConfigurationTool.GetButton(mod));

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            //	Hotbar.groupWindow.Visible = false;
            //	MasterView.gameScreen.AddChild(Hotbar.groupWindow);
            ChangedConfiguration();
            //this.Resize();
            return;
        }
Пример #14
0
        public QuickClearHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            buttonView = new UIView();
            Visible    = false;

            Main.instance.LoadItem(ItemID.WoodenSword);
            Main.instance.LoadItem(ItemID.WoodenArrow);

            // Button images
            bItems       = new UIImage(TextureAssets.Item[ItemID.WoodenSword].Value);
            bProjectiles = new UIImage(TextureAssets.Item[ItemID.WoodenArrow].Value);
            bBuffs       = new UIImage(TextureAssets.Buff[BuffID.Honey].Value);
            bDebuffs     = new UIImage(TextureAssets.Buff[BuffID.Poisoned].Value);

            // Button tooltips
            bItems.Tooltip       = CSText("ClearDroppedItems");
            bProjectiles.Tooltip = CSText("ClearProjectiles");
            bBuffs.Tooltip       = CSText("ClearBuffs");
            bDebuffs.Tooltip     = CSText("ClearDebuffs");

            // Button EventHandlers
            bItems.onLeftClick       += (s, e) => { HandleQuickClear(); };
            bProjectiles.onLeftClick += (s, e) => { HandleQuickClear(1); };
            bBuffs.onLeftClick       += (s, e) => { HandleQuickClear(2); };
            bDebuffs.onLeftClick     += (s, e) => { HandleQuickClear(3); };

            // Register mousedown
            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) =>
            {
                justMouseDown = true;
                mouseDown     = false;             /*startTileX = -1; startTileY = -1;*/
            };

            // ButtonView
            buttonView.AddChild(bItems);
            buttonView.AddChild(bProjectiles);
            buttonView.AddChild(bBuffs);
            buttonView.AddChild(bDebuffs);

            Width             = 200f;
            Height            = 55f;
            buttonView.Height = Height;
            Anchor            = AnchorPosition.Top;
            AddChild(buttonView);
            Position = new Vector2(Hotbar.xPosition, hiddenPosition);
            CenterXAxisToParentCenter();
            float num = spacing;

            for (int i = 0; i < buttonView.children.Count; i++)
            {
                buttonView.children[i].Anchor   = AnchorPosition.Left;
                buttonView.children[i].Position = new Vector2(num, 0f);
                buttonView.children[i].CenterYAxisToParentCenter();
                buttonView.children[i].Visible         = true;
                buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += buttonView.children[i].Width + spacing;
            }

            Resize();
        }
Пример #15
0
        public QuickTeleportHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            this.buttonView = new UIView();
            base.Visible    = false;
            //base.UpdateWhenOutOfBounds = true;

            bDungeon = new UIImage(Main.itemTexture[ItemID.DungeonDoor]);
            bSpawn   = new UIImage(Main.itemTexture[ItemID.WoodenDoor]);
            bHell    = new UIImage(Main.itemTexture[ItemID.ObsidianDoor]);
            bTemple  = new UIImage(Main.itemTexture[ItemID.LihzahrdDoor]);
            bRandom  = new UIImage(Main.itemTexture[ItemID.SpookyDoor]);

            bDungeon.Tooltip = "Dungeon";
            bSpawn.Tooltip   = "Spawnpoint";
            bHell.Tooltip    = "Hell";
            bTemple.Tooltip  = "Temple";
            bRandom.Tooltip  = "Random";

            bDungeon.onLeftClick += (s, e) =>
            {
                HandleTeleport();
            };
            bSpawn.onLeftClick += (s, e) =>
            {
                HandleTeleport(1);
            };
            bHell.onLeftClick += (s, e) =>
            {
                HandleTeleport(2);
            };
            bTemple.onLeftClick += (s, e) =>
            {
                HandleTeleport(3);
            };
            bRandom.onLeftClick += (s, e) =>
            {
                HandleTeleport(4);
            };

            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) => { justMouseDown = true; mouseDown = false; /*startTileX = -1; startTileY = -1;*/ };

            //UpdateWhenOutOfBounds = true;

            buttonView.AddChild(bDungeon);
            buttonView.AddChild(bSpawn);
            buttonView.AddChild(bHell);
            buttonView.AddChild(bTemple);
            buttonView.AddChild(bRandom);

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #16
0
        public PaintToolsHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            this.buttonView = new UIView();
            base.Visible    = false;
            //base.UpdateWhenOutOfBounds = true;

            //		bDecreaseBrushSize = new UIImage(Main.itemTexture[ItemID.CopperShortsword]);
            //		bIncreaseBrushSize = new UIImage(Main.itemTexture[ItemID.CrossNecklace]);
            bStampTiles                 = new UIImage(Main.itemTexture[ItemID.Paintbrush]);
            bEyeDropper                 = new UIImage(Main.itemTexture[ItemID.EmptyDropper]);
            bFlipHorizontal             = new UIImage(mod.GetTexture("CustomUI/Horizontal"));
            bFlipVertical               = new UIImage(mod.GetTexture("CustomUI/Vertical"));
            bToggleTransparentSelection = new UIImage(Main.buffTexture[BuffID.Invisibility]);

            //		this.bIncreaseBrushSize.Tooltip = "    Increase Brush Size";
            //		this.bDecreaseBrushSize.Tooltip = "    Decrease Brush Size";
            bStampTiles.Tooltip                 = "    Paint Tiles";
            bEyeDropper.Tooltip                 = "    Eye Dropper";
            bFlipHorizontal.Tooltip             = "    Flip Horizontal";
            bFlipVertical.Tooltip               = "    Flip Vertical";
            bToggleTransparentSelection.Tooltip = "    Toggle Transparent Selection: Off";

            //		this.bIncreaseBrushSize.onLeftClick += (s, e) => brushSize = Math.Min(10, brushSize + 1);
            //		this.bDecreaseBrushSize.onLeftClick += (s, e) => brushSize = Math.Max(1, brushSize - 1);
            bStampTiles.onLeftClick   += new EventHandler(this.bTogglePaintTiles_onLeftClick);
            bEyeDropper.onLeftClick   += new EventHandler(this.bToggleEyeDropper_onLeftClick);
            bFlipVertical.onLeftClick += (s, e) =>
            {
                for (int i = 0; i < StampTiles.GetLength(0); i++)
                {
                    for (int j = 0; j < StampTiles.GetLength(1) / 2; j++)
                    {
                        Utils.Swap(ref StampTiles[i, j], ref StampTiles[i, StampTiles.GetLength(1) - 1 - j]);
                    }
                }
                if (stampInfo != null)
                {
                    stampInfo.bFlipVertical = !stampInfo.bFlipVertical;
                }
            };
            bFlipHorizontal.onLeftClick += (s, e) =>
            {
                for (int j = 0; j < StampTiles.GetLength(1); j++)
                {
                    for (int i = 0; i < StampTiles.GetLength(0) / 2; i++)
                    {
                        Utils.Swap(ref StampTiles[i, j], ref StampTiles[StampTiles.GetLength(0) - 1 - i, j]);
                    }
                }
                if (stampInfo != null)
                {
                    stampInfo.bFlipHorizontal = !stampInfo.bFlipHorizontal;
                }
            };
            bToggleTransparentSelection.onLeftClick += (s, e) => { TransparentSelectionEnabled = !TransparentSelectionEnabled; bToggleTransparentSelection.Tooltip = TransparentSelectionEnabled ? "    Toggle Transparent Selection: On" : "    Toggle Transparent Selection: Off"; };

            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside && !UIView.MouseRightButton)
                {
                    leftMouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside && (!UIView.MousePrevRightButton || (UIView.MousePrevLeftButton && !UIView.MouseLeftButton)))
                {
                    justLeftMouseDown = true; leftMouseDown = false;                     /*startTileX = -1; startTileY = -1;*/
                }
            };

            //UpdateWhenOutOfBounds = true;

            //	buttonView.AddChild(bDecreaseBrushSize);
            //		buttonView.AddChild(bIncreaseBrushSize);
            buttonView.AddChild(bStampTiles);
            buttonView.AddChild(bEyeDropper);
            buttonView.AddChild(bFlipHorizontal);
            buttonView.AddChild(bFlipVertical);
            buttonView.AddChild(bToggleTransparentSelection);

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #17
0
        public PaintToolsUI(CheatSheet mod)
        {
            categories.Clear();
            this.view          = new PaintToolsView();
            this.mod           = mod;
            this.CanMove       = true;
            base.Width         = this.view.Width + this.spacing * 2f;
            base.Height        = 35f + this.view.Height + this.spacing * 2f;
            this.view.Position = new Vector2(this.spacing, 55f);
            this.AddChild(this.view);

            Texture2D texture = mod.GetTexture("UI/closeButton");
            UIImage   uIImage = new UIImage(texture);

            uIImage.Anchor       = AnchorPosition.TopRight;
            uIImage.Position     = new Vector2(base.Width - this.spacing, this.spacing);
            uIImage.onLeftClick += new EventHandler(this.bClose_onLeftClick);
            this.AddChild(uIImage);

            var snaptexture = mod.GetTexture("UI/Snap");

            btnSnap = new UIImageListButton(
                (new ImageList(mod.GetTexture("UI/Snap"), 28, 28)).listTexture,
                new List <object>()
            {
                SnapType.TopLeft, SnapType.TopCenter, SnapType.TopRight,
                SnapType.LeftCenter, SnapType.Center, SnapType.RightCenter,
                SnapType.BottomLeft, SnapType.BottomCenter, SnapType.BottomRight,
            },
                new List <string>()
            {
                CSText("SnapTopLeft"), CSText("SnapTopCenter"), CSText("SnapTopRight"),
                CSText("SnapLeftCenter"), CSText("SnapCenter"), CSText("SnapRightCenter"),
                CSText("SnapBottomLeft"), CSText("SnapBottomCenter"), CSText("SnapBottomRight"),
            },
                4);
            btnSnap.onLeftClick  += (a, b) => btnSnap.NextIamge();
            btnSnap.onRightClick += (a, b) => btnSnap.PrevIamge();
            btnSnap.Position      = new Vector2(this.spacing, this.spacing);
            this.AddChild(btnSnap);

            var position = btnSnap.Position;

            uIImage              = new UIImage(Main.itemTexture[ItemID.TrashCan]);
            position             = position.Offset(btnSnap.Width + this.spacing, 0);
            uIImage.Position     = position;
            uIImage.onLeftClick += (a, b) => view.RemoveSelectedItem();
            uIImage.Tooltip      = CSText("DeleteSelection");
            this.AddChild(uIImage);

            uIImage              = new UIImage(Main.itemTexture[ItemID.AlphabetStatueI]);
            position             = position.Offset(uIImage.Width + this.spacing, 0);
            uIImage.Position     = position;
            uIImage.onLeftClick += (a, b) => PaintToolsEx.Import(this.view);
            uIImage.Tooltip      = CSText("ImportData");
            this.AddChild(uIImage);

            uIImage              = new UIImage(Main.itemTexture[ItemID.AlphabetStatueE]);
            position             = position.Offset(uIImage.Width + this.spacing, 0);
            uIImage.Position     = position;
            uIImage.onLeftClick += (a, b) => PaintToolsEx.Export(this.view);
            uIImage.Tooltip      = CSText("ExportData");
            this.AddChild(uIImage);

            uIImage              = new UIImage(Main.itemTexture[ItemID.AlphabetStatueW]);
            position             = position.Offset(uIImage.Width + this.spacing, 0);
            uIImage.Position     = position;
            uIImage.onLeftClick += (a, b) => PaintToolsEx.OnlineImport(this.view);
            uIImage.Tooltip      = "Load Online Schematics Database";
            this.AddChild(uIImage);

            infoPanel                 = new UIView();
            position                  = position.Offset(uIImage.Width + this.spacing, 0);
            infoPanel.Position        = position;
            infoPanel.Y               = 6;
            infoPanel.Width           = 210;
            infoPanel.Height          = 44;
            infoPanel.ForegroundColor = Color.Thistle;
            AddChild(infoPanel);

            infoMessage          = new UILabel("Message Here");
            infoMessage.Scale    = 0.35f;
            infoMessage.Position = new Vector2(30, 10);
            infoPanel.AddChild(infoMessage);

            upVoteButton              = new UIImage(CheatSheet.instance.GetTexture("UI/VoteUp"));
            upVoteButton.Position     = new Vector2(0, 0);
            upVoteButton.onLeftClick += (a, b) => Vote(true);
            upVoteButton.Tooltip      = "Vote Up";
            infoPanel.AddChild(upVoteButton);

            downVoteButton              = new UIImage(CheatSheet.instance.GetTexture("UI/VoteDown"));
            downVoteButton.Position     = new Vector2(0, 24);
            downVoteButton.onLeftClick += (a, b) => Vote(false);
            downVoteButton.Tooltip      = "Vote Down";
            infoPanel.AddChild(downVoteButton);

            infoPanel.Visible = false;

            submitPanel          = new UIView();
            submitPanel.Position = position;
            submitPanel.Y        = 6;
            submitPanel.Width    = 210;
            submitPanel.Height   = 44;
            AddChild(submitPanel);

            submitLabel          = new UILabel("Submit Name:");
            submitLabel.Scale    = 0.35f;
            submitLabel.Position = new Vector2(0, 0);
            submitPanel.AddChild(submitLabel);

            submitInput          = new UITextbox();
            submitInput.Position = new Vector2(0, 20);
            submitInput.Width    = 200;
            submitPanel.AddChild(submitInput);

            submitButton              = new UIImage(Terraria.Graphics.TextureManager.Load("Images/UI/ButtonCloudActive"));
            submitButton.Position     = new Vector2(178, -2);
            submitButton.onLeftClick += (a, b) => Submit();
            submitButton.Tooltip      = "Submit to Schematics Browser";
            submitPanel.AddChild(submitButton);

            submitPanel.Visible = false;
        }
Пример #18
0
    private static void HandleUilayoutEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "go_layout_config")    // its LAYOUT-O-MATIC time.
            {
                AtomicMain.AppLog("UILayout action : " + widget.GetId() + " was pressed, its LAYOUT-O-MATIC time");
                UIView   someview = widget.GetView();
                UIWindow window   = new UIWindow();
                window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
                window.SetText("LAYOUT-O-MATIC(tm)");
                window.Load("Scenes/view_layout.ui.txt");
                window.ResizeToFitContent();
                someview.AddChild(window);

                UIWidget okbutt = window.GetWidget("ok");
                okbutt.SubscribeToEvent <WidgetEvent> (okbutt, HandleUilayoutEvent);

                var lox = new AtomicEngine.Vector <AtomicEngine.UIWidget>();
                window.SearchWidgetClass("TBRadioButton", lox);
                for (var ii = 0; ii < lox.Size; ii++)
                {
                    lox[ii].SubscribeToEvent <WidgetEvent> (lox [ii], HandleUilayoutEvent);
                }
            }
            if (widget.GetId() == "ok")
            {
                UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
            if (widget.GetId() == "set_ax")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'X');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_ay")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'Y');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_sza")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }


            if (widget.GetId() == "set_posc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dista")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dpc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
        }
    }
Пример #19
0
        public QuickClearHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            this.buttonView = new UIView();
            base.Visible    = false;

            // Button images
            bItems       = new UIImage(Main.itemTexture[ItemID.WoodenSword]);
            bProjectiles = new UIImage(Main.itemTexture[ItemID.WoodenArrow]);
            bBuffs       = new UIImage(Main.buffTexture[BuffID.Honey]);
            bDebuffs     = new UIImage(Main.buffTexture[BuffID.Poisoned]);

            // Button tooltips
            bItems.Tooltip       = "Clear dropped items";
            bProjectiles.Tooltip = "Clear projectiles";
            bBuffs.Tooltip       = "Clear buffs";
            bDebuffs.Tooltip     = "Clear debuffs";

            // Button EventHandlers
            bItems.onLeftClick += (s, e) =>
            {
                HandleQuickClear();
            };
            bProjectiles.onLeftClick += (s, e) =>
            {
                HandleQuickClear(1);
            };
            bBuffs.onLeftClick += (s, e) =>
            {
                HandleQuickClear(2);
            };
            bDebuffs.onLeftClick += (s, e) =>
            {
                HandleQuickClear(3);
            };

            // Register mousedown
            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) => { justMouseDown = true; mouseDown = false; /*startTileX = -1; startTileY = -1;*/ };

            // ButtonView
            buttonView.AddChild(bItems);
            buttonView.AddChild(bProjectiles);
            buttonView.AddChild(bBuffs);
            buttonView.AddChild(bDebuffs);

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #20
0
        void CreateUI()
        {
            var cache = GetSubsystem <ResourceCache>();

            var layout = new UILayout()
            {
                Axis = UI_AXIS.UI_AXIS_Y
            };

            layout.Rect = UIView.Rect;
            UIView.AddChild(layout);

            // Create a scene which will not be actually rendered, but is used to hold SoundSource components while they play sounds
            scene = new Scene();

            // Create buttons for playing back sounds
            foreach (var item in sounds)
            {
                var button = new UIButton();
                layout.AddChild(button);
                button.Text = item.Key;

                button.SubscribeToEvent <WidgetEvent>(button, e => {
                    if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                    {
                        // Get the sound resource
                        Sound sound = cache.Get <Sound>(item.Value);
                        if (sound != null)
                        {
                            // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays
                            // non-positional audio, so its 3D position in the scene does not matter. For positional sounds the
                            // SoundSource3D component would be used instead
                            Node soundNode          = scene.CreateChild("Sound");
                            SoundSource soundSource = soundNode.CreateComponent <SoundSource>();
                            soundSource.Play(sound);
                            // In case we also play music, set the sound volume below maximum so that we don't clip the output
                            soundSource.Gain = 0.75f;
                            // Set the sound component to automatically remove its scene node from the scene when the sound is done playing
                        }
                    }
                });
            }

            // Create buttons for playing/stopping music
            var playMusicButton = new UIButton();

            layout.AddChild(playMusicButton);
            playMusicButton.Text = "Play Music";
            playMusicButton.SubscribeToEvent <WidgetEvent> (playMusicButton, e => {
                if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                {
                    return;
                }

                if (scene.GetChild("Music", false) != null)
                {
                    return;
                }

                var music               = cache.Get <Sound>("Music/StoryTime.ogg");
                music.Looped            = true;
                Node musicNode          = scene.CreateChild("Music");
                SoundSource musicSource = musicNode.CreateComponent <SoundSource> ();
                // Set the sound type to music so that master volume control works correctly
                musicSource.SetSoundType("Music");
                musicSource.Play(music);
            });

            var audio = GetSubsystem <Audio>();

            // FIXME: Removing the music node is not stopping music
            var stopMusicButton = new UIButton();

            layout.AddChild(stopMusicButton);
            stopMusicButton.Text = "Stop Music";
            stopMusicButton.SubscribeToEvent <WidgetEvent>(stopMusicButton, e =>
            {
                if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                {
                    return;
                }

                scene.RemoveChild(scene.GetChild("Music", false));
            });

            // Effect Volume Slider
            var slider = new UISlider();

            layout.AddChild(slider);
            slider.SetLimits(0, 1);
            slider.Text = "Sound Volume";

            slider.SubscribeToEvent <WidgetEvent>(slider, e =>
            {
                if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
                {
                    return;
                }

                Log.Info($"Setting Effects to {slider.Value}");
                audio.SetMasterGain("Effect", slider.Value);
            });

            // Music Volume Slider
            var slider2 = new UISlider();

            layout.AddChild(slider2);
            slider2.SetLimits(0, 1);
            slider2.Text = "Music Volume";

            slider2.SubscribeToEvent <WidgetEvent>(slider2, e =>
            {
                if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
                {
                    return;
                }

                Log.Info($"Setting Music to {slider2.Value}");
                audio.SetMasterGain("Music", slider2.Value);
            });
        }
Пример #21
0
    public override void Start()
    {
        AtomicNET.GetSubsystem <Player> ().LoadScene("Scenes/Scene.scene");

        var ui = GetSubsystem <UI> ();

        ui.AddFont("Textures/BrokenGlass.ttf", "BrokenGlass"); // add a gooder font
        ui.LoadSkin("Textures/desktop.tb.txt");                // load in the app skin

        ResourceCache cache    = GetSubsystem <ResourceCache> ();
        Graphics      graphics = GetSubsystem <Graphics> ();

        graphics.SetWindowTitle("PeriodicApp");
        Image icon = cache.GetResource <Image> ("Textures/AtomicLogo32.png");

        graphics.SetWindowIcon(icon);

        myuivew  = new UIView();
        mylayout = new UILayout();                  // make the host widget for all visible ui
        mylayout.SetId("UIPeriodicTable");          // tag it, like a big game scientist
        mylayout.SetRect(myuivew.GetRect());        //size it to fill the screen area
        mylayout.SetLayoutConfig("YAGAC");          //all-in-one setting
        mylayout.SetSkinBg("background_solid");     // make it look gooder
        mylayout.Load("Scenes/main_layout.ui.txt"); // load the main layout
        myuivew.AddChild(mylayout);                 // And make it show up.

        UITabContainer maintb    = (UITabContainer)mylayout.GetWidget("maintabs");
        UITabContainer acttb     = (UITabContainer)mylayout.GetWidget("primarytabs");
        UITabContainer semitb    = (UITabContainer)mylayout.GetWidget("moretabs");
        UITabContainer viewtb    = (UITabContainer)mylayout.GetWidget("supporttabs");
        UITabContainer supporttb = (UITabContainer)mylayout.GetWidget("atomictabs");

        supporttb.SetCurrentPage(0);
        viewtb.SetCurrentPage(0);
        semitb.SetCurrentPage(0);
        acttb.SetCurrentPage(0);
        maintb.SetCurrentPage(0);  // do this or else the tab contents look like crap!
        mylog = (UITextField)mylayout.GetWidget("LogText");
        UIWidget ea = mylayout.GetWidget("exitapp");

        var cota = new code_table();

        cota.Setup(mylayout);
        var cobg = new code_uibargraph();

        cobg.Setup(mylayout.GetWidget("pageuibargraph"));
        var cobu = new code_uibutton();

        cobu.Setup(mylayout.GetWidget("pageuibutton"));
        var cocb = new code_uicheckbox();

        cocb.Setup(mylayout.GetWidget("pageuicheckbox"));
        var cocl = new code_uiclicklabel();

        cocl.Setup(mylayout.GetWidget("pageuiclicklabel"));
        var coch = new code_uicolorwheel();

        coch.Setup(mylayout.GetWidget("pageuicolorwheel"));
        var cocw = new code_uicolorwidget();

        cocw.Setup(mylayout.GetWidget("pageuicolorwidget"));
        var coco = new code_uicontainer();

        coco.Setup(mylayout.GetWidget("pageuicontainer"));
        var coef = new code_uieditfield();

        coef.Setup(mylayout.GetWidget("pageuieditfield"));
        var cofw = new code_uifinderwindow();

        cofw.Setup(mylayout.GetWidget("pageuifinderwindow"));
        var cofd = new code_uifontdescription();

        cofd.Setup(mylayout.GetWidget("pageuifontdescription"));
        var coiw = new code_uiimagewidget();

        coiw.Setup(mylayout.GetWidget("pageuiimagewidget"));
        var cois = new code_uiinlineselect();

        cois.Setup(mylayout.GetWidget("pageuiinlineselect"));
        var colo = new code_uilayout();

        colo.Setup(mylayout.GetWidget("pageuilayout"));
        var colp = new code_uilayoutparams();

        colp.Setup(mylayout.GetWidget("pageuilayoutparams"));
        var comi = new code_uimenuitem();

        comi.Setup(mylayout.GetWidget("pageuimenuitem"));
        var comw = new code_uimenuwindow();

        comw.Setup(mylayout.GetWidget("pageuimenuwindow"));
        var come = new code_uimessagewindow();

        come.Setup(mylayout.GetWidget("pageuimessagewindow"));
        var copw = new code_uipromptwindow();

        copw.Setup(mylayout.GetWidget("pageuipromptwindow"));
        var copd = new code_uipulldownmenu();

        copd.Setup(mylayout.GetWidget("pageuipulldownmenu"));
        var corb = new code_uiradiobutton();

        corb.Setup(mylayout.GetWidget("pageuiradiobutton"));
        var cosv = new code_uisceneview();

        cosv.Setup(mylayout.GetWidget("pageuisceneview"));
        var cosb = new code_uiscrollbar();

        cosb.Setup(mylayout.GetWidget("pageuiscrollbar"));
        var cosc = new code_uiscrollcontainer();

        cosc.Setup(mylayout.GetWidget("pageuiscrollcontainer"));
        var cose = new code_uisection();

        cose.Setup(mylayout.GetWidget("pageuisection"));
        var cosd = new code_uiselectdropdown();

        cosd.Setup(mylayout.GetWidget("pageuiselectdropdown"));
        var cosi = new code_uiselectitem();

        cosi.Setup(mylayout.GetWidget("pageuiselectitem"));
        var cosl = new code_uiselectlist();

        cosl.Setup(mylayout.GetWidget("pageuiselectlist"));
        var cosp = new code_uiseparator();

        cosp.Setup(mylayout.GetWidget("pageuiseparator"));
        var cosk = new code_uiskinimage();

        cosk.Setup(mylayout.GetWidget("pageuiskinimage"));
        var cosa = new code_uislider();

        cosa.Setup(mylayout.GetWidget("pageuislider"));
        var cotc = new code_uitabcontainer();

        cotc.Setup(mylayout.GetWidget("pageuitabcontainer"));
        var cotf = new code_uitextfield();

        cotf.Setup(mylayout.GetWidget("pageuitextfield"));
        var cotw = new code_uitexturewidget();

        cotw.Setup(mylayout.GetWidget("pageuitexturewidget"));
        var cowd = new code_uiwidget();

        cowd.Setup(mylayout.GetWidget("pageuiwidget"));
        var cowi = new code_uiwindow();

        cowi.Setup(mylayout.GetWidget("pageuiwindow"));

        SubscribeToEvent <WidgetEvent> (ea, ev => {
            if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
            {
                GetSubsystem <Engine> ().Exit();
            }
        });

        SubscribeToEvent <KeyDownEvent> (e => {
            if (e.Key == Constants.KEY_ESCAPE)
            {
                GetSubsystem <Engine> ().Exit();
            }
        });
    }
Пример #22
0
        public EventManagerHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            this.buttonView = new UIView();
            base.Visible    = false;

            // Button images
            bGoblinInvasion = new UIImage(Main.itemTexture[ItemID.GoblinBattleStandard]);
            bBloodmoon      = new UIImage(Main.itemTexture[ItemID.PiggyBank]);
            bSlimerain      = new UIImage(Main.itemTexture[ItemID.RoyalGel]);
            bFrostlegion    = new UIImage(Main.itemTexture[ItemID.SnowGlobe]);
            bSolarEclipse   = new UIImage(Main.itemTexture[ItemID.SolarTablet]);
            bPirateInvasion = new UIImage(Main.itemTexture[ItemID.PirateMap]);
            bPumpkinMoon    = new UIImage(Main.itemTexture[ItemID.PumpkinMoonMedallion]);
            bFrostMoon      = new UIImage(Main.itemTexture[ItemID.NaughtyPresent]);
            bMartianMadness = new UIImage(Main.itemTexture[ItemID.MartianSaucerTrophy]);
            bStopEvents     = new UIImage(Main.itemTexture[ItemID.AlphabetStatueX]);

            // Button tooltips
            bGoblinInvasion.Tooltip = "Summon a Goblin Invasion";
            bBloodmoon.Tooltip      = "Start a bloodmoon";
            bSlimerain.Tooltip      = "Start a slimerain";
            bFrostlegion.Tooltip    = "Summon a Frost Legion";
            bSolarEclipse.Tooltip   = "Start a solar eclipse";
            bPirateInvasion.Tooltip = "Summon a Pirate Invasion";
            bPumpkinMoon.Tooltip    = "Start a pumpkin moon";
            bFrostMoon.Tooltip      = "Start a frost moon";
            bMartianMadness.Tooltip = "Start a martian madness";
            bStopEvents.Tooltip     = "Stop all events";

            // Button EventHandlers
            bGoblinInvasion.onLeftClick += new EventHandler(this.bGoblinInvasion_onLeftClick);
            bBloodmoon.onLeftClick      += new EventHandler(this.bBloodmoon_onLeftClick);
            bSlimerain.onLeftClick      += new EventHandler(this.bSlimerain_onLeftClick);
            bFrostlegion.onLeftClick    += new EventHandler(this.bFrostlegion_onLeftClick);
            bSolarEclipse.onLeftClick   += new EventHandler(this.bSolarEclipse_onLeftClick);
            bPirateInvasion.onLeftClick += new EventHandler(this.bPirateInvasion_onLeftClick);
            bPumpkinMoon.onLeftClick    += new EventHandler(this.bPumpkinMoon_onLeftClick);
            bFrostMoon.onLeftClick      += new EventHandler(this.bFrostMoon_onLeftClick);
            bMartianMadness.onLeftClick += new EventHandler(this.bMartianMadness_onLeftClick);
            bStopEvents.onLeftClick     += new EventHandler(this.bStopEvents_onLeftClick);

            // Register mousedown
            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) => { justMouseDown = true; mouseDown = false; /*startTileX = -1; startTileY = -1;*/ };

            // ButtonView
            buttonView.AddChild(bGoblinInvasion);
            buttonView.AddChild(bBloodmoon);
            buttonView.AddChild(bSlimerain);
            buttonView.AddChild(bFrostlegion);
            buttonView.AddChild(bSolarEclipse);
            buttonView.AddChild(bPirateInvasion);
            buttonView.AddChild(bPumpkinMoon);
            buttonView.AddChild(bFrostMoon);
            buttonView.AddChild(bMartianMadness);
            buttonView.AddChild(bStopEvents);

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #23
0
        public NPCButchererHotbar(CheatSheet mod)
        {
            this.mod = mod;
            //parentHotbar = mod.hotbar;

            this.buttonView = new UIView();
            base.Visible    = false;

            // Button images
            bButcherHostiles = new UIImage(Main.itemTexture[ItemID.DemonHeart]);
            bButcherBoth     = new UIImage(Main.itemTexture[ItemID.CrimsonHeart]);
            bButcherTownNPCs = new UIImage(Main.itemTexture[ItemID.Heart]);

            // Button tooltips
            bButcherHostiles.Tooltip = "Butcher hostile NPCs";
            bButcherBoth.Tooltip     = "Butcher hostile and friendly NPCs";
            bButcherTownNPCs.Tooltip = "Butcher friendly NPCs";

            // Button EventHandlers
            bButcherHostiles.onLeftClick += (s, e) =>
            {
                HandleButcher(0);
            };
            bButcherBoth.onLeftClick += (s, e) =>
            {
                HandleButcher(1);
            };
            bButcherTownNPCs.onLeftClick += (s, e) =>
            {
                HandleButcher(2);
            };

            // Register mousedown
            onMouseDown += (s, e) =>
            {
                if (!Main.LocalPlayer.mouseInterface && !mod.hotbar.MouseInside && !mod.hotbar.button.MouseInside)
                {
                    mouseDown = true;
                    Main.LocalPlayer.mouseInterface = true;
                }
            };
            onMouseUp += (s, e) => { justMouseDown = true; mouseDown = false; /*startTileX = -1; startTileY = -1;*/ };

            // ButtonView
            buttonView.AddChild(bButcherHostiles);
            buttonView.AddChild(bButcherBoth);
            buttonView.AddChild(bButcherTownNPCs);

            base.Width             = 200f;
            base.Height            = 55f;
            this.buttonView.Height = base.Height;
            base.Anchor            = AnchorPosition.Top;
            this.AddChild(this.buttonView);
            base.Position = new Vector2(Hotbar.xPosition, this.hiddenPosition);
            base.CenterXAxisToParentCenter();
            float num = this.spacing;

            for (int i = 0; i < this.buttonView.children.Count; i++)
            {
                this.buttonView.children[i].Anchor   = AnchorPosition.Left;
                this.buttonView.children[i].Position = new Vector2(num, 0f);
                this.buttonView.children[i].CenterYAxisToParentCenter();
                this.buttonView.children[i].Visible         = true;
                this.buttonView.children[i].ForegroundColor = buttonUnselectedColor;
                num += this.buttonView.children[i].Width + this.spacing;
            }
            this.Resize();
        }
Пример #24
0
    private static void HandleUiwindowEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uiwindowcode")
            {
                AtomicMain.AppLog("UIWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiwindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiwindowlayout")
            {
                AtomicMain.AppLog("UIWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiwindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "windowdemo")
            {
                AtomicMain.AppLog("UIWindow action : " + widget.GetId() + " was pressed ");
                UIView   someview = widget.GetView();
                UIWindow window   = new UIWindow();
                window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
                window.SetText("UIWindow demo (a login dialog)");
                window.Load("Scenes/login_dialog.ui.txt");
                window.ResizeToFitContent();
                someview.AddChild(window);
                window.Center();
                UIWidget login = window.GetWidget("login");
                login.SubscribeToEvent <WidgetEvent> (login, HandleUiwindowEvent);
                UIWidget cancel = window.GetWidget("cancel");
                cancel.SubscribeToEvent <WidgetEvent> (cancel, HandleUiwindowEvent);
            }
            if (widget.GetId() == "login")
            {
                AtomicMain.AppLog("UIWindow action : " + widget.GetId() + " was pressed ");
                UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
            if (widget.GetId() == "cancel")
            {
                AtomicMain.AppLog("UIWindow action : " + widget.GetId() + " was pressed ");
                UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
            if (widget.GetId() == "windowdemo1")
            {
                AtomicMain.AppLog("UIWindow action : " + widget.GetId() + " was pressed ");
                UIView   someview = widget.GetView();
                UIWindow window   = new UIWindow();
                window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
                window.SetText("UIWindow demo (a table)");
                window.Load("Scenes/sheet.ui.txt");
                window.ResizeToFitContent();
                someview.AddChild(window);
                window.Center();
            }
        }
    }