Ejemplo n.º 1
0
        public static Entity createInventoryWindow(Entity caller,
                                                   Point position, Point dimensions,
                                                   int buttonHeight, int rows, int cols)
        {
            Entity e = ecs_instance.create();

            BasicWindow window = new BasicWindow(e, caller, ecs_instance, position, dimensions, buttonHeight);

            //initialize the window
            window.init();

            //setup background frame
            window.Frame.background_color = Color.White;
            window.Frame.background_name  = "whitebg";
            window.Frame.transparency     = 0.5f;

            //setup close button
            window.Button.background_name  = "test_dialog";
            window.Button.background_color = Color.Gray;
            window.Button.transparency     = 1f;
            window.Button.border           = 0;
            window.Button.font_name        = "General";

            window.Button.center_text = true;
            window.Button.text        = "Inventory";
            window.Button.text_color  = Color.White;


            //setup button mouse events
            window.Button.mouse_enter += change_button_on_hover;
            window.Button.mouse_press += change_button_on_press;
            window.Button.mouse_leave += change_button_on_leave;
            window.Button.mouse_click += destroyUI;

            //pre-assemble window
            window.preAssemble();

            //add what i need here
            int x = window.Frame.bounds.X;
            int y = window.Frame.bounds.Y + buttonHeight;

            int xSize = window.Frame.bounds.Width / cols;
            int ySize = (window.Frame.bounds.Height - buttonHeight) / rows;

            for (int i = 0; i < cols; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    GFrame slot = new GFrame();
                    slot.owner        = e;
                    slot.caller       = caller;
                    slot.ecs_instance = ecs_instance;
                    slot.bounds       = new Rectangle(x + i * xSize, y + j * ySize, xSize - 1, ySize - 1);

                    slot.background_color = Color.White;
                    slot.background_name  = "frame";
                    slot.transparency     = 0.5f;

                    slot.mouse_click += getItem;

                    window.Canvas.controls.Add(slot);
                }
            }

            //final assemble
            window.assemble();

            //create the UI component and assign it to the entity
            UserInterface ui = new UserInterface(window.Form);

            ecs_instance.component_manager.add_component(e, ui);

            ecs_instance.resolve(e);

            return(e);
        }
Ejemplo n.º 2
0
        public static Entity createStatWindow(Entity caller, Point position, Point dimensions, int buttonHeight)
        {
            Entity e = ecs_instance.create();

            BasicWindow window = new BasicWindow(e, caller, ecs_instance, position, dimensions, buttonHeight);

            //initialize the window
            window.init();

            //setup background frame
            window.Frame.background_color = Color.White;
            window.Frame.background_name  = "whitebg";
            window.Frame.transparency     = 0.5f;

            //setup close button
            window.Button.background_color = Color.Gray;
            window.Button.background_name  = "test_dialog";
            window.Button.font_name        = "General";
            window.Button.center_text      = true;
            window.Button.text             = "Player Stats";
            window.Button.text_color       = Color.White;



            //setup mouse events
            window.Button.mouse_enter += change_button_on_hover;
            window.Button.mouse_press += change_button_on_press;
            window.Button.mouse_leave += change_button_on_leave;
            window.Button.mouse_click += destroyUI;

            //pre-assemble window
            window.preAssemble();

            //add any custom controls here to window.Canvas
            GLabel label = new GLabel();

            label.owner        = e;
            label.caller       = caller;
            label.ecs_instance = ecs_instance;
            label.bounds       = new Rectangle(window.Form.bounds.Left + 20,
                                               window.Form.bounds.Top + 40,
                                               dimensions.X - 40,
                                               dimensions.Y - 60);
            label.autosize         = false;
            label.text             = "stuffs";
            label.font_name        = "General";
            label.border           = 0;
            label.text_color       = Color.White;
            label.background_name  = "frame";
            label.background_color = Color.Black;
            label.transparency     = 0.5f;
            label.updating        += labelUpdate;

            //add controls to canvas
            window.Canvas.controls.Add(label);

            //final assemble
            window.assemble();

            //create the UI component and assign it to the entity
            UserInterface ui = new UserInterface(window.Form);

            ecs_instance.component_manager.add_component(e, ui);

            ecs_instance.resolve(e);

            return(e);
        }