colours now decrement accordingly when one is removed

This commit is contained in:
MachineMuse 2013-05-06 14:49:44 -06:00
parent 4bfecdec03
commit 56c4e219cc
5 changed files with 46 additions and 19 deletions

View file

@ -32,6 +32,7 @@ class ColourPickerFrame(val borderRef: MuseRect, val insideColour: Colour, val b
var selectedSlider: Option[ClickableSlider] = None
var selectedColour: Int = 0
var decrAbove: Int = -1
def getOrCreateColourTag:Option[NBTTagIntArray] = {
if(itemSelector.getSelectedItem == null) return None
@ -120,7 +121,7 @@ class ColourPickerFrame(val borderRef: MuseRect, val insideColour: Colour, val b
}
if (y > border.bottom - 16 && y < border.bottom - 8) {
val colourCol:Int = (x - border.left - 8.0).toInt / 8
if (colourCol > 0 && colourCol < colours.size) {
if (colourCol >= 0 && colourCol < colours.size) {
onSelectColour(colourCol.toInt)
} else if (colourCol == colours.size) {
MuseLogger.logDebug("Adding")
@ -136,6 +137,10 @@ class ColourPickerFrame(val borderRef: MuseRect, val insideColour: Colour, val b
if(y > border.bottom - 24 && y < border.bottom - 16 && x > border.left + 8 + selectedColour * 8 && x < border.left + 16 + selectedColour * 8) {
getOrCreateColourTag.map( e=>{
e.intArray = e.intArray diff Array(e.intArray(selectedColour))
decrAbove = selectedColour
if(selectedColour == e.intArray.size) {
selectedColour = selectedColour - 1
}
val player = Minecraft.getMinecraft.thePlayer
if (player.worldObj.isRemote)
player.sendQueue.addToSendQueue(new MusePacketColourInfo(player.asInstanceOf[Player], itemSelector.getSelectedItem.inventorySlot, e.intArray).getPacket250)

View file

@ -59,8 +59,14 @@ class PartManipContainer(val itemSelect: ItemSelectionFrame, val colourSelect: C
(acc, subframe) => subframe.updateItems; subframe.border.bottom()
}.toInt
}
if(colourSelect.decrAbove > -1) {
decrAbove(colourSelect.decrAbove)
colourSelect.decrAbove = -1
}
}
def decrAbove(index:Int) {for(frame<-modelframes) frame.decrAbove(index)}
override def draw() {
super.draw()

View file

@ -73,6 +73,22 @@ class PartManipSubFrame(val model: ModelSpec, val colourframe: ColourPickerFrame
}
}
def decrAbove(index: Int) {
for (spec <- specs) {
val tagname = ModelRegistry.makeName(spec)
val player = Minecraft.getMinecraft.thePlayer
val tagdata = getOrDontGetSpecTag(spec)
tagdata.map(e => {
val oldindex = spec.getColourIndex(e)
if (oldindex >= index) {
spec.setColourIndex(e, oldindex - 1)
if (player.worldObj.isRemote) player.sendQueue.addToSendQueue(new MusePacketCosmeticInfo(player.asInstanceOf[Player], getSelectedItem.inventorySlot, tagname, e).getPacket250)
}
})
}
}
def drawSpecPartial(x: Double, y: Double, spec: ModelPartSpec, ymino: Double, ymaxo: Double) = {
val tag = getSpecTag(spec)
val selcomp = if (tag.hasNoTags) 0 else if (spec.getGlow(tag)) 2 else 1
@ -87,7 +103,7 @@ class PartManipSubFrame(val model: ModelSpec, val colourframe: ColourPickerFrame
GuiIcons.ArmourColourPatch(acc, y, new Colour(colour), ymin = ymino, ymax = ymaxo)
acc + 8
}
if(selcomp > 0) {
if (selcomp > 0) {
GuiIcons.SelectedArmorOverlay(x + 28 + selcolour * 8, y, ymin = ymino, ymax = ymaxo)
}

View file

@ -63,7 +63,7 @@ class ArmorModel(par1: Float, par2: Float, par3: Int, par4: Int) extends ModelBi
import scala.collection.JavaConverters._
val colours = renderSpec.getIntArray("colours")
for (tag <- NBTTagAccessor.getValues(renderSpec).asScala) {
RenderPart(tag, colours, this)
RenderPart(tag, colours, this, visible)
}
glPopMatrix()
}

View file

@ -12,25 +12,25 @@ import net.minecraft.nbt.NBTTagCompound
* Created: 4:16 AM, 29/04/13
*/
object RenderPart {
def apply(nbt: NBTTagCompound, c: Array[Int], m: ArmorModel) {
def apply(nbt: NBTTagCompound, c: Array[Int], m: ArmorModel, slot: Int) {
//MuseLogger.logDebug("rendering model " + nbt.getString("model") + ":" + nbt.getString("part"))
ModelRegistry.getPart(nbt).map(part => {
if (part.slot == slot) {
Minecraft.getMinecraft.renderEngine.bindTexture(part.getTexture(nbt))
glPushMatrix
part.morph(m)
if (part.getGlow(nbt)) MuseRenderer.glowOn
val ix = part.getColourIndex(nbt)
if (ix < c.size) {
Colour.doGLByInt(c(ix))
}
part.modelSpec.applyOffsetAndRotation
part.modelSpec.model.renderPart(part.partName)
Minecraft.getMinecraft.renderEngine.bindTexture(part.getTexture(nbt))
glPushMatrix
part.morph(m)
if (part.getGlow(nbt)) MuseRenderer.glowOn
val ix = part.getColourIndex(nbt)
if (ix < c.size) {
Colour.doGLByInt(c(ix))
Colour.WHITE.doGL
if (part.getGlow(nbt)) MuseRenderer.glowOff
glPopMatrix
}
part.modelSpec.applyOffsetAndRotation
part.modelSpec.model.renderPart(part.partName)
Colour.WHITE.doGL
if (part.getGlow(nbt)) MuseRenderer.glowOff
glPopMatrix
}
)
})
}
}