mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-27 15:23:12 +00:00
More work on the API but IIcons are not behaving as expected
This commit is contained in:
1 parent
3773cfdcbe
commit
0a2876d407
20 files changed
+340
-72
No files matched your search
@@ -3,43 +3,57 @@ package baubles.api.expanded;
|
||||
import baubles.api.BaubleType;
|
||||
|
||||
public class BaubleExpandedSlots {
|
||||
|
||||
//The total number of slots that can be added.
|
||||
public static final int slotLimit = 20;
|
||||
|
||||
//All "default" types will have slot backgrounds registered automatically.
|
||||
public static final String ringType = "ring";
|
||||
public static final String amuletType = "amulet";
|
||||
public static final String beltType = "belt";
|
||||
public static final String headType = "head";
|
||||
public static final String bodyType = "body";
|
||||
public static final String charmType = "charm";
|
||||
public static final String gauntletType = "gauntlet";
|
||||
public static final String capeType = "cape";
|
||||
|
||||
public static final String[] defaultTypes = {
|
||||
ringType,
|
||||
amuletType,
|
||||
beltType,
|
||||
headType,
|
||||
bodyType,
|
||||
charmType,
|
||||
gauntletType,
|
||||
capeType
|
||||
};
|
||||
|
||||
private static String[] slots = new String[slotLimit];
|
||||
private static int newSlotsRemaining = slotLimit;
|
||||
|
||||
public static final String ringType = "ring";
|
||||
public static final String amuletType = "amulet";
|
||||
public static final String beltType = "belt";
|
||||
|
||||
static {
|
||||
tryAddSlot(amuletType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(beltType);
|
||||
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
tryAddSlot(ringType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to add a slot, but will not if there are no slots left.
|
||||
*
|
||||
* @param type The type of the slot being added
|
||||
* @return If adding a slot was successful
|
||||
*/
|
||||
public static boolean tryAddSlot(String type) {
|
||||
//TODO: block after GUI init
|
||||
if(newSlotsRemaining >= 1) {
|
||||
slots[slotLimit - newSlotsRemaining] = type;
|
||||
newSlotsRemaining--;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a slot of the specified type if one could be found.
|
||||
*
|
||||
* @param type The type of the slot being removed
|
||||
* @return If removing a slot was successful
|
||||
*/
|
||||
public static boolean tryRemoveSlot(String type) {
|
||||
//TODO: block after GUI init
|
||||
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
|
||||
if(slots[slotToCheck].equals(type)) {
|
||||
for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) {
|
||||
@@ -53,6 +67,13 @@ public class BaubleExpandedSlots {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the currently number of slots matching the specified type.
|
||||
*
|
||||
* @param type The type of slot being counted
|
||||
* @return The current total number of matching slots found
|
||||
*/
|
||||
public static int totalCurrentSlotsOfType(String type) {
|
||||
int total = 0;
|
||||
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
|
||||
@@ -63,18 +84,36 @@ public class BaubleExpandedSlots {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots that are currently used.
|
||||
*
|
||||
* @return The total number of slots currently used
|
||||
*/
|
||||
public static int getTotalSlots() {
|
||||
return slotLimit - newSlotsRemaining;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type of the specified slot or null if none or out of range.
|
||||
*
|
||||
* @param slot The slot to check
|
||||
* @return The type in the specified slot or "unknown"
|
||||
*/
|
||||
public static String getSlotType(int slot) {
|
||||
if (slot > 0 & slot < slotLimit) {
|
||||
if (slot >= 0 & slot < slotLimit) {
|
||||
return slots[slot];
|
||||
} else {
|
||||
return null;
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type based on the specified BaubleType.
|
||||
*
|
||||
* @param type The BaubleType get a matching type from
|
||||
* @return The type matching the BaubleType or "unknown"
|
||||
*/
|
||||
public static String getTypeStringFromBaubleType(BaubleType type) {
|
||||
switch(type) {
|
||||
case RING:
|
||||
|
||||
Reference in new issue
Block a user