Example #1
0
        public ProductionFrame(ProductionComponent source) : base(1, 3)
        {
            padding_ = new Vector2(5);
            source_  = source;
            buttons_ = new ItemButton[2];
            for (int index = 0; index < 2; ++index)
            {
                buttons_[index]              = new ItemButton(source_, index);
                buttons_[index].getSource    = getSource;
                buttons_[index].getComponent = getComponent;
                buttons_[index].getTarget    = source_.getItem;
            }
            bar_ = new ProgressBar();

            set(0, 0, buttons_[0]);
            set(0, 1, bar_);
            set(0, 2, buttons_[1]);

            refresh();
            source_.register(refresh);
        }
Example #2
0
        public ProductionFrame(ProductionComponent source)
            : base(1, 3)
        {
            padding_ = new Vector2(5);
            source_ = source;
            buttons_ = new ItemButton[2];
            for (int index = 0; index < 2; ++index)
            {
                buttons_[index] = new ItemButton(source_, index);
                buttons_[index].getSource = getSource;
                buttons_[index].getComponent = getComponent;
                buttons_[index].getTarget = source_.getItem;
            }
            bar_ = new ProgressBar();

            set(0, 0, buttons_[0]);
            set(0, 1, bar_);
            set(0, 2, buttons_[1]);

            refresh();
            source_.register(refresh);
        }
Example #3
0
        public InventoryFrame(InventoryComponent source) : base(1, 1)
        {
            padding_  = new Vector2(5);
            source_   = source;
            capacity_ = source_.capacity;
            buttons_  = new ItemButton[capacity_];
            int rows = 1;
            int cols = capacity_;

            if (capacity_ > maxPerLine)
            {
                rows = capacity_ / maxPerLine;
                cols = maxPerLine;
            }
            inner_ = new FrameComponent(rows, cols);
            set(0, 0, inner_);
            int row = 0;
            int col = 0;

            for (int index = 0; index < capacity_; ++index)
            {
                buttons_[index]              = new ItemButton(source_, index);
                buttons_[index].slot_        = index;
                buttons_[index].getSource    = getSource;
                buttons_[index].getComponent = getComponent;
                buttons_[index].getTarget    = source_.getItem;
                inner_.set(row, col++, buttons_[index]);
                if (col >= maxPerLine)
                {
                    ++row;
                    col = 0;
                }
            }

            refresh();
            source_.register(refresh);
        }
Example #4
0
        public InventoryFrame(InventoryComponent source)
            : base(1, 1)
        {
            padding_ = new Vector2(5);
            source_ = source;
            capacity_ = source_.capacity;
            buttons_ = new ItemButton[capacity_];
            int rows = 1;
            int cols = capacity_;
            if (capacity_ > maxPerLine)
            {
                rows = capacity_ / maxPerLine;
                cols = maxPerLine;
            }
            inner_ = new FrameComponent(rows, cols);
            set(0, 0, inner_);
            int row = 0;
            int col = 0;
            for (int index = 0; index < capacity_; ++index)
            {
                buttons_[index] = new ItemButton(source_, index);
                buttons_[index].slot_ = index;
                buttons_[index].getSource = getSource;
                buttons_[index].getComponent = getComponent;
                buttons_[index].getTarget = source_.getItem;
                inner_.set(row, col++, buttons_[index]);
                if (col >= maxPerLine)
                {
                    ++row;
                    col = 0;
                }
            }

            refresh();
            source_.register(refresh);
        }