mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-13 11:40:29 +00:00
Network the colour palette
Which means it actually has a visible effect! 🎉
This commit is contained in:
parent
b0f0d8fd71
commit
088dab799e
@ -72,9 +72,7 @@ public class TermAPI implements ILuaAPI
|
||||
"setColour",
|
||||
"setColor",
|
||||
"getColour",
|
||||
"getColor",
|
||||
"resetColour",
|
||||
"resetColor"
|
||||
"getColor"
|
||||
};
|
||||
}
|
||||
|
||||
@ -302,6 +300,7 @@ public class TermAPI implements ILuaAPI
|
||||
if( m_terminal.getPalette() != null )
|
||||
{
|
||||
m_terminal.getPalette().setColour( colour, r, g, b );
|
||||
m_terminal.setChanged();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -307,7 +307,12 @@ public class Terminal
|
||||
{
|
||||
return m_changed;
|
||||
}
|
||||
|
||||
|
||||
public void setChanged()
|
||||
{
|
||||
m_changed = true;
|
||||
}
|
||||
|
||||
public void clearChanged()
|
||||
{
|
||||
m_changed = false;
|
||||
@ -326,6 +331,10 @@ public class Terminal
|
||||
nbttagcompound.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
||||
nbttagcompound.setString( "term_textBgColour_" + n, m_backgroundColour[ n ].toString() );
|
||||
}
|
||||
if(m_palette != null)
|
||||
{
|
||||
m_palette.writeToNBT( nbttagcompound );
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@ -355,6 +364,10 @@ public class Terminal
|
||||
m_backgroundColour[n].write( nbttagcompound.getString( "term_textBgColour_" + n ) );
|
||||
}
|
||||
}
|
||||
if (m_palette != null)
|
||||
{
|
||||
m_palette.readFromNBT( nbttagcompound );
|
||||
}
|
||||
m_changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class Palette
|
||||
{
|
||||
private static class PaletteColour
|
||||
@ -93,4 +95,28 @@ public class Palette
|
||||
resetColour( i );
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
for(int i = 0; i < colours.length; ++i)
|
||||
{
|
||||
PaletteColour c = colours[i];
|
||||
String prefix = "term_palette_colour_" + i;
|
||||
nbt.setFloat( prefix + "_r", c.m_r );
|
||||
nbt.setFloat( prefix + "_g", c.m_g );
|
||||
nbt.setFloat( prefix + "_b", c.m_b );
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
for(int i = 0; i < colours.length; ++i)
|
||||
{
|
||||
String prefix = "term_palette_colour_" + i;
|
||||
colours[i].m_r = nbt.getFloat( prefix + "_r" );
|
||||
colours[i].m_g = nbt.getFloat( prefix + "_g" );
|
||||
colours[i].m_b = nbt.getFloat( prefix + "_b" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,6 +383,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
||||
updateCursorBlink()
|
||||
updateCursorColor()
|
||||
updateCursorPos()
|
||||
updatePalette()
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user