Implement VISIBLE
This commit is contained in:
@@ -268,8 +268,17 @@ class BuiltinFunction
|
||||
}
|
||||
return p.button;
|
||||
}
|
||||
static void VISIBLE(PetitComputer p, DefaultValue!(int) console, DefaultValue!(int) graphic, DefaultValue!(int) BG, DefaultValue!(int) sprite)
|
||||
static void VISIBLE(PetitComputer p, int console, int graphic, int BG, int sprite)
|
||||
{
|
||||
import std.exception : enforce;
|
||||
enforce(console == 0 || console == 1, new OutOfRange("VISIBLE", 1));
|
||||
enforce(graphic == 0 || graphic == 1, new OutOfRange("VISIBLE", 2));
|
||||
enforce(BG == 0 || BG == 1, new OutOfRange("VISIBLE", 3));
|
||||
enforce(sprite == 0 || sprite == 1, new OutOfRange("VISIBLE", 4));
|
||||
p.console.visible = cast(bool)console;
|
||||
p.graphic.visible = cast(bool)graphic;
|
||||
p.BGvisible = cast(bool)BG;
|
||||
p.sprite.visible = cast(bool)sprite;
|
||||
}
|
||||
static void XON(PetitComputer p, Value mode/*!?!???!?*/)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,15 @@ class Console
|
||||
SDL_Rect[] fontTable = new SDL_Rect[65536];
|
||||
GraphicPage GRPF;
|
||||
PetitComputer petitcom;
|
||||
bool[2] visibles = [true, true];
|
||||
bool visible()
|
||||
{
|
||||
return visibles[petitcom.displaynum];
|
||||
}
|
||||
void visible(bool value)
|
||||
{
|
||||
visibles[petitcom.displaynum] = value;
|
||||
}
|
||||
this(PetitComputer p)
|
||||
{
|
||||
petitcom = p;
|
||||
@@ -253,7 +262,7 @@ class Console
|
||||
}
|
||||
void render()
|
||||
{
|
||||
if(petitcom.xscreenmode == 2)
|
||||
if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
@@ -291,80 +300,86 @@ class Console
|
||||
glEnd();
|
||||
return;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeight; y++)
|
||||
for(int x = 0; x < consoleWidth; x++)
|
||||
{
|
||||
auto back = consoleColorGL[console[y][x].backColor];
|
||||
if(back)
|
||||
if (showCursor || visibles[0])
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeight; y++)
|
||||
for(int x = 0; x < consoleWidth; x++)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&back);
|
||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
||||
glVertex3f(x * 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
||||
auto back = consoleColorGL[console[y][x].backColor];
|
||||
if(back)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&back);
|
||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
||||
glVertex3f(x * 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
||||
}
|
||||
}
|
||||
if(petitcom.displaynum == 0 && showCursor && animationCursor)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
|
||||
}
|
||||
if(petitcom.displaynum == 0 && showCursor && animationCursor)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
|
||||
}
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeight; y++)
|
||||
for(int x = 0; x < consoleWidth; x++)
|
||||
{
|
||||
drawCharacter(x, y, console[y][x]);
|
||||
}
|
||||
glEnd();
|
||||
if(petitcom.xscreenmode != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//下画面
|
||||
petitcom.chScreen(40, 0, 400, 240);
|
||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeightDisplay1; y++)
|
||||
for(int x = 0; x < consoleWidthDisplay1; x++)
|
||||
{
|
||||
auto back = consoleColorGL[consoleDisplay1[y][x].backColor];
|
||||
if(back)
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeight; y++)
|
||||
for(int x = 0; x < consoleWidth; x++)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&back);
|
||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
||||
glVertex3f(x * 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
||||
drawCharacter(x, y, console[y][x]);
|
||||
}
|
||||
}
|
||||
if(petitcom.displaynum == 1 && showCursor && animationCursor)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
|
||||
}
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeightDisplay1; y++)
|
||||
for(int x = 0; x < consoleWidthDisplay1; x++)
|
||||
glEnd();
|
||||
if(petitcom.xscreenmode != 1)
|
||||
{
|
||||
drawCharacter(x, y, consoleDisplay1[y][x]);
|
||||
return;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
if (visibles[1] || showCursor)
|
||||
{
|
||||
//下画面
|
||||
petitcom.chScreen(40, 0, 400, 240);
|
||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeightDisplay1; y++)
|
||||
for(int x = 0; x < consoleWidthDisplay1; x++)
|
||||
{
|
||||
auto back = consoleColorGL[consoleDisplay1[y][x].backColor];
|
||||
if(back)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&back);
|
||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
||||
glVertex3f(x * 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8, 1024);
|
||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
||||
}
|
||||
}
|
||||
if(petitcom.displaynum == 1 && showCursor && animationCursor)
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
||||
glVertex3f((CSRX * 8), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
|
||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
|
||||
}
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for(int y = 0; y < consoleHeightDisplay1; y++)
|
||||
for(int x = 0; x < consoleWidthDisplay1; x++)
|
||||
{
|
||||
drawCharacter(x, y, consoleDisplay1[y][x]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
void print(T...)(T args)
|
||||
{
|
||||
|
||||
@@ -15,9 +15,17 @@ class Graphic
|
||||
paint.buffer = new uint[512 * 512];
|
||||
}
|
||||
|
||||
bool visibleGRP = true;
|
||||
bool[2] visibles = [true, true];
|
||||
private int[2] showPage = [0, 1];
|
||||
private int[2] usePage = [0, 1];
|
||||
bool visible()
|
||||
{
|
||||
return visibles[petitcom.displaynum];
|
||||
}
|
||||
void visible(bool value)
|
||||
{
|
||||
visibles[petitcom.displaynum] = value;
|
||||
}
|
||||
@property int useGRP()
|
||||
{
|
||||
return usePage[petitcom.displaynum];
|
||||
@@ -471,6 +479,8 @@ class Graphic
|
||||
int gprio;
|
||||
void render(int display, float w, float h)
|
||||
{
|
||||
if (!visibles[display])
|
||||
return;
|
||||
float z = gprio;
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glBindTexture(GL_TEXTURE_2D, GRP[showPage[display]].glTexture);
|
||||
|
||||
@@ -413,6 +413,15 @@ class PetitComputer
|
||||
{
|
||||
return bg;
|
||||
}
|
||||
bool[2] BGvisibles = [true, true];
|
||||
bool BGvisible()
|
||||
{
|
||||
return BGvisibles[displaynum];
|
||||
}
|
||||
void BGvisible(bool value)
|
||||
{
|
||||
BGvisibles[displaynum] = value;
|
||||
}
|
||||
protected BG[4] bg;
|
||||
bool quit;
|
||||
Condition renderCondition;
|
||||
@@ -586,7 +595,7 @@ class PetitComputer
|
||||
version(test) glLoadIdentity();
|
||||
version(test) glRotatef(rot_test_deg, rot_test_x, rot_test_y, rot_test_z);
|
||||
glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage].glTexture);
|
||||
if(xscreenmode == 2)
|
||||
if(xscreenmode == 2 && BGvisibles[0])
|
||||
{
|
||||
for(int i = 0; i < bgmax; i++)
|
||||
{
|
||||
@@ -595,16 +604,22 @@ class PetitComputer
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < bgmax; i++)
|
||||
if (BGvisibles[0])
|
||||
{
|
||||
bg[i].render(400f, 240f);
|
||||
for(int i = 0; i < bgmax; i++)
|
||||
{
|
||||
bg[i].render(400f, 240f);
|
||||
}
|
||||
}
|
||||
if(xscreenmode == 1)
|
||||
{
|
||||
chScreen(40, 0, 320, 240);
|
||||
for(int i = bgmax; i < bg.length; i++)
|
||||
if (BGvisibles[1])
|
||||
{
|
||||
bg[i].render(320f, 240f);
|
||||
chScreen(40, 0, 320, 240);
|
||||
for(int i = bgmax; i < bg.length; i++)
|
||||
{
|
||||
bg[i].render(320f, 240f);
|
||||
}
|
||||
}
|
||||
chScreen(0, 240, 400, 240);
|
||||
}
|
||||
|
||||
@@ -300,6 +300,15 @@ class Sprite
|
||||
PetitComputer petitcom;
|
||||
string spdefTableFile = "spdef.csv";
|
||||
int spmax = 512;
|
||||
bool[2] visibles = [true, true];
|
||||
bool visible()
|
||||
{
|
||||
return visibles[petitcom.displaynum];
|
||||
}
|
||||
void visible(bool value)
|
||||
{
|
||||
visibles[petitcom.displaynum] = value;
|
||||
}
|
||||
void initUVTable()
|
||||
{
|
||||
SPDEFTable = new SpriteDef[4096];
|
||||
@@ -558,6 +567,17 @@ class Sprite
|
||||
SpriteBucket* bucketsptr;
|
||||
void render()
|
||||
{
|
||||
if (!visibles[0] && !visibles[1])
|
||||
{
|
||||
foreach(ref sprite; sprites)
|
||||
{
|
||||
if(sprite.define)
|
||||
{
|
||||
animation(&sprite);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
//とりあえずZ更新されたら描画時にまとめてソート
|
||||
//thread safe.....
|
||||
if(zChange)
|
||||
@@ -648,6 +668,8 @@ class Sprite
|
||||
{
|
||||
if(!dis && sprite.id >= spmax)
|
||||
{
|
||||
if (!visibles[1])
|
||||
continue;
|
||||
disw = 160f;
|
||||
disw2 = 320f;
|
||||
petitcom.chScreen(40, 0, 320, 240);
|
||||
@@ -658,6 +680,8 @@ class Sprite
|
||||
{
|
||||
if(sprite.id < spmax && dis)
|
||||
{
|
||||
if (!visibles[0])
|
||||
continue;
|
||||
disw = 200f;
|
||||
disw2 = 400f;
|
||||
petitcom.chScreen(0, 240, 400, 240);
|
||||
|
||||
Reference in New Issue
Block a user