2017-05-07 00:18:59 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2019-01-01 01:10:18 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
2017-05-01 13:32:39 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computercraft.core.terminal;
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-05 13:24:29 +00:00
|
|
|
import dan200.computercraft.shared.util.Palette;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
|
|
|
public class Terminal
|
2018-12-23 17:46:58 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
private static final String base16 = "0123456789abcdef";
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
private int m_cursorX;
|
|
|
|
private int m_cursorY;
|
|
|
|
private boolean m_cursorBlink;
|
|
|
|
private int m_cursorColour;
|
|
|
|
private int m_cursorBackgroundColour;
|
|
|
|
|
|
|
|
private int m_width;
|
|
|
|
private int m_height;
|
|
|
|
|
|
|
|
private TextBuffer m_text[];
|
|
|
|
private TextBuffer m_textColour[];
|
|
|
|
private TextBuffer m_backgroundColour[];
|
|
|
|
|
2017-05-05 14:14:13 +00:00
|
|
|
private final Palette m_palette;
|
2017-05-05 13:24:29 +00:00
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
private boolean m_changed;
|
2019-01-20 15:35:48 +00:00
|
|
|
private final Runnable onChanged;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public Terminal( int width, int height )
|
2019-01-20 15:35:48 +00:00
|
|
|
{
|
|
|
|
this( width, height, null );
|
|
|
|
}
|
|
|
|
|
|
|
|
public Terminal( int width, int height, Runnable changedCallback )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
m_width = width;
|
|
|
|
m_height = height;
|
2019-01-20 15:35:48 +00:00
|
|
|
this.onChanged = changedCallback;
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
m_cursorColour = 0;
|
|
|
|
m_cursorBackgroundColour = 15;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text = new TextBuffer[m_height];
|
|
|
|
m_textColour = new TextBuffer[m_height];
|
|
|
|
m_backgroundColour = new TextBuffer[m_height];
|
|
|
|
for( int i = 0; i < m_height; i++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
m_text[i] = new TextBuffer( ' ', m_width );
|
|
|
|
m_textColour[i] = new TextBuffer( base16.charAt( m_cursorColour ), m_width );
|
|
|
|
m_backgroundColour[i] = new TextBuffer( base16.charAt( m_cursorBackgroundColour ), m_width );
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
m_cursorX = 0;
|
|
|
|
m_cursorY = 0;
|
|
|
|
m_cursorBlink = false;
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
m_changed = false;
|
2017-05-05 13:24:29 +00:00
|
|
|
|
|
|
|
m_palette = new Palette();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void reset()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
m_cursorColour = 0;
|
|
|
|
m_cursorBackgroundColour = 15;
|
|
|
|
m_cursorX = 0;
|
|
|
|
m_cursorY = 0;
|
|
|
|
m_cursorBlink = false;
|
|
|
|
clear();
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-05 13:24:29 +00:00
|
|
|
m_palette.resetColours();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
|
|
|
public int getWidth()
|
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_width;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
|
|
|
public int getHeight()
|
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_height;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void resize( int width, int height )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
if( width == m_width && height == m_height )
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
int oldHeight = m_height;
|
|
|
|
int oldWidth = m_width;
|
|
|
|
TextBuffer[] oldText = m_text;
|
2017-05-01 13:32:39 +00:00
|
|
|
TextBuffer[] oldTextColour = m_textColour;
|
|
|
|
TextBuffer[] oldBackgroundColour = m_backgroundColour;
|
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
m_width = width;
|
|
|
|
m_height = height;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text = new TextBuffer[m_height];
|
|
|
|
m_textColour = new TextBuffer[m_height];
|
|
|
|
m_backgroundColour = new TextBuffer[m_height];
|
|
|
|
for( int i = 0; i < m_height; i++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
if( i >= oldHeight )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[i] = new TextBuffer( ' ', m_width );
|
|
|
|
m_textColour[i] = new TextBuffer( base16.charAt( m_cursorColour ), m_width );
|
|
|
|
m_backgroundColour[i] = new TextBuffer( base16.charAt( m_cursorBackgroundColour ), m_width );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
else if( m_width == oldWidth )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[i] = oldText[i];
|
|
|
|
m_textColour[i] = oldTextColour[i];
|
|
|
|
m_backgroundColour[i] = oldBackgroundColour[i];
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[i] = new TextBuffer( ' ', m_width );
|
|
|
|
m_textColour[i] = new TextBuffer( base16.charAt( m_cursorColour ), m_width );
|
|
|
|
m_backgroundColour[i] = new TextBuffer( base16.charAt( m_cursorBackgroundColour ), m_width );
|
|
|
|
m_text[i].write( oldText[i] );
|
|
|
|
m_textColour[i].write( oldTextColour[i] );
|
|
|
|
m_backgroundColour[i].write( oldBackgroundColour[i] );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public void setCursorPos( int x, int y )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
if( m_cursorX != x || m_cursorY != y )
|
|
|
|
{
|
|
|
|
m_cursorX = x;
|
|
|
|
m_cursorY = y;
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public void setCursorBlink( boolean blink )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
if( m_cursorBlink != blink )
|
|
|
|
{
|
|
|
|
m_cursorBlink = blink;
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public void setTextColour( int colour )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
if( m_cursorColour != colour )
|
|
|
|
{
|
|
|
|
m_cursorColour = colour;
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public void setBackgroundColour( int colour )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
if( m_cursorBackgroundColour != colour )
|
|
|
|
{
|
|
|
|
m_cursorBackgroundColour = colour;
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public int getCursorX()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_cursorX;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public int getCursorY()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_cursorY;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public boolean getCursorBlink()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_cursorBlink;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public int getTextColour()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_cursorColour;
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
public int getBackgroundColour()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_cursorBackgroundColour;
|
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-05 13:24:29 +00:00
|
|
|
public Palette getPalette()
|
|
|
|
{
|
|
|
|
return m_palette;
|
|
|
|
}
|
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void blit( String text, String textColour, String backgroundColour )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
int x = m_cursorX;
|
|
|
|
int y = m_cursorY;
|
|
|
|
if( y >= 0 && y < m_height )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[y].write( text, x );
|
|
|
|
m_textColour[y].write( textColour, x );
|
|
|
|
m_backgroundColour[y].write( backgroundColour, x );
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void write( String text )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
int x = m_cursorX;
|
|
|
|
int y = m_cursorY;
|
|
|
|
if( y >= 0 && y < m_height )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[y].write( text, x );
|
|
|
|
m_textColour[y].fill( base16.charAt( m_cursorColour ), x, x + text.length() );
|
|
|
|
m_backgroundColour[y].fill( base16.charAt( m_cursorBackgroundColour ), x, x + text.length() );
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void scroll( int yDiff )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
if( yDiff != 0 )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
TextBuffer[] newText = new TextBuffer[m_height];
|
|
|
|
TextBuffer[] newTextColour = new TextBuffer[m_height];
|
|
|
|
TextBuffer[] newBackgroundColour = new TextBuffer[m_height];
|
|
|
|
for( int y = 0; y < m_height; y++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
int oldY = y + yDiff;
|
|
|
|
if( oldY >= 0 && oldY < m_height )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
newText[y] = m_text[oldY];
|
|
|
|
newTextColour[y] = m_textColour[oldY];
|
|
|
|
newBackgroundColour[y] = m_backgroundColour[oldY];
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
newText[y] = new TextBuffer( ' ', m_width );
|
|
|
|
newTextColour[y] = new TextBuffer( base16.charAt( m_cursorColour ), m_width );
|
|
|
|
newBackgroundColour[y] = new TextBuffer( base16.charAt( m_cursorBackgroundColour ), m_width );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
m_text = newText;
|
|
|
|
m_textColour = newTextColour;
|
|
|
|
m_backgroundColour = newBackgroundColour;
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void clear()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
for( int y = 0; y < m_height; y++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[y].fill( ' ' );
|
|
|
|
m_textColour[y].fill( base16.charAt( m_cursorColour ) );
|
|
|
|
m_backgroundColour[y].fill( base16.charAt( m_cursorBackgroundColour ) );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void clearLine()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
int y = m_cursorY;
|
2017-05-01 14:48:44 +00:00
|
|
|
if( y >= 0 && y < m_height )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
m_text[y].fill( ' ' );
|
|
|
|
m_textColour[y].fill( base16.charAt( m_cursorColour ) );
|
|
|
|
m_backgroundColour[y].fill( base16.charAt( m_cursorBackgroundColour ) );
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized TextBuffer getLine( int y )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
if( y >= 0 && y < m_height )
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
return m_text[y];
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
return null;
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized void setLine( int y, String text, String textColour, String backgroundColour )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
m_text[y].write( text );
|
|
|
|
m_textColour[y].write( textColour );
|
|
|
|
m_backgroundColour[y].write( backgroundColour );
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized TextBuffer getTextColourLine( int y )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
if( y >= 0 && y < m_height )
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
return m_textColour[y];
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-02-22 21:20:08 +00:00
|
|
|
public synchronized TextBuffer getBackgroundColourLine( int y )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
if( y >= 0 && y < m_height )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
return m_backgroundColour[y];
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-01-20 15:35:48 +00:00
|
|
|
/**
|
|
|
|
* @deprecated All {@code *Changed()} methods are deprecated: one should pass in a callback
|
|
|
|
* instead.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public final boolean getChanged()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
return m_changed;
|
|
|
|
}
|
2017-05-05 15:21:53 +00:00
|
|
|
|
2019-01-20 15:35:48 +00:00
|
|
|
public final void setChanged()
|
2017-05-05 15:21:53 +00:00
|
|
|
{
|
|
|
|
m_changed = true;
|
2019-01-20 15:35:48 +00:00
|
|
|
if( onChanged != null ) onChanged.run();
|
2017-05-05 15:21:53 +00:00
|
|
|
}
|
|
|
|
|
2019-01-20 15:35:48 +00:00
|
|
|
public final void clearChanged()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
m_changed = false;
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-12-29 14:01:00 +00:00
|
|
|
public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
nbt.setInteger( "term_cursorX", m_cursorX );
|
|
|
|
nbt.setInteger( "term_cursorY", m_cursorY );
|
|
|
|
nbt.setBoolean( "term_cursorBlink", m_cursorBlink );
|
|
|
|
nbt.setInteger( "term_textColour", m_cursorColour );
|
|
|
|
nbt.setInteger( "term_bgColour", m_cursorBackgroundColour );
|
2018-12-23 17:46:58 +00:00
|
|
|
for( int n = 0; n < m_height; n++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
nbt.setString( "term_text_" + n, m_text[n].toString() );
|
|
|
|
nbt.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
|
|
|
nbt.setString( "term_textBgColour_" + n, m_backgroundColour[n].toString() );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
if( m_palette != null )
|
2017-05-05 15:21:53 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_palette.writeToNBT( nbt );
|
2017-05-05 15:21:53 +00:00
|
|
|
}
|
2018-12-29 14:01:00 +00:00
|
|
|
return nbt;
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
|
2018-12-29 14:01:00 +00:00
|
|
|
public synchronized void readFromNBT( NBTTagCompound nbt )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_cursorX = nbt.getInteger( "term_cursorX" );
|
|
|
|
m_cursorY = nbt.getInteger( "term_cursorY" );
|
|
|
|
m_cursorBlink = nbt.getBoolean( "term_cursorBlink" );
|
|
|
|
m_cursorColour = nbt.getInteger( "term_textColour" );
|
|
|
|
m_cursorBackgroundColour = nbt.getInteger( "term_bgColour" );
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-12-23 17:46:58 +00:00
|
|
|
for( int n = 0; n < m_height; n++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
m_text[n].fill( ' ' );
|
2018-12-29 14:01:00 +00:00
|
|
|
if( nbt.hasKey( "term_text_" + n ) )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_text[n].write( nbt.getString( "term_text_" + n ) );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
m_textColour[n].fill( base16.charAt( m_cursorColour ) );
|
2018-12-29 14:01:00 +00:00
|
|
|
if( nbt.hasKey( "term_textColour_" + n ) )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_textColour[n].write( nbt.getString( "term_textColour_" + n ) );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
m_backgroundColour[n].fill( base16.charAt( m_cursorBackgroundColour ) );
|
2018-12-29 14:01:00 +00:00
|
|
|
if( nbt.hasKey( "term_textBgColour_" + n ) )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_backgroundColour[n].write( nbt.getString( "term_textBgColour_" + n ) );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-23 17:46:58 +00:00
|
|
|
if( m_palette != null )
|
2017-05-05 15:21:53 +00:00
|
|
|
{
|
2018-12-29 14:01:00 +00:00
|
|
|
m_palette.readFromNBT( nbt );
|
2017-05-05 15:21:53 +00:00
|
|
|
}
|
2019-01-20 15:35:48 +00:00
|
|
|
setChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|