Commits

Anonymous committed 491715e Merge

Merging upstream changes

Comments (0)

Files changed (11)

   * Added shape:getBody.
   * Added love.filesystem.FileData for public usage.
   * Added base64 support for love.filesystem.FileData.
-  * Added table support for love.graphics.setColor.
+  * Added table support for love.graphics.setColor and love.graphics.setBackgroundColor.
+  * Added love.graphics.hasFocus().
+  * Added ?/init.lua to the loader.
 
   * Fixed the debug module not being an upvalue of the error handlers. (you can now override debug)
   * Fixed some cases when love.audio.pause and friends, were acting on everything, not just the passed Source.
   * Changed fonts, they're now po2 safe.
   * Changed the traceback in the error screen.
   * Changed font origin to top-left.
-  * Changed behavior of love.physics.newWorld(w, h), it now creates a w*h world, not a 4*w*h world.
   * Changed linux save dir location to obey to Freedesktop.org's XDG specs. (~/.local/share/love by default.)
 
   * Removed font functions from love.graphics.
+  * Removed love.physics.newWorld(w, h). Use love.physics.newWorld(x1, y1, x2, y2) instead.
 
 LOVE 0.6.2 [Jiggly Juice]
 -------------------------

platform/msvc2008/love.vcproj

 						>
 					</File>
 					<File
+						RelativePath="..\..\src\modules\graphics\opengl\Framebuffer.cpp"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+								ObjectFile="$(IntDir)\graphics\opengl\"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\graphics\opengl\Framebuffer.h"
+						>
+					</File>
+					<File
 						RelativePath="..\..\src\modules\graphics\opengl\GLee.c"
 						>
 						<FileConfiguration
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\ImageFont.cpp"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\modules\graphics\opengl\ImageFont.h"
-						>
-					</File>
-					<File
 						RelativePath="..\..\src\modules\graphics\opengl\ParticleSystem.cpp"
 						>
 						<FileConfiguration
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.cpp"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.h"
-						>
-					</File>
-					<File
 						RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.cpp"
 						>
 						<FileConfiguration
 						>
 					</File>
 					<File
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Framebuffer.cpp"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+								ObjectFile="$(IntDir)\graphics\opengl\"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Framebuffer.h"
+						>
+					</File>
+					<File
 						RelativePath="..\..\src\modules\graphics\opengl\wrap_Glyph.cpp"
 						>
 						<FileConfiguration
 					</File>
 				</Filter>
 			</Filter>
+			<Filter
+				Name="font"
+				>
+				<File
+					RelativePath="..\..\src\modules\font\Font.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\FontData.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\FontData.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\GlyphData.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\GlyphData.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\ImageRasterizer.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\ImageRasterizer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\Rasterizer.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\Rasterizer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_FontData.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_FontData.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_GlyphData.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_GlyphData.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_Rasterizer.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\font\"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\modules\font\wrap_Rasterizer.h"
+					>
+				</File>
+				<Filter
+					Name="freetype"
+					>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\Font.cpp"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+								ObjectFile="$(IntDir)\font\freetype\"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\Font.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\TrueTypeRasterizer.cpp"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+								ObjectFile="$(IntDir)\font\freetype\"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\TrueTypeRasterizer.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\wrap_Font.cpp"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+								ObjectFile="$(IntDir)\font\freetype\"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\font\freetype\wrap_Font.h"
+						>
+					</File>
+				</Filter>
+			</Filter>
 		</Filter>
 		<Filter
 			Name="common"
 			>
 			<File
+				RelativePath="..\..\src\common\b64.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\common\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\src\common\config.h"
 				>
 			</File>
 			Name="scripts"
 			>
 		</Filter>
-		<Filter
-			Name="resources"
-			>
-			<File
-				RelativePath="..\..\src\resources\resources.cpp"
-				>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						ObjectFile="$(IntDir)\resources\"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						ObjectFile="$(IntDir)\resources\"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\resources\resources.h"
-				>
-			</File>
-		</Filter>
 		<File
 			RelativePath=".\icon.rc"
 			>

src/modules/filesystem/physfs/wrap_Filesystem.cpp

 		}
 
 		// Check whether file exists.
-		if(!instance->exists(tmp.c_str()))
+		if(instance->exists(tmp.c_str()))
 		{
-			lua_pushfstring(L, "\n\tno file \"%s\" in LOVE game directories.\n", tmp.c_str());
-			return 1;
+			lua_pop(L, 1);
+			lua_pushstring(L, tmp.c_str());
+			// Ok, load it.
+			return instance->load(L);
 		}
 
-		lua_pop(L, 1);
-		lua_pushstring(L, tmp.c_str());
+		tmp = filename;
+		size = tmp.size();
+		for(int i=0;i<size;i++)
+		{
+			if(tmp[i] == '.')
+			{
+				tmp[i] = '/';
+			}
+		}
 
-		// Ok, load it.
-		return instance->load(L);
+		if (instance->isDirectory(tmp.c_str()))
+		{
+			tmp += "/init.lua";
+			if (instance->exists(tmp.c_str())) {
+				lua_pop(L, 1);
+				lua_pushstring(L, tmp.c_str());
+				// Ok, load it.
+				return instance->load(L);
+			}
+		}
+
+		lua_pushfstring(L, "\n\tno file \"%s\" in LOVE game directories.\n", tmp.c_str());
+		return 1;
 	}
 
 	// List of functions to wrap.

src/modules/graphics/opengl/Font.cpp

 		for (unsigned int i = 0; i < text.size(); i++) {
 			unsigned char g = (unsigned char)text[i];
 			if (g == '\n') { // wrap newline, but do not print it
-				glTranslatef(-dx, round(getHeight()), 0);
+				glTranslatef(-dx, floor(getHeight() + 0.5f), 0);
 				dx = 0.0f;
 				continue;
 			}
 			if (!glyphs[g]) g = 32; // space
 			glPushMatrix();
-			if (type == FONT_TRUETYPE) glTranslatef(0, round(getHeight()), 0);
+			if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() + 0.5f), 0);
 			glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0);
 			glPopMatrix();
 			glTranslatef(spacing[g], 0, 0);
 	{
 		if (!glyphs[character]) character = ' ';
 		glPushMatrix();
-		glTranslatef(x, round(y+getHeight()), 0.0f);
+		glTranslatef(x, floor(y+getHeight() + 0.5f), 0.0f);
 		glCallList(list+character);
 		glPopMatrix();
 	}

src/modules/graphics/opengl/Graphics.cpp

 		glDisableClientState(GL_VERTEX_ARRAY);
 	}
 
+	bool Graphics::hasFocus()
+	{
+		return SDL_GetAppState() & SDL_APPINPUTFOCUS;
+	}
 } // opengl
 } // graphics
 } // love

src/modules/graphics/opengl/Graphics.h

 
 		void drawTest(Image * image, float x, float y, float a, float sx, float sy, float ox, float oy);
 
+		bool hasFocus();
+
 	}; // Graphics
 
 } // opengl

src/modules/graphics/opengl/wrap_Graphics.cpp

 		// Convert to Data, if necessary.
 		if(luax_istype(L, 1, FILESYSTEM_FILE_T)) {
 			love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
-			Data * d = f->read();
+			Data * d;
+			try {
+				d = f->read();
+			}
+			catch (love::Exception & e) {
+				return luaL_error(L, e.what());
+			}
 			lua_remove(L, 1); // get rid of the file
 			luax_newtype(L, "Data", DATA_T, (void*)d);
 			lua_insert(L, 1); // put it at the bottom of the stack
 	int w_setBackgroundColor(lua_State * L)
 	{
 		Color c;
-		c.r = (unsigned char)luaL_checkint(L, 1);
-		c.g = (unsigned char)luaL_checkint(L, 2);
-		c.b = (unsigned char)luaL_checkint(L, 3);
+		if (lua_istable(L, 1)) {
+			lua_pushinteger(L, 1);
+			lua_gettable(L, -2);
+			c.r = (unsigned char)luaL_checkint(L, -1);
+			lua_pop(L, 1);
+			lua_pushinteger(L, 2);
+			lua_gettable(L, -2);
+			c.g = (unsigned char)luaL_checkint(L, -1);
+			lua_pop(L, 1);
+			lua_pushinteger(L, 3);
+			lua_gettable(L, -2);
+			c.b = (unsigned char)luaL_checkint(L, -1);
+			lua_pop(L, 1);
+		}
+		else
+		{
+			c.r = (unsigned char)luaL_checkint(L, 1);
+			c.g = (unsigned char)luaL_checkint(L, 2);
+			c.b = (unsigned char)luaL_checkint(L, 3);
+		}
 		c.a = 255;
 		instance->setBackgroundColor(c);
 		return 0;
 		return 0;
 	}
 
+	int w_hasFocus(lua_State * L)
+	{
+		luax_pushboolean(L, instance->hasFocus());
+		return 1;
+	}
+
 
 	// List of functions to wrap.
 	static const luaL_Reg functions[] = {
 
 		{ "translate", w_translate },
 
+		{ "hasFocus", w_hasFocus },
+
 		{ 0, 0 }
 	};
 

src/modules/graphics/opengl/wrap_Graphics.h

 	int w_rotate(lua_State * L);
 	int w_scale(lua_State * L);
 	int w_translate(lua_State * L);
+	int w_hasFocus(lua_State * L);
 	extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L);
 
 } // opengl

src/modules/physics/box2d/Physics.cpp

 		aabb.lowerBound.Set(lx, ly);
 		aabb.upperBound.Set(ux, uy);
 		return new World(aabb, b2Vec2(gx, gy), sleep, meter);
-	}
-
-	World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep)
-	{
-		b2AABB aabb;
-		aabb.lowerBound.Set(lx, ly);
-		aabb.upperBound.Set(ux, uy);
-		return new World(aabb, b2Vec2(gx, gy), sleep);
-	}
-
-	World * Physics::newWorld(float w, float h)
-	{
-		return newWorld(0, 0, w, h, 0, 0, true);
 	}
 
 	Body * Physics::newBody(World * world, float x, float y, float mass, float i)

src/modules/physics/box2d/Physics.h

 		World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter);
 
 		/**
-		* Creates a new World.
-		* @param lx Lower bound on the x-axis.
-		* @param ly Lower bound on the y-axis.
-		* @param ux Upper bound on the x-axis.
-		* @param uy Upper bound on the y-axis.
-		* @param gx Gravity along x-axis.
-		* @param gy Gravity along y-axis.
-		* @param sleep Whether the World allows sleep.
-		**/
-		World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep);
-
-		/**
-		* Creates a new World with with size (w,h).
-		* @param w The width of the world.
-		* @param h The height of the world.
-		**/
-		World * newWorld(float w, float h);
-
-		/**
 		* Creates a new Body at the specified position.
 		* @param world The world to create the Body in.
 		* @param x The position along the x-axis.

src/modules/physics/box2d/wrap_Physics.cpp

 
 	int w_newWorld(lua_State * L)
 	{
-		int top = lua_gettop(L);
-		if (top == 2)
-		{
-			float x = (float)luaL_checknumber(L, 1);
-			float y = (float)luaL_checknumber(L, 2);
-			World * w = instance->newWorld(x, y);
-			luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
-			return 1;
-		}
-		else if (top == 6 || top == 7)
-		{
-			float lx = (float)luaL_checknumber(L, 1);
-			float ly = (float)luaL_checknumber(L, 2);
-			float ux = (float)luaL_checknumber(L, 3);
-			float uy = (float)luaL_checknumber(L, 4);
-			float gx = (float)luaL_checknumber(L, 5);
-			float gy = (float)luaL_checknumber(L, 6);
-			bool sleep = luax_optboolean(L, 7, true);
-			World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep);
-			luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
-			return 1;
-		}
-		else if (top == 8)
-		{
-			float lx = (float)luaL_checknumber(L, 1);
-			float ly = (float)luaL_checknumber(L, 2);
-			float ux = (float)luaL_checknumber(L, 3);
-			float uy = (float)luaL_checknumber(L, 4);
-			float gx = (float)luaL_checknumber(L, 5);
-			float gy = (float)luaL_checknumber(L, 6);
-			bool sleep = lua_toboolean(L, 7);
-			int meter = (int)luaL_checknumber(L, 8);
-			World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter);
-			luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
-			return 1;
-		}
-		else
+		if (lua_gettop(L) < 4)
 			return luaL_error(L, "Incorrect number of parameters");
+
+		float lx = (float)luaL_checknumber(L, 1);
+		float ly = (float)luaL_checknumber(L, 2);
+		float ux = (float)luaL_checknumber(L, 3);
+		float uy = (float)luaL_checknumber(L, 4);
+		float gx = (float)luaL_optnumber(L, 5, 0);
+		float gy = (float)luaL_optnumber(L, 6, 0);
+		bool sleep = luax_optboolean(L, 7, true);
+		int meter = (int)luaL_optnumber(L, 8, World::DEFAULT_METER);
+
+		World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter);
+		luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
+
+		return 1;
 	}
 
 	int w_newBody(lua_State * L)