// 注册组
    protected void  resist_item_to_group(string group_name, Botan.ItemBase item)
    {
        Botan.Group group = this.findGroup(group_name);

        if (group == null)
        {
            group = this.default_group;
        }
        group.items.Add(item);

        item.group_name = group_name;
    }
    void    Update()
    {
        // ---------------------------------------------------------------- //
        // 探测鼠标的状态

        if (this.input.enable)
        {
            this.input.mouse_position    = Input.mousePosition;
            this.input.button.trigger_on = Input.GetMouseButtonDown(0);
            this.input.button.current    = Input.GetMouseButton(0);
        }
        else
        {
            this.input.button.trigger_on = false;
            this.input.button.current    = false;
        }

        // ---------------------------------------------------------------- //
        //

        foreach (Botan.Group group in this.groups)
        {
            if (!group.is_visible)
            {
                continue;
            }

            // ---------------------------------------------------------------- //
            // 先运行上一帧中焦点所处的按钮

            Botan.ItemBase next_focused = group.focused_item;

            if (group.focused_item != null)
            {
                group.focused_item.execute(true);

                if (!group.focused_item.focused.current)
                {
                    next_focused = null;
                }
            }

            // 运行其他按钮的逻辑

            foreach (Botan.ItemBase item in group.items)
            {
                if (item == group.focused_item)
                {
                    continue;
                }

                item.execute(next_focused == null);

                if (next_focused == null)
                {
                    if (item.focused.current)
                    {
                        next_focused = item;
                    }
                }
            }

            group.focused_item = next_focused;
        }
    }
示例#3
0
    void    Update()
    {
        // ---------------------------------------------------------------- //
        // マウスの状態を調べておく.

        if (this.input.enable)
        {
            this.input.mouse_position    = Input.mousePosition;
            this.input.button.trigger_on = Input.GetMouseButtonDown(0);
            this.input.button.current    = Input.GetMouseButton(0);
        }
        else
        {
            this.input.button.trigger_on = false;
            this.input.button.current    = false;
        }

        // ---------------------------------------------------------------- //
        //

        foreach (Botan.Group group in this.groups)
        {
            if (!group.is_visible)
            {
                continue;
            }

            // ---------------------------------------------------------------- //
            // 前のフレームでフォーカスしていたボタンを最初に実行.

            Botan.ItemBase next_focused = group.focused_item;

            if (group.focused_item != null)
            {
                group.focused_item.execute(true);

                if (!group.focused_item.focused.current)
                {
                    next_focused = null;
                }
            }

            // 他のボタンを実行.

            foreach (Botan.ItemBase item in group.items)
            {
                if (item == group.focused_item)
                {
                    continue;
                }

                item.execute(next_focused == null);

                if (next_focused == null)
                {
                    if (item.focused.current)
                    {
                        next_focused = item;
                    }
                }
            }

            group.focused_item = next_focused;
        }
    }