1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-16 14:50:01 +00:00

Merge branch 'master' of file:///Users/User/code/coding/Aquaria_fg_clean

Conflicts:
	Aquaria/UserSettings.cpp
This commit is contained in:
fgenesis 2012-06-14 18:16:31 +01:00
commit 8142376bbf
5 changed files with 65 additions and 119 deletions

View file

@ -220,11 +220,7 @@ void AquariaSaveSlot::onUpdate(float dt)
else if ((!core->mouse.buttons.left && !core->mouse.buttons.right) && mbDown) else if ((!core->mouse.buttons.left && !core->mouse.buttons.right) && mbDown)
{ {
mbDown = false; mbDown = false;
if (text1->getText().find(dsq->continuity.stringBank.get(2003))!=std::string::npos && dsq->saveSlotMode == SSM_LOAD) if (!(empty && dsq->saveSlotMode == SSM_LOAD))
{
}
else
{ {
selected = true; selected = true;
// pick this file // pick this file

View file

@ -1200,11 +1200,11 @@ void Continuity::loadSongBank()
songSlotNames.clear(); songSlotNames.clear();
songBank.clear(); songBank.clear();
loadIntoSongBank("data/songs.xml"); loadIntoSongBank(dsq->user.localisePath("data/songs.xml"));
if (dsq->mod.isActive()) if (dsq->mod.isActive())
{ {
loadIntoSongBank(dsq->mod.getPath() + "scripts/songs.xml"); loadIntoSongBank(dsq->user.localisePath(dsq->mod.getPath() + "scripts/songs.xml", dsq->mod.getPath()));
} }
} }

View file

@ -1958,54 +1958,56 @@ void Game::clearObsRows()
void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim) void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
{ {
/*
if (obsType == OT_INVISIBLEIN)
obsType = OT_INVISIBLE;
*/
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
if (q->texture) if (q->texture)
{ {
std::vector<TileVector> obs, obsCopy; std::vector<TileVector> obs;
TileVector tpos(q->position); TileVector tpos(q->position);
//int tw = int((q->getWidth()*q->scale.x)/TILE_SIZE); int widthscale = q->getWidth()*q->scale.x;
//int th = int((q->getHeight()*q->scale.y)/TILE_SIZE); int heightscale = q->getHeight()*q->scale.y;
int w2 = int(q->getWidth()*q->scale.x)/2; int w2 = widthscale/2;
int h2 = int(q->getHeight()*q->scale.y)/2; int h2 = heightscale/2;
w2/=TILE_SIZE; w2/=TILE_SIZE;
h2/=TILE_SIZE; h2/=TILE_SIZE;
tpos.x -= w2; tpos.x -= w2;
tpos.y -= h2; tpos.y -= h2;
GLuint id = q->texture->textures[0]; GLuint id = q->texture->textures[0];
float w, h, c=4; int w = 0, h = 0;
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
//glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPONENTS, &c);// assume 4 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPONENTS, &c);// assume 4
int size = w*h*c; int size = w*h*4;
unsigned char *data=0; if(size <= 0)
int sz = size*sizeof(unsigned char); return;
data = (unsigned char*)malloc(sz); unsigned char *data = (unsigned char*)malloc(size + 6);
if (c == 4) memcpy(data + size, "SAFE", 5);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); if (!data)
else if (c == 3)
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
else
{ {
if (data) errorLog("Game::fillGridFromQuad allocation failure");
free(data); return;
}
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glBindTexture(GL_TEXTURE_2D, 0);
// Not sure but this might be the case with nouveau drivers on linux... still investigating. -- fg
if(memcmp(data + size, "SAFE", 5))
{
errorLog("Game::fillGridFromQuad(): Broken graphics driver! Wrote past end of buffer!");
free(data); // in case we are here, this will most likely cause a crash.
return; return;
} }
for (int tx = 0; tx < (q->getWidth()*q->scale.x); tx+=TILE_SIZE) int szx = TILE_SIZE/q->scale.x;
int szy = TILE_SIZE/q->scale.y;
if (szx < 1) szx = 1;
if (szy < 1) szy = 1;
for (int tx = 0; tx < widthscale; tx+=TILE_SIZE)
{ {
for (int ty = 0; ty < (q->getHeight()*q->scale.y); ty+=TILE_SIZE) for (int ty = 0; ty < heightscale; ty+=TILE_SIZE)
{ {
int num = 0; int num = 0;
int szx = TILE_SIZE/q->scale.x;
int szy = TILE_SIZE/q->scale.y;
if (szx < 1) szx = 1;
if (szy < 1) szy = 1;
for (int x = 0; x < szx; x++) for (int x = 0; x < szx; x++)
{ {
for (int y = 0; y < szy; y++) for (int y = 0; y < szy; y++)
@ -2016,19 +2018,14 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
int py = int(ty/q->scale.y) + y; int py = int(ty/q->scale.y) + y;
if (px < w && py < h) if (px < w && py < h)
{ {
if (c==3) int p = (py*w*4) + px*4;
num++; if (data[p+3] >= 254)
{
num ++;
}
else else
{ {
int p = (py*w*c) + px*c; break;
if (data[p+3] >= 254)
{
num ++;
}
else
{
break;
}
} }
} }
} }
@ -2044,18 +2041,21 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
} }
} }
if (data)
{
free(data);
data = 0;
}
if (trim) if (trim)
{ {
obsCopy = obs; std::vector<TileVector> obsCopy = obs;
obs.clear(); obs.clear();
int sides = 0; int sides = 0;
bool added;
for (int i = 0; i < obsCopy.size(); i++) for (int i = 0; i < obsCopy.size(); i++)
{ {
sides = 0; sides = 0;
added = false;
for (int j = 0; j < obsCopy.size(); j++) for (int j = 0; j < obsCopy.size(); j++)
{ {
if (i != j) if (i != j)
@ -2072,42 +2072,18 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
if (sides>=4) if (sides>=4)
{ {
obs.push_back(obsCopy[i]); obs.push_back(obsCopy[i]);
added = true;
//debugLog("added");
break; break;
} }
} }
} }
/*
if (!added)
{
debugLog("not added");
}
*/
} }
} }
glBindTexture(GL_TEXTURE_2D, 0);
if (data) glPushMatrix();
free(data);
int rot = q->rotation.z;
while (rot > 360)
rot -= 360;
while (rot < 0)
rot += 360;
//rot = int(float(rot-45)/90.0f);
//int obsType = OT_INVISIBLEIN;
for (int i = 0; i < obs.size(); i++) for (int i = 0; i < obs.size(); i++)
{ {
/*
Vector p = q->getWorldCollidePosition(Vector(obs[i].x-w2, obs[i].y-h2));
TileVector tvec(tpos.x+w2+p.x, tpos.y+h2+p.y);
if (dsq->game->getGrid(tvec) == OT_EMPTY)
dsq->game->setGrid(tvec, obsType);
*/
glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glRotatef(q->rotation.z, 0, 0, 1); glRotatef(q->rotation.z, 0, 0, 1);
@ -2129,37 +2105,9 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
if (dsq->game->getGrid(tvec) == OT_EMPTY) if (dsq->game->getGrid(tvec) == OT_EMPTY)
dsq->game->setGrid(tvec, obsType); dsq->game->setGrid(tvec, obsType);
glPopMatrix();
/*
// clockwise
if ((rot >= 0 && rot < 45) || rot >= 315)
{
// normal
dsq->game->setGrid(TileVector(tpos.x+obs[i].x, tpos.y+obs[i].y), obsType);
}
else if (rot >= 45 && rot < 135)
{
TileVector tpos(q->position);
tpos.x -= h2;
tpos.y -= w2;
dsq->game->setGrid(TileVector(tpos.x+(th-obs[i].y), tpos.y+obs[i].x), obsType);
}
else if (rot >= 135 && rot < 225)
{
// flip y
dsq->game->setGrid(TileVector(tpos.x+(tw-obs[i].x), tpos.y+(th-obs[i].y)), obsType);
}
else if (rot >= 225 && rot < 315)
{
TileVector tpos(q->position);
tpos.x -= h2;
tpos.y -= w2;
dsq->game->setGrid(TileVector(tpos.x+obs[i].y, tpos.y+(tw-obs[i].x)), obsType);
}
*/
} }
} glPopMatrix();
}
#endif #endif
} }
@ -5496,6 +5444,9 @@ bool Game::loadScene(std::string scene)
void Game::saveScene(std::string scene) void Game::saveScene(std::string scene)
{ {
if (!this->saveFile)
return;
std::string fn = getSceneFilename(scene); std::string fn = getSceneFilename(scene);
TiXmlDocument saveFile(*this->saveFile); TiXmlDocument saveFile(*this->saveFile);

View file

@ -103,7 +103,7 @@ protected:
data->fp = fopen(data->tempFilename.c_str(), "wb"); data->fp = fopen(data->tempFilename.c_str(), "wb");
if(!data->fp) if(!data->fp)
{ {
fprintf(stderr, "SOCKET: Failed to save %u bytes, file not open"); fprintf(stderr, "SOCKET: Failed to save %u bytes, file not open", size);
data->fail = true; data->fail = true;
// TODO: and now? // TODO: and now?
return; return;

View file

@ -40,16 +40,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif #endif
#ifdef BBGE_BUILD_MACOSX #ifdef BBGE_BUILD_MACOSX
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <CoreFoundation/CFLocale.h> #include <CoreFoundation/CFLocale.h>
#include <CoreFoundation/CFString.h> #include <CoreFoundation/CFString.h>
// veeery clunky. // veeery clunky.
static std::string _CFToStdString(CFStringRef cs) static std::string _CFToStdString(CFStringRef cs)
{ {
char buf[1024]; char buf[1024];
CFStringGetCString(cs, &buf[0], 2048, kCFStringEncodingUTF8); CFStringGetCString(cs, &buf[0], 2048, kCFStringEncodingUTF8);
return &buf[0]; return &buf[0];
} }
#endif #endif
@ -658,7 +658,6 @@ void UserSettings::getSystemLocale()
} }
#elif BBGE_BUILD_MACOSX #elif BBGE_BUILD_MACOSX
CFLocaleRef locale = CFLocaleCopyCurrent(); CFLocaleRef locale = CFLocaleCopyCurrent();
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
CFStringRef buf; CFStringRef buf;
if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleLanguageCode)) != NULL) if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleLanguageCode)) != NULL)
@ -666,7 +665,7 @@ void UserSettings::getSystemLocale()
system.locale = _CFToStdString(buf); system.locale = _CFToStdString(buf);
CFRelease(buf); CFRelease(buf);
if ((buf = (CFStringRef)CFArrayGetValueAtIndex(langs, 0)) != NULL) if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleCountryCode)) != NULL)
{ {
system.locale += "_"; system.locale += "_";
system.locale += _CFToStdString(buf); system.locale += _CFToStdString(buf);
@ -675,7 +674,7 @@ void UserSettings::getSystemLocale()
} }
CFRelease(locale); CFRelease(locale);
CFRelease(langs);
#else #else
const char *lang = (const char *)getenv("LANG"); const char *lang = (const char *)getenv("LANG");