mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-09 15:27:25 +00:00
Add palette functions to monitor peripheral
This commit is contained in:
parent
088dab799e
commit
6997471280
@ -320,7 +320,7 @@ public class TermAPI implements ILuaAPI
|
|||||||
{
|
{
|
||||||
if ( m_terminal.getPalette() != null )
|
if ( m_terminal.getPalette() != null )
|
||||||
{
|
{
|
||||||
return ArrayUtils.toObject( m_terminal.getPalette().getColour64( colour ) );
|
return ArrayUtils.toObject( m_terminal.getPalette().getColour( colour ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -11,6 +11,8 @@ import dan200.computercraft.api.lua.LuaException;
|
|||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
|
import dan200.computercraft.shared.util.Palette;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
public class MonitorPeripheral implements IPeripheral
|
public class MonitorPeripheral implements IPeripheral
|
||||||
{
|
{
|
||||||
@ -52,7 +54,11 @@ public class MonitorPeripheral implements IPeripheral
|
|||||||
"getTextColor",
|
"getTextColor",
|
||||||
"getBackgroundColour",
|
"getBackgroundColour",
|
||||||
"getBackgroundColor",
|
"getBackgroundColor",
|
||||||
"blit"
|
"blit",
|
||||||
|
"setColour",
|
||||||
|
"setColor",
|
||||||
|
"getColour",
|
||||||
|
"getColor"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +224,52 @@ public class MonitorPeripheral implements IPeripheral
|
|||||||
terminal.setCursorPos( terminal.getCursorX() + text.length(), terminal.getCursorY() );
|
terminal.setCursorPos( terminal.getCursorX() + text.length(), terminal.getCursorY() );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
case 20:
|
||||||
|
case 21:
|
||||||
|
{
|
||||||
|
// setColour/setColor
|
||||||
|
Terminal terminal = m_monitor.getTerminal().getTerminal();
|
||||||
|
Palette palette = terminal.getPalette();
|
||||||
|
|
||||||
|
// setColour/setColor
|
||||||
|
if( args.length < 4 || !(args[0] instanceof Double) || !(args[1] instanceof Double) || !(args[2] instanceof Double) || !(args[3] instanceof Double) )
|
||||||
|
{
|
||||||
|
throw new LuaException( "Expected number, number, number, number" );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isColour = m_monitor.getTerminal().isColour();
|
||||||
|
|
||||||
|
if( !isColour )
|
||||||
|
{
|
||||||
|
throw new LuaException( "Colour not supported" );
|
||||||
|
}
|
||||||
|
|
||||||
|
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args, true );
|
||||||
|
float r = ((Double)args[1]).floatValue();
|
||||||
|
float g = ((Double)args[2]).floatValue();
|
||||||
|
float b = ((Double)args[3]).floatValue();
|
||||||
|
|
||||||
|
if( palette != null )
|
||||||
|
{
|
||||||
|
palette.setColour( colour, r, g, b );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 22:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
// getColour/getColor
|
||||||
|
Terminal terminal = m_monitor.getTerminal().getTerminal();
|
||||||
|
Palette palette = terminal.getPalette();
|
||||||
|
|
||||||
|
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args, m_monitor.getTerminal().isColour() );
|
||||||
|
|
||||||
|
if( palette != null )
|
||||||
|
{
|
||||||
|
return ArrayUtils.toObject( palette.getColour( colour ) );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -70,16 +70,6 @@ public class Palette
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[] getColour64( int i )
|
|
||||||
{
|
|
||||||
if( i >= 0 && i < colours.length )
|
|
||||||
{
|
|
||||||
PaletteColour c = colours[ i ];
|
|
||||||
return new double[] { (double)c.m_r, (double)c.m_g, (double)c.m_b };
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetColour( int i )
|
public void resetColour( int i )
|
||||||
{
|
{
|
||||||
if(i >= 0 && i < colours.length )
|
if(i >= 0 && i < colours.length )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user