Projects >> SpoutcraftPlugin >>4f08797348102feefeea775b21dcd9107dfaf5de

Chunk
Conflicting content
	public int getScrollPosition() {
		return getScrollPosition(Orientation.VERTICAL);
	}
<<<<<<< HEAD
	
=======

>>>>>>> 981fb66c63565b46042ad8f540387d096d9a7fc7
	@Override
	public int getInnerSize(Orientation axis) {
		if(axis == Orientation.HORIZONTAL) return getViewportSize(Orientation.HORIZONTAL);
Solution content
/*
 * This file is part of Spout API (http://wiki.getspout.org/).
 *
 * Spout API is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Spout API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 */
package org.getspout.spoutapi.gui;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.getspout.spoutapi.packet.PacketUtil;

public class GenericListWidget extends GenericScrollable implements ListWidget {
	private List items = new ArrayList();
	private int selected = -1;
	private int cachedTotalHeight = -1;

	@Override
	public WidgetType getType() {
		return WidgetType.ListWidget;
	}

	@Override
	public ListWidgetItem[] getItems() {
		ListWidgetItem[] sample = {};
		return items.toArray(sample);
	}

	@Override
	public ListWidgetItem getItem(int i) {
		if(i == -1) {
			return null;
		}
		ListWidgetItem items [] = getItems();
		if(i>=items.length) {
			return null;
		}
		return items[i];
	}

	@Override
	public ListWidget addItem(ListWidgetItem item) {
		items.add(item);
		item.setListWidget(this);
		cachedTotalHeight = -1;
		return this;
	}

	@Override
	public boolean removeItem(ListWidgetItem item) {
		if(items.contains(item)){
			items.remove(item);
			item.setListWidget(null);
			cachedTotalHeight = -1;
			return true;
		}
		return false;
	}

	@Override
	public ListWidgetItem getSelectedItem() {
		return getItem(selected);
	}
	
	@Override
	public int getSelectedRow() {
		return selected;
	}

	@Override
	public ListWidget setSelection(int n) {
		selected = n;
		if(selected < -1) {
			selected = -1;
		}
		if(selected > items.size()-1) {
			selected = items.size()-1;
		}
		
		//Check if selection is visible
		ensureVisible(getItemRect(selected));
		return this;
	}
	
	private Rectangle getItemRect(int n) {
		ListWidgetItem item = getItem(n);
		Rectangle result = new Rectangle(0,0,0,0);
		if(item == null) {
			return result;
		}
		result.setX(0);
		result.setY(getItemYOnScreen(n));
		result.setHeight(24);
		result.setWidth(getInnerSize(Orientation.VERTICAL));
		return result;
	}

	private int getItemYOnScreen(int n) {
		int height = items.size() * 24;
		return height;
	}

	@Override
	public ListWidget clearSelection() {
		setSelection(-1);
		return this;
	}

	@Override
	public boolean isSelected(int n) {
		return selected == n;
	}

	public ListWidget setScrollPosition(int position) {
		setScrollPosition(Orientation.VERTICAL, position);
		return this;
	}

	@Override
	public int getInnerSize(Orientation axis) {
		if(axis == Orientation.HORIZONTAL) return getViewportSize(Orientation.HORIZONTAL);
File
GenericListWidget.java
Developer's decision
Manual
Kind of conflict
Blank
Chunk
Conflicting content
	PacketBlockData(42, PacketBlockData.class),
	PacketCustomMultiBlockOverride(43, PacketCustomMultiBlockOverride.class),
	PacketServerPlugins(44, PacketServerPlugins.class),
<<<<<<< HEAD
	PacketAddonData(45, PacketAddonData.class),
=======
	PacketCustomMaterial(45, PacketCustomMaterial.class),
>>>>>>> 981fb66c63565b46042ad8f540387d096d9a7fc7
	;
	
	private final int id;
Solution content
	PacketBlockData(42, PacketBlockData.class),
	PacketCustomMultiBlockOverride(43, PacketCustomMultiBlockOverride.class),
	PacketServerPlugins(44, PacketServerPlugins.class),
	PacketAddonData(45, PacketAddonData.class),
	PacketCustomMaterial(46, PacketCustomMaterial.class),
	;
	
	private final int id;
File
PacketType.java
Developer's decision
Manual
Kind of conflict
Enum value