Permalink
Browse files

New graphics api function: getColors, returns r, b, g, and a from a h…

…ex color

Also, remove generated/ and build/generated when using scons -c
  • Loading branch information...
1 parent ec29044 commit 89ffa60529ea16563d3ac830ff038c8fad132afe @jacob1 jacob1 committed Jun 9, 2014
Showing with 31 additions and 1 deletion.
  1. +6 −0 SConscript
  2. +7 −1 SConstruct
  3. +17 −0 src/lua/LuaScriptInterface.cpp
  4. +1 −0 src/lua/LuaScriptInterface.h
View
@@ -337,6 +337,12 @@ if not GetOption('clean'):
conf.CheckBit()
findLibs(env, conf)
env = conf.Finish()
+else:
+ import os, shutil
+ try:
+ shutil.rmtree("generated/")
+ except:
+ print "couldn't remove build/generated/"
if not msvc:
if platform == "Windows":
View
@@ -9,7 +9,13 @@ if GetOption('clean'):
try:
shutil.rmtree(".sconf_temp/")
except:
- print "couldn't remove .sconf_temp"
+ print "couldn't remove .sconf_temp/"
+
+ try:
+ shutil.rmtree("generated/")
+ except:
+ print "couldn't remove generated/"
+
try:
os.remove(".sconsign.dblite")
except:
@@ -2394,6 +2394,7 @@ void LuaScriptInterface::initGraphicsAPI()
{"fillRect", graphics_fillRect},
{"drawCircle", graphics_drawCircle},
{"fillCircle", graphics_fillCircle},
+ {"getColors", graphics_getColors},
{NULL, NULL}
};
luaL_register(l, "graphics", graphicsAPIMethods);
@@ -2560,6 +2561,22 @@ int LuaScriptInterface::graphics_fillCircle(lua_State * l)
return 0;
}
+int LuaScriptInterface::graphics_getColors(lua_State * l)
+{
+ int color = lua_tointeger(l, 1);
+
+ int a = color >> 24;
+ int r = (color >> 16)&0xFF;
+ int g = (color >> 8)&0xFF;
+ int b = color&0xFF;
+
+ lua_pushinteger(l, r);
+ lua_pushinteger(l, g);
+ lua_pushinteger(l, b);
+ lua_pushinteger(l, a);
+ return 4;
+}
+
void LuaScriptInterface::initFileSystemAPI()
{
//Methods
@@ -131,6 +131,7 @@ class LuaScriptInterface: public CommandInterface
static int graphics_fillRect(lua_State * l);
static int graphics_drawCircle(lua_State * l);
static int graphics_fillCircle(lua_State * l);
+ static int graphics_getColors(lua_State * l);
void initFileSystemAPI();
static int fileSystem_list(lua_State * l);

0 comments on commit 89ffa60

Please sign in to comment.