Browse Source

Added some resources.

rude 16 years ago
parent
commit
45f69512ac

+ 1 - 0
extra/reshax/files

@@ -0,0 +1 @@
+res/belt_tooth.png res/belt_track.png res/bubble.png res/bush01.png res/bush02.png res/knoll01.png res/knoll02.png res/knoll03.png res/knoll04.png res/love.png res/star.png res/tree01.png res/turret_body.png res/turret_cannon.png res/Vera.ttf res/wheel_major.png res/wheel_minor.png res/wheel_revision.png

+ 0 - 0
extra/reshax/Vera.ttf → extra/reshax/res/Vera.ttf


BIN
extra/reshax/res/belt_tooth.png


BIN
extra/reshax/res/belt_track.png


BIN
extra/reshax/res/bubble.png


BIN
extra/reshax/res/bush01.png


BIN
extra/reshax/res/bush02.png


BIN
extra/reshax/res/knoll01.png


BIN
extra/reshax/res/knoll02.png


BIN
extra/reshax/res/knoll03.png


BIN
extra/reshax/res/knoll04.png


BIN
extra/reshax/res/love.png


BIN
extra/reshax/res/star.png


BIN
extra/reshax/res/tree01.png


BIN
extra/reshax/res/turret_body.png


BIN
extra/reshax/res/turret_cannon.png


BIN
extra/reshax/res/wheel_major.png


BIN
extra/reshax/res/wheel_minor.png


BIN
extra/reshax/res/wheel_revision.png


+ 28 - 7
extra/reshax/reshax.cpp

@@ -1,9 +1,12 @@
+#define _CRT_SECURE_NO_WARNINGS
+
 #include <fstream>
 #include <map>
 #include <sstream>
 #include <sys/stat.h>
 
 std::ofstream resources_cpp, resources_h;
+std::stringstream resources_array;
 
 void load(std::string file);
 void write(std::string file, int size, char *data);
@@ -44,19 +47,34 @@ int main(int argc, char *argv[])
 			<< "#ifndef LOVE_RESOURCES_H\n"
 			<< "#define LOVE_RESOURCES_H\n\n"
 			<< "namespace love\n"
-			<< "{\n";
+			<< "{\n"
+			<< "\tstruct Resource\n"
+			<< "\t{\n"
+			<< "\t\tconst char * name;\n"
+			<< "\t\tvoid * data;\n"
+			<< "\t\tunsigned int size;\n"
+			<< "\t};\n"
+			<< "\n"
+			<< "\textern const Resource resources[];\n"
+			<< "\n";
 		resources_cpp.open("resources.cpp");
 		resources_cpp
 			<< love_header
 			<< "#include \"resources.h\"\n\n"
 			<< "namespace love\n"
 			<< "{\n";
+
+		resources_array << "\n\tconst Resource resources[] = {\n";
+
 		for (int i = 1; i < argc; i++)
 		{
 			// use boost::filesystem to list all the files (in v2 maybe)
 			load(argv[i]);
 		}
-		resources_cpp << "};\n";
+
+		resources_array << "\t\t{0,0,0}\n\t};\n\n";
+
+		resources_cpp << resources_array.str();
 		resources_cpp << "} // love\n";
 		resources_cpp.close();
 		resources_h
@@ -119,6 +137,11 @@ void write(string file, int size, char *data)
 	}
 	//#endif
 
+	// Lowercase plz.
+    for (unsigned int i=0;i<strlen(var.c_str());i++) 
+        if (var[i] >= 0x41 && var[i] <= 0x5A) 
+            var[i] = var[i] + 0x20;
+
 	resources_cpp << "\tconst char " << var << "_data[] = {";
 	for (int i = 0; i < size - 1; i++)
 	{
@@ -127,10 +150,8 @@ void write(string file, int size, char *data)
 		if (i != 0 && i % 30 == 0)
 			resources_cpp << "\n\t";
 	}
-	sprintf(buffer, "%d};\n", data[size]);
-
-	resources_h << "\t// " << var << "\n";
-	resources_h << "\tconst int " << var << "_size = " << size << ";\n";
-	resources_h << "\textern const char " << var << "_data[];\n\n";
+	sprintf(buffer, "%d};\n\n", data[size]);
+	resources_cpp << buffer;
+	resources_array << "\t\t{\"_" << var << "\", (void*)" << var << "_data, " << size << "},\n";
 	printf(" is haxed\n");
 }

+ 5 - 2
src/love.cpp

@@ -71,8 +71,11 @@ DECLSPEC int luaopen_love(lua_State * L)
 	love::luax_insistglobal(L, "love");
 
 	// Resources.
-	love::luax_newtype(L, "Data", love::DATA_T, new love::MemoryData((void*)love::Vera_ttf_data, love::Vera_ttf_size));
-	lua_setfield(L, -2, "_vera");
+	for(const love::Resource * r = love::resources; r->name != 0; r++)
+	{
+		love::luax_newtype(L, "Data", love::DATA_T, new love::MemoryData((void*)r->data, r->size));
+		lua_setfield(L, -2, r->name);
+	}
 
 	lua_pop(L, 1); // love
 

+ 1 - 0
src/modules/filesystem/physfs/Filesystem.cpp

@@ -183,6 +183,7 @@ namespace physfs
 #endif
 	}
 
+
 	const char * Filesystem::getSaveDirectory()
 	{
 		return save_path_full.c_str();

File diff suppressed because it is too large
+ 1648 - 1
src/resources/resources.cpp


+ 8 - 3
src/resources/resources.h

@@ -23,9 +23,14 @@
 
 namespace love
 {
-	// Vera_ttf
-	const int Vera_ttf_size = 65932;
-	extern const char Vera_ttf_data[];
+	struct Resource
+	{
+		const char * name;
+		void * data;
+		unsigned int size;
+	};
+
+	extern const Resource resources[];
 
 }
 

Some files were not shown because too many files changed in this diff