예제 #1
0
    private static void HandleUipromptwindowEvent(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() == "uipromptwindowcode")
            {
                AtomicMain.AppLog("UIPromptWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uipromptwindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uipromptwindowlayout")
            {
                AtomicMain.AppLog("UIPromptWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uipromptwindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "stringfinder")
            {
                AtomicMain.AppLog("UIPromptWindow action : " + widget.GetId() + " was pressed ");
                UIWidget       someview = (UIWidget  )widget.GetView();
                UIPromptWindow windowp  = new  UIPromptWindow(someview, widget.GetId());
                windowp.SubscribeToEvent <UIPromptCompleteEvent> (windowp, HandlePromptCompleteEvent);
                windowp.Show("WindowTitle", "Message in window", "preset value", 0, 0, 0);
            }
        }
    }
예제 #2
0
    private static void HandleUisceneviewEvent(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() == "uisceneviewcode")
            {
                AtomicMain.AppLog("UISceneView support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uisceneview.cs", widget.GetParent());
            }
            if (widget.GetId() == "uisceneviewlayout")
            {
                AtomicMain.AppLog("UISceneView support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uisceneview.ui.txt", widget.GetParent());
            }
        }
        if (widget.GetId() == "UISceneViewDemo")
        {
            AtomicMain.AppLog("UISceneView event : " + widget.GetId() + " got event= " + AtomicMain.EventReport((int)ev.Type));
        }
    }
예제 #3
0
    private static void HandleUiimagewidgetEvent(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() == "uiimagewidgetcode")
            {
                AtomicMain.AppLog("UIImageWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiimagewidget.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiimagewidgetlayout")
            {
                AtomicMain.AppLog("UIImageWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiimagewidget.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "imagecolor")
            {
                AtomicMain.AppLog("UIImageWidget action : " + widget.GetId() + " was pressed ");
                UIImageWidget img1 = (UIImageWidget)widget.FindWidget("imagewidgetdemo");
                img1.SetImage("Textures/HSV21.png");
            }
            if (widget.GetId() == "imagenewbuild")
            {
                AtomicMain.AppLog("UIImageWidget action : " + widget.GetId() + " was pressed ");
                UIImageWidget img1 = (UIImageWidget)widget.FindWidget("imagewidgetdemo");
                img1.SetImage("Textures/newbuilddetected_header.jpg");
            }
        }
    }
예제 #4
0
    private static void HandleUiclicklabelEvent(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() == "uiclicklabelcode")
            {
                AtomicMain.AppLog("UIClickLabel support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiclicklabel.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiclicklabellayout")
            {
                AtomicMain.AppLog("UIClickLabel support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiclicklabel.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "somecheck")
            {
                AtomicMain.AppLog("UIClickLabel event : " + widget.GetId() + " was pressed, state = " + widget.GetValue().ToString());
            }
            if (widget.GetId() == "someradio")
            {
                AtomicMain.AppLog("UIClickLabel event : " + widget.GetId() + " was pressed, state = " + widget.GetValue().ToString());
            }
        }
    }
예제 #5
0
    private static void HandleUicolorwheelEvent(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() == "uicolorwheelcode")
            {
                AtomicMain.AppLog("UIColorWheel support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uicolorwheel.cs", widget.GetParent());
            }
            if (widget.GetId() == "uicolorwheellayout")
            {
                AtomicMain.AppLog("UIColorWheel support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uicolorwheel.ui.txt", widget.GetParent());
            }
        }
        else if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "colorwheeldemo")
            {
                UIColorWheel cwx = (UIColorWheel)widget; // collect click color info
                if (!cwx.Equals(null))
                {
                    AtomicMain.AppLog("UIColorWheel event : " + widget.GetId() + " hue = " + cwx.GetHue().ToString() + " saturation = " + cwx.GetSaturation().ToString());
                }
            }
        }
    }
예제 #6
0
    private static void HandleUieditfieldEvent(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() == "uieditfieldcode")
            {
                AtomicMain.AppLog("UIEditField support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uieditfield.cs", widget.GetParent());
            }
            if (widget.GetId() == "uieditfieldlayout")
            {
                AtomicMain.AppLog("UIEditField support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uieditfield.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "editfieldadd")
            {
                AtomicMain.AppLog("UIEditField action : " + widget.GetId() + " was pressed ");
                UIEditField ef1 = (UIEditField)widget.FindWidget("editfieldmulti");
                if (!ef1.Equals(null))
                {
                    var    cache = GetSubsystem <ResourceCache>();
                    File   filex = cache.GetFile("Scenes/layout_uieditfield.ui.txt");
                    String textx = filex.ReadText();
                    filex.Close();
                    ef1.SetText(textx);
                }
            }
            if (widget.GetId() == "editfieldclr")
            {
                AtomicMain.AppLog("UIEditField action : " + widget.GetId() + " was pressed ");
                UIEditField ef1 = (UIEditField)widget.FindWidget("editfieldmulti");
                if (!ef1.Equals(null))
                {
                    ef1.SetText("");
                }
            }
        }
        else
        {
            if (widget.GetId() == "editfieldsingle")
            {
                UIEditField efx = (UIEditField)widget;
                AtomicMain.AppLog("UIEditField event : " + widget.GetId() + " text = `" + efx.GetText() + "` event type = " + AtomicMain.EventReport((int)ev.Type));
            }
            if (widget.GetId() == "editfieldmulti")
            {
                UIEditField efx = (UIEditField)widget;
                AtomicMain.AppLog("UIEditField event : " + widget.GetId() + " text = `" + efx.GetText() + "` event type = " + AtomicMain.EventReport((int)ev.Type));
            }
        }
    }
예제 #7
0
    private static void HandleUipulldownmenuEvent(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() == "uipulldownmenucode")
            {
                AtomicMain.AppLog("UIPulldownMenu support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uipulldownmenu.cs", widget.GetParent());
            }
            if (widget.GetId() == "uipulldownmenulayout")
            {
                AtomicMain.AppLog("UIPulldownMenu support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uipulldownmenu.ui.txt", widget.GetParent());
            }
        }
        else if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "FileMenu")
            {
                UIPulldownMenu pdm = (UIPulldownMenu)widget;
                if (!pdm.Equals(null))
                {
                    AtomicMain.AppLog("UIPulldownMenu event : " + widget.GetId() + " selected entry = " + pdm.GetSelectedId());
                }
            }
            if (widget.GetId() == "EditMenu")
            {
                UIPulldownMenu pdm = (UIPulldownMenu)widget;
                if (!pdm.Equals(null))
                {
                    AtomicMain.AppLog("UIPulldownMenu event : " + widget.GetId() + " selected entry = " + pdm.GetSelectedId());
                }
            }
            if (widget.GetId() == "ViewMenu")
            {
                UIPulldownMenu pdm = (UIPulldownMenu)widget;
                if (!pdm.Equals(null))
                {
                    AtomicMain.AppLog("UIPulldownMenu event : " + widget.GetId() + " selected entry = " + pdm.GetSelectedId());
                }
            }
            if (widget.GetId() == "HelpMenu")
            {
                UIPulldownMenu pdm = (UIPulldownMenu)widget;
                if (!pdm.Equals(null))
                {
                    AtomicMain.AppLog("UIPulldownMenu event : " + widget.GetId() + " selected entry = " + pdm.GetSelectedId());
                }
            }
        }
    }
예제 #8
0
    void CreateDecor(Vector3 position, Vector3 leftVector)
    {
        // We discard a few calls
        _discard++;
        if (_discard % 3 != 0)
        {
            return;
        }

        // We use the simplex noise to evaluate chances with smooth transition
        double chance = _noise.Evaluate(position.X * 0.2f, 0) + 1;
        Node   node   = null;
        bool   isTree = false;

        // Common decorations (grasses)
        if (chance < 1.2f)
        {
            // We discard a few of these too
            if (_rng.Next(6) < 4)
            {
                node = AtomicMain.CreateSpriteNode(_decorationLib.GetRandomFromGroup(0), 3, false);
            }
        }
        else if (chance < 1.3f)
        {
            node = AtomicMain.CreateSpriteNode(_decorationLib.GetRandomFromGroup(1), 4, false);
        }
        else if (chance < 1.7f)
        {
            // We only spawn trees if the surface isn't too steep
            if (Math.Abs(leftVector.Y) < 0.1f)
            {
                node         = AtomicMain.CreateSpriteNode(_decorationLib.GetRandomFromGroup(2), 4, false);
                node.Scale2D = node.Scale2D *= 1 + _rng.Next(30) / 100f;
                isTree       = true;
            }
        }

        if (node != null)
        {
            // We position the node on the surface, if the node is a tree we don't rotate it AND offset it a bit
            node.SetPosition(position + Vector3.Forward * 15);
            if (!isTree)
            {
                Quaternion transformation = Quaternion.FromRotationTo(Vector3.Left, leftVector);
                node.SetRotation(transformation);
            }
            else
            {
                node.Translate(-node.Up * 0.1f);
            }
        }
    }
예제 #9
0
    private static void HandleUicolorwidgetEvent(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() == "uicolorwidgetcode")
            {
                AtomicMain.AppLog("UIColorWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uicolorwidget.cs", widget.GetParent());
            }
            if (widget.GetId() == "uicolorwidgetlayout")
            {
                AtomicMain.AppLog("UIColorWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uicolorwidget.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "uicolorwidgetred")
            {
                AtomicMain.AppLog("UIColorWidget action : " + widget.GetId() + " was pressed ");
                UIColorWidget clw = (UIColorWidget)widget.FindWidget("colorwidgetdemo");
                if (!clw.Equals(null))
                {
                    clw.SetColorString("#FF1111");
                }
            }
            if (widget.GetId() == "uicolorwidgetgreen")
            {
                AtomicMain.AppLog("UIColorWidget action : " + widget.GetId() + " was pressed ");
                UIColorWidget clw = (UIColorWidget)widget.FindWidget("colorwidgetdemo");
                if (!clw.Equals(null))
                {
                    clw.SetColorString("#11FF11");
                }
            }
            if (widget.GetId() == "uicolorwidgetblue")
            {
                AtomicMain.AppLog("UIColorWidget action : " + widget.GetId() + " was pressed ");
                UIColorWidget clw = (UIColorWidget)widget.FindWidget("colorwidgetdemo");
                if (!clw.Equals(null))
                {
                    clw.SetColorString("#1111FF");
                }
            }
        }
    }
예제 #10
0
    private static void HandleUimenuwindowEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uimenuwindowcode")
            {
                AtomicMain.AppLog("UIMenuWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uimenuwindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uimenuwindowlayout")
            {
                AtomicMain.AppLog("UIMenuWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uimenuwindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "uimenuwindowpush")
            {
                AtomicMain.AppLog("UIMenuWindow action : " + widget.GetId() + " was pressed ");
                UIMenuWindow     mymenuwindow = new UIMenuWindow(widget, "MenuWindowDemo");
                UIMenuItemSource mis          = new UIMenuItemSource();
                mis.AddItem(new UIMenuItem("UISelectItem1", "item1"));
                mis.AddItem(new UIMenuItem("UISelectItem2", "item2", "Ctrl+C"));
                mis.AddItem(new UIMenuItem("UISelectItem3", "item3", "Ctrl+A", "DuckButton"));
                mis.AddItem(new UIMenuItem("UISelectItem4", "item4", "Ctrl+O", "LogoAtomic"));
                int xx = widget.GetX() + (widget.GetWidth() / 2);
                int yy = widget.GetY() + (widget.GetHeight() / 2);
                mymenuwindow.SubscribeToEvent <WidgetEvent> (mymenuwindow, HandleUimenuwindowEvent);
                mymenuwindow.Show(mis, xx, yy);
            }

            if (widget.GetId() == "MenuWindowDemo")
            {
                AtomicMain.AppLog("UIMenuWindow event : " + widget.GetId() + " and " + refid + " was selected ");
            }
        }
        else
        {
            if (widget.GetId() == "MenuWindowDemo")
            {
                AtomicMain.AppLog("UIMenuWindow event : " + widget.GetId() + " refid=" + refid + " event type=" + AtomicMain.EventReport((int)ev.Type));
            }
        }
    }
예제 #11
0
        // Emit particles if close to a surface point and returns true if positive
        public bool EmitSurfaceParticles()
        {
            Vector3 nearestSurfPoint = AtomicMain.GetSurfacePointClosestToPoint(_rigidBody.Node);
            float   contactDistance  = Vector3.Distance(_rigidBody.Node.Position, nearestSurfPoint);

            if (contactDistance > _particlesDistance)
            {
                _particleEmitter.Effect.StartColor = new Color(0, 0, 0, 0);
                return(false);
            }
            _particleEmitter.Effect.StartColor = Color.White;
            _particleEmitter.Node.Position     = nearestSurfPoint;
            return(true);
        }
예제 #12
0
    private static void HandleAllTabcontainerEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }

        if (widget.GetId() == "UITabContainerDemo" && ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_TAB_CHANGED)
        {
            UITabContainer tcx = (UITabContainer)widget;   // check the focus & stuff, or it gets a little spammy
            AtomicMain.AppLog("UITabContainer event : " + widget.GetId() + " UI_EVENT_TYPE_TAB_CHANGED to " + tcx.GetCurrentPage().ToString()
                              + " id: " + tcx.GetCurrentPageWidget().GetId());
        }
    }
예제 #13
0
    private static void HandleUiradiobuttonEvent(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() == "uiradiobuttoncode")
            {
                AtomicMain.AppLog("UIRadioButton support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiradiobutton.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiradiobuttonlayout")
            {
                AtomicMain.AppLog("UIRadioButton support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiradiobutton.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "demoradio")
            {
                AtomicMain.AppLog("UIRadioButton event : " + widget.GetId() + " was pressed, state = " + widget.GetValue().ToString());
            }

            if (widget.GetId() == "radioset")
            {
                UIWidget demochk = widget.FindWidget("demoradio");
                if (!demochk.Equals(null))
                {
                    demochk.SetValue(1);
                    AtomicMain.AppLog("UIRadioButton action : " + widget.GetId() + " was pressed, set state to 1");
                }
            }
            if (widget.GetId() == "radiounset")
            {
                UIWidget demochk = widget.FindWidget("demoradio");
                if (!demochk.Equals(null))
                {
                    demochk.SetValue(0);
                    AtomicMain.AppLog("UIRadioButton action : " + widget.GetId() + " was pressed, set state to 0");
                }
            }
        }
    }
예제 #14
0
    private static void HandleUiinlineselectEvent(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() == "uiinlineselectcode")
            {
                AtomicMain.AppLog("UIInlineSelect support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiinlineselect.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiinlineselectlayout")
            {
                AtomicMain.AppLog("UIInlineSelect support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiinlineselect.ui.txt", widget.GetParent());
            }
        }
        else if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "inlineselectdemo")
            {
                UIInlineSelect ils = (UIInlineSelect)widget;
                if (!ils.Equals(null))
                {
                    AtomicMain.AppLog("UIInlineSelect event : " + widget.GetId() + " changed value to " + ils.GetValue().ToString());
                }
            }
            if (widget.GetId() == "ilsstep")
            {
                UISlider steps = (UISlider)widget;
                if (!steps.Equals(null))
                {
                    UIInlineSelect ils = (UIInlineSelect)widget.FindWidget("inlineselectdemo");
                    if (!ils.Equals(null))
                    {
                        ils.SetStepSize(steps.GetValue());
                    }
                    AtomicMain.AppLog("UIInlineSelect event : " + widget.GetId() + " step size changed to " + steps.GetValue().ToString());
                }
            }
        }
    }
    private static void HandleAllSelectdropdownEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }

        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "selectdropdowndemo")
            {
                AtomicMain.AppLog("UISelectDropdown event : " + widget.GetId() + " changed value to " + widget.GetText());
            }
        }
    }
예제 #16
0
    private static void HandleAllScrollcontainerEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }

        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "scrollbardemo")
            {
                AtomicMain.AppLog("UIScrollBar action : " + widget.GetId() + " changed value to " + widget.GetValue().ToString());
            }
        }
    }
예제 #17
0
    public Terrain(Scene scene)
    {
        _scene = scene;

        // We load the materials, the ones in this example only use built in techniques, we use diffuse for the ground for performance
        _surfaceMaterial = Cache.Get <Material>("Materials/UnlitAlpha.xml");
        _surfaceMaterial.SetTexture(0, Cache.Get <Texture2D>("Scenarios/grasslands/surface.png"));
        _chunkMaterial = Cache.Get <Material>("Materials/Unlit.xml");
        _chunkMaterial.SetTexture(0, Cache.Get <Texture2D>("Scenarios/grasslands/ground.png"));

        // We create and populate a library with the decorations
        Func <string, Sprite2D> GetSprite = file => Cache.Get <Sprite2D>($"Scenarios/grasslands/Object/{file}");

        _decorationLib = new DecorationLibrary <Sprite2D>(
            new [] { GetSprite("Bush (1).png"), GetSprite("Bush (2).png"), GetSprite("Bush (3).png"), GetSprite("Bush (4).png") },
            new [] { GetSprite("Mushroom_1.png"), GetSprite("Mushroom_2.png"), GetSprite("Stone.png"), GetSprite("Sign_2.png") },
            new [] { GetSprite("Tree_1.png"), GetSprite("Tree_2.png"), GetSprite("Tree_3.png") }
            );

        // We setup the hotstop/origin of each sprite to be next to its bottom
        foreach (Sprite2D sprite in _decorationLib.GetAllResources())
        {
            sprite.SetHotSpot(new Vector2(0.5f, 0.1f));
        }

        // We generate the chunks and add some boxes randomly
        Sprite2D crateSprite = Cache.Get <Sprite2D>("Scenarios/grasslands/Object/Crate.png");

        for (int i = 0; i < Chunksize * chunksToGenerate; i += Chunksize)
        {
            GenerateChunk(i);

            // Crates
            if (_rng.Next(100) < PercentageOfChunksWithCrates)
            {
                Node crateNode = AtomicMain.CreateSpriteNode(crateSprite, 3);
                crateNode.SetPosition(new Vector3(i + _rng.Next(8), 20, -5));
                CollisionBox2D crateCollider = crateNode.CreateComponent <CollisionBox2D>();
                crateCollider.SetSize(0.76f, 0.76f);
                crateCollider.SetDensity(1.0f);
                crateCollider.SetRestitution(0.6f);
                crateCollider.SetFriction(0.4f);
            }
        }
    }
예제 #18
0
    private static void HandleUitexturewidgetEvent(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() == "uitexturewidgetcode")
            {
                AtomicMain.AppLog("UITextureWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uitexturewidget.cs", widget.GetParent());
            }
            if (widget.GetId() == "uitexturewidgetlayout")
            {
                AtomicMain.AppLog("UITextureWidget support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uitexturewidget.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "uitexturewidgetch1")
            {
                AtomicMain.AppLog("UITextureWidget support : " + widget.GetId() + " was pressed ");
                var             cache = GetSubsystem <ResourceCache>();
                UITextureWidget tw    = (UITextureWidget)widget.FindWidget("UITextureWidgetDemo");
                tw.SetTexture(cache.GetResource <Texture2D>("Textures/newbuilddetected_header.jpg"));
            }
            if (widget.GetId() == "uitexturewidgetch2")
            {
                AtomicMain.AppLog("UITextureWidget support : " + widget.GetId() + " was pressed ");
                var             cache = GetSubsystem <ResourceCache>();
                UITextureWidget tw    = (UITextureWidget)widget.FindWidget("UITextureWidgetDemo");
                tw.SetTexture(cache.GetResource <Texture2D>("Textures/HSV21.png"));
            }
            if (widget.GetId() == "uitexturewidgetch3")
            {
                AtomicMain.AppLog("UITextureWidget support : " + widget.GetId() + " was pressed ");
                var             cache = GetSubsystem <ResourceCache>();
                UITextureWidget tw    = (UITextureWidget)widget.FindWidget("UITextureWidgetDemo");
                tw.SetTexture(cache.GetResource <Texture2D>("Textures/planet.jpg"));
            }
        }
    }
예제 #19
0
    private static void HandleUibuttonEvent(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() == "uibuttoncode")
            {
                AtomicMain.AppLog("UIButton support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uibutton.cs", widget.GetParent());
            }
            if (widget.GetId() == "uibuttonlayout")
            {
                AtomicMain.AppLog("UIButton support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uibutton.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "demobutton")
            {
                AtomicMain.AppLog("UIButton action : " + widget.GetId() + " was pressed ");
            }
            if (widget.GetId() == "buttonducky")
            {
                AtomicMain.AppLog("UIButton action : " + widget.GetId() + " was pressed ");
            }
            if (widget.GetId() == "buttonready")
            {
                AtomicMain.AppLog("UIButton action : " + widget.GetId() + " was pressed ");
            }
            if (widget.GetId() == "buttonatomic")
            {
                AtomicMain.AppLog("UIButton action : " + widget.GetId() + " was pressed ");
            }
            if (widget.GetId() == "buttongreen")
            {
                AtomicMain.AppLog("UIButton action : " + widget.GetId() + " was pressed ");
            }
        }
    }
    private static void HandleUifontdescriptionEvent(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() == "uifontdescriptioncode")
            {
                AtomicMain.AppLog("UIFontdescription support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uifontdescription.cs", widget.GetParent());
            }
            if (widget.GetId() == "uifontdescriptionlayout")
            {
                AtomicMain.AppLog("UIFontdescription support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uifontdescription.ui.txt", widget.GetParent());
            }
        }
        else if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            if (widget.GetId() == "fontstep")
            {
                UISlider uis = (UISlider)widget;
                if (!uis.Equals(null))
                {
                    UITextField       mytext = (UITextField)widget.FindWidget("changetext");
                    UIFontDescription myfont = new UIFontDescription();
                    int mysize = (int)uis.GetValue();
                    myfont.SetSize(mysize);
                    myfont.SetId("Vera");
                    mytext.SetFontDescription(myfont);
                    mytext.SetText("Size " + mysize);
                    AtomicMain.AppLog("UIFontdescription action : " + widget.GetId() + " step size changed to " + mysize);
                }
            }
        }
    }
예제 #21
0
    private static void HandleUiskinimageEvent(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() == "uiskinimagecode")
            {
                AtomicMain.AppLog("UISkinImage support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uiskinimage.cs", widget.GetParent());
            }
            if (widget.GetId() == "uiskinimagelayout")
            {
                AtomicMain.AppLog("UISkinImage support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uiskinimage.ui.txt", widget.GetParent());
            }
        }
    }
예제 #22
0
    private static void HandleUifinderwindowEvent(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() == "uifinderwindowcode")
            {
                AtomicMain.AppLog("UIFinderWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uifinderwindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uifinderwindowlayout")
            {
                AtomicMain.AppLog("UIFinderWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uifinderwindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "filefinder")
            {
                AtomicMain.AppLog("UIFinderWindow action : " + widget.GetId() + " was pressed ");
                UIWidget       someview = (UIWidget)widget.GetView();
                UIFinderWindow windowf  = new UIFinderWindow(someview, widget.GetId());
                windowf.SubscribeToEvent <UIFinderCompleteEvent> (windowf, HandleFinderCompleteEvent);
                windowf.FindFile("Find a File", "", 0, 0, 0);
            }
            if (widget.GetId() == "folderfinder")
            {
                AtomicMain.AppLog("UIFinderWindow action : " + widget.GetId() + " was pressed ");
                UIWidget       someview = (UIWidget)widget.GetView();
                UIFinderWindow windowd  = new UIFinderWindow(someview, widget.GetId());
                windowd.SubscribeToEvent <UIFinderCompleteEvent> (windowd, HandleFinderCompleteEvent);
                windowd.FindPath("Find a Folder", "", 0, 0, 0);
            }
        }
    }
예제 #23
0
    public Clouds(float startX, int minY, int deviation, int amount, int range)
    {
        _minY      = minY;
        _deviation = deviation;
        _range     = range;

        Sprite2D[] cloudSprites =
        {
            Cache.Get <Sprite2D>("Scenarios/cloud1.png"),
            Cache.Get <Sprite2D>("Scenarios/cloud2.png"),
            Cache.Get <Sprite2D>("Scenarios/cloud3.png")
        };

        // We pre-fill the screen with clouds
        float cloudSpacing = range * 2 / amount;

        _clouds = new Node[amount];
        for (int i = 0; i < amount; i++)
        {
            _clouds[i]           = AtomicMain.CreateSpriteNode(cloudSprites[rng.Next(cloudSprites.Length)], 4, false);
            RecycleCloud(startX -= cloudSpacing, _clouds[i]);
        }
    }
예제 #24
0
    public Vehicle CreateChassis(Vector2 colliderCenter, float colliderRadius, int massDensity, Vector3 exhaustPosition,
                                 ParticleEffect2D exhaustParticles, Sound engineSound, Sound tireSound, Sound[] suspensionSounds,
                                 int horsePower, int maxSpeedFwd, int maxSpeedBwd, int rollForce)
    {
        // We set out private fields
        _horsePower = horsePower;
        _maxSpdFwd  = maxSpeedFwd;
        _maxSpdBwd  = maxSpeedBwd;
        _rollForce  = rollForce;
        _rigidBody  = GetComponent <RigidBody2D>();

        // We add the collider (circle collider at the moment)
        var col = AtomicMain.AddCollider <CollisionCircle2D>(Node, dens: massDensity, fric: 0);

        col.SetRadius(colliderRadius);
        col.SetCenter(colliderCenter);

        // We create the exhaust particle system
        var exhaustParticlesNode = Node.CreateChild();

        exhaustParticlesNode.SetPosition(exhaustPosition);
        _exhaustParticles = exhaustParticlesNode.CreateComponent <ParticleEmitter2D>();
        _exhaustParticles.SetEffect(exhaustParticles);

        // We setup the engine sound and other sound effect
        engineSound.SetLooped(true);
        _soundSource = Node.CreateComponent <SoundSource3D>();
        _soundSource.SetNearDistance(10);
        _soundSource.SetFarDistance(50);
        _accelSound            = engineSound;
        _brakeSound            = tireSound;
        _suspensionSoundSource = Node.CreateComponent <SoundSource3D>();
        _suspensionSounds      = suspensionSounds;

        // We return the Vehicle for convenience, since this function is intended to be the vehicle's init function
        return(this);
    }
예제 #25
0
    public Node CreateWheel(Sprite2D sprite, Vector2 relativePosition, float radius, int suspensionFrequency, float suspensionDamping,
                            ParticleEffect2D particles, float distanceToEmitParticles)
    {
        Node wheelNode = AtomicMain.CreateSpriteNode(sprite);

        wheelNode.SetPosition2D(relativePosition);

        // CreateSpriteNode adds a RigidBody for us, so we get it here
        RigidBody2D wheelRigidBody = wheelNode.GetComponent <RigidBody2D>();

        // We activate CCD
        wheelRigidBody.SetBullet(true);

        AtomicMain.AddCollider <CollisionCircle2D>(wheelNode).SetRadius(radius);

        // The Box2D wheel joint provides spring for simulating suspension
        ConstraintWheel2D wheelJoint = Node.CreateComponent <ConstraintWheel2D>();

        wheelJoint.SetOtherBody(wheelRigidBody);
        wheelJoint.SetAnchor(relativePosition);
        wheelJoint.SetAxis(Vector2.UnitY);
        wheelJoint.SetFrequencyHz(suspensionFrequency);
        wheelJoint.SetDampingRatio(suspensionDamping);

        // Each wheel has a particle emitter to emit particles when it's in contact with the surface
        Node particlesNode = Node.Scene.CreateChild();

        particlesNode.SetPosition(new Vector3(relativePosition.X, relativePosition.Y, 14));
        ParticleEmitter2D particleEmitter = particlesNode.CreateComponent <ParticleEmitter2D>();

        particleEmitter.SetEffect(particles);

        // We create a new Wheel struct and add to the _wheels list
        _wheels.Add(new Wheel(wheelRigidBody, wheelJoint, particleEmitter, distanceToEmitParticles));

        return(wheelNode);
    }
예제 #26
0
    public Node CreateHead(Sprite2D sprite, Vector3 relativePosition, float colliderRadius, Vector2 neckAnchor)
    {
        Node head = AtomicMain.CreateSpriteNode(sprite);

        head.SetPosition(relativePosition);
        AtomicMain.AddCollider <CollisionCircle2D>(head).SetRadius(colliderRadius);

        // This is the actual neck joint
        ConstraintRevolute2D joint = head.CreateComponent <ConstraintRevolute2D>();

        joint.SetOtherBody(_rigidBody);
        joint.SetAnchor(neckAnchor);

        // This is the spring, it's attached to the body with an offset
        ConstraintDistance2D spring = head.CreateComponent <ConstraintDistance2D>();

        spring.SetOtherBody(_rigidBody);
        spring.SetOwnerBodyAnchor(-Vector2.UnitY * 2);
        spring.SetOtherBodyAnchor(Node.WorldToLocal2D(head.WorldPosition2D - Vector2.UnitY * 2));
        spring.SetFrequencyHz(3);
        spring.SetDampingRatio(0.4f);

        return(head);
    }
예제 #27
0
    private static void HandleUisectionEvent(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() == "uisectioncode")
            {
                AtomicMain.AppLog("UISection support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uisection.cs", widget.GetParent());
            }
            if (widget.GetId() == "uisectionlayout")
            {
                AtomicMain.AppLog("UISection support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uisection.ui.txt", widget.GetParent());
            }
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED)
        {
            UIWidget demo1 = widget.FindWidget("UISectionDemo");  // event comes in on child widget!
            if (demo1.IsAncestorOf(widget))
            {
                AtomicMain.AppLog("UISection event : " + demo1.GetId() + " changed to value = " + demo1.GetValue().ToString());
            }

            UIWidget demo2 = widget.FindWidget("UISection2Demo");
            if (demo2.IsAncestorOf(widget))
            {
                AtomicMain.AppLog("UISection event : " + demo2.GetId() + " changed to value = " + demo2.GetValue().ToString());
            }
        }
    }
예제 #28
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();
            }
        }
    }
예제 #29
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);
                    }
                }
            }
        }
    }
    private static void HandleUimessagewindowEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        UIWidget mylayout = (UIWidget)widget.FindWidget("pageuimessagewindow");

        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uimessagewindowcode")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uimessagewindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uimessagewindowlayout")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uimessagewindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "msgnone")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                UIMessageWindow mess1 = new UIMessageWindow(mylayout, "mymess1");
                mess1.Show("MessageWindow - NONE", "this is a MessageWindow - None button", (UI_MESSAGEWINDOW_SETTINGS)0, false, 0, 0);
            }
            if (widget.GetId() == "msgok")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                UIMessageWindow mess2 = new UIMessageWindow(mylayout, "mymess2");
                mess2.SubscribeToEvent <WidgetEvent> (mess2, HandleUimessagewindowEvent);
                mess2.Show("MessageWindow - OK", "this is a MessageWindow - OK button", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_OK, false, 0, 0);
            }
            if (widget.GetId() == "msgkcancel")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                UIMessageWindow mess3 = new UIMessageWindow(mylayout, "mymess3");
                mess3.SubscribeToEvent <WidgetEvent> (mess3, HandleUimessagewindowEvent);
                mess3.Show("MessageWindow - OK CANCEL", "this is a MessageWindow - OK CANCEL buttons", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_OK_CANCEL, false, 0, 0);
            }
            if (widget.GetId() == "msgyesno")
            {
                AtomicMain.AppLog("UIMessageWindow support : " + widget.GetId() + " was pressed ");
                UIMessageWindow mess4 = new UIMessageWindow(mylayout, "mymess4");
                mess4.SubscribeToEvent <WidgetEvent> (mess4, HandleUimessagewindowEvent);
                mess4.Show("MessageWindow - YES NO", "this is a MessageWindow - YES NO buttons", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_YES_NO, false, 0, 0);
            }

            if (refid == "TBMessageWindow.ok")
            {
                AtomicMain.AppLog("UIMessageWindow event : " + refid + " closed the UIMessageWindow");
            }
            if (refid == "TBMessageWindow.cancel")
            {
                AtomicMain.AppLog("UIMessageWindow event : " + refid + " closed the UIMessageWindow");
            }
            if (refid == "TBMessageWindow.yes")
            {
                AtomicMain.AppLog("UIMessageWindow event : " + refid + " closed the UIMessageWindow");
            }
            if (refid == "TBMessageWindow.no")
            {
                AtomicMain.AppLog("UIMessageWindow event : " + refid + " closed the UIMessageWindow");
            }
        }
        else
        {
            AtomicMain.AppLog("UIMessageWindow event : " + widget.GetId() + " event type = " + AtomicMain.EventReport((int)ev.Type));
        }
    }