|
|
@ -28,6 +28,21 @@ using df::viewscreen_dwarfmodest;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using std::vector;
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("rendermax");
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(cur_year_tick);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(cursor);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(enabler);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(gametype);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(gps);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(ui);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(ui_area_map_width);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(ui_menu_width);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(window_x);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(window_y);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(window_z);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
|
|
|
|
|
|
|
|
enum RENDERER_MODE
|
|
|
|
enum RENDERER_MODE
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MODE_DEFAULT,MODE_TRIPPY,MODE_TRUECOLOR,MODE_LUA,MODE_LIGHT
|
|
|
|
MODE_DEFAULT,MODE_TRIPPY,MODE_TRUECOLOR,MODE_LUA,MODE_LIGHT
|
|
|
@ -37,9 +52,6 @@ lightingEngine *engine=NULL;
|
|
|
|
|
|
|
|
|
|
|
|
static command_result rendermax(color_ostream &out, vector <string> & parameters);
|
|
|
|
static command_result rendermax(color_ostream &out, vector <string> & parameters);
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("rendermax");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
@ -93,34 +105,34 @@ void removeOld()
|
|
|
|
engine=0;
|
|
|
|
engine=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(current_mode!=MODE_DEFAULT)
|
|
|
|
if(current_mode!=MODE_DEFAULT)
|
|
|
|
delete df::global::enabler->renderer;
|
|
|
|
delete enabler->renderer;
|
|
|
|
|
|
|
|
|
|
|
|
current_mode=MODE_DEFAULT;
|
|
|
|
current_mode=MODE_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void installNew(df::renderer* r,RENDERER_MODE newMode)
|
|
|
|
void installNew(df::renderer* r,RENDERER_MODE newMode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::global::enabler->renderer=r;
|
|
|
|
enabler->renderer=r;
|
|
|
|
current_mode=newMode;
|
|
|
|
current_mode=newMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void lockGrids()
|
|
|
|
static void lockGrids()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
r->dataMutex.lock();
|
|
|
|
r->dataMutex.lock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void unlockGrids()
|
|
|
|
static void unlockGrids()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
r->dataMutex.unlock();
|
|
|
|
r->dataMutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void resetGrids()
|
|
|
|
static void resetGrids()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
for(size_t i=0;i<r->foreMult.size();i++)
|
|
|
|
for(size_t i=0;i<r->foreMult.size();i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
r->foreMult[i]=rgbf(1,1,1);
|
|
|
|
r->foreMult[i]=rgbf(1,1,1);
|
|
|
@ -133,16 +145,16 @@ static int getGridsSize(lua_State* L)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
lua_pushnumber(L,df::global::gps->dimx);
|
|
|
|
lua_pushnumber(L,gps->dimx);
|
|
|
|
lua_pushnumber(L,df::global::gps->dimy);
|
|
|
|
lua_pushnumber(L,gps->dimy);
|
|
|
|
return 2;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static int getCell(lua_State* L)
|
|
|
|
static int getCell(lua_State* L)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
int x=luaL_checknumber(L,1);
|
|
|
|
int x=luaL_checknumber(L,1);
|
|
|
|
int y=luaL_checknumber(L,2);
|
|
|
|
int y=luaL_checknumber(L,2);
|
|
|
|
int id=r->xyToTile(x,y);
|
|
|
|
int id=r->xyToTile(x,y);
|
|
|
@ -193,7 +205,7 @@ static int setCell(lua_State* L)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
int x=luaL_checknumber(L,1);
|
|
|
|
int x=luaL_checknumber(L,1);
|
|
|
|
int y=luaL_checknumber(L,2);
|
|
|
|
int y=luaL_checknumber(L,2);
|
|
|
|
|
|
|
|
|
|
|
@ -242,7 +254,7 @@ static int invalidate(lua_State* L)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
if(lua_gettop(L)==0)
|
|
|
|
if(lua_gettop(L)==0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
r->invalidate();
|
|
|
|
r->invalidate();
|
|
|
@ -324,7 +336,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(parameters.size()==0)
|
|
|
|
if(parameters.size()==0)
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
if(!df::global::enabler->renderer->uses_opengl())
|
|
|
|
if(!enabler->renderer->uses_opengl())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("Sorry, this plugin needs open gl enabled printmode. Try STANDARD or other non-2D\n");
|
|
|
|
out.printerr("Sorry, this plugin needs open gl enabled printmode. Try STANDARD or other non-2D\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
return CR_FAILURE;
|
|
|
@ -333,7 +345,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
if(cmd=="trippy")
|
|
|
|
if(cmd=="trippy")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
removeOld();
|
|
|
|
removeOld();
|
|
|
|
installNew(new renderer_trippy(df::global::enabler->renderer),MODE_TRIPPY);
|
|
|
|
installNew(new renderer_trippy(enabler->renderer),MODE_TRIPPY);
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd=="truecolor")
|
|
|
|
else if(cmd=="truecolor")
|
|
|
@ -341,7 +353,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
if(current_mode!=MODE_TRUECOLOR)
|
|
|
|
if(current_mode!=MODE_TRUECOLOR)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
removeOld();
|
|
|
|
removeOld();
|
|
|
|
installNew(new renderer_test(df::global::enabler->renderer),MODE_TRUECOLOR);
|
|
|
|
installNew(new renderer_test(enabler->renderer),MODE_TRUECOLOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(current_mode==MODE_TRUECOLOR && parameters.size()==2)
|
|
|
|
if(current_mode==MODE_TRUECOLOR && parameters.size()==2)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -356,10 +368,10 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
else if(col=="blue")
|
|
|
|
else if(col=="blue")
|
|
|
|
cur=blue;
|
|
|
|
cur=blue;
|
|
|
|
|
|
|
|
|
|
|
|
renderer_test* r=reinterpret_cast<renderer_test*>(df::global::enabler->renderer);
|
|
|
|
renderer_test* r=reinterpret_cast<renderer_test*>(enabler->renderer);
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(r->dataMutex);
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(r->dataMutex);
|
|
|
|
int h=df::global::gps->dimy;
|
|
|
|
int h=gps->dimy;
|
|
|
|
int w=df::global::gps->dimx;
|
|
|
|
int w=gps->dimx;
|
|
|
|
int cx=w/2;
|
|
|
|
int cx=w/2;
|
|
|
|
int cy=h/2;
|
|
|
|
int cy=h/2;
|
|
|
|
int rad=cx;
|
|
|
|
int rad=cx;
|
|
|
@ -385,7 +397,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
else if(cmd=="lua")
|
|
|
|
else if(cmd=="lua")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
removeOld();
|
|
|
|
removeOld();
|
|
|
|
installNew(new renderer_lua(df::global::enabler->renderer),MODE_LUA);
|
|
|
|
installNew(new renderer_lua(enabler->renderer),MODE_LUA);
|
|
|
|
lockGrids();
|
|
|
|
lockGrids();
|
|
|
|
resetGrids();
|
|
|
|
resetGrids();
|
|
|
|
unlockGrids();
|
|
|
|
unlockGrids();
|
|
|
@ -396,7 +408,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
if(current_mode!=MODE_LIGHT)
|
|
|
|
if(current_mode!=MODE_LIGHT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
removeOld();
|
|
|
|
removeOld();
|
|
|
|
renderer_light *myRender=new renderer_light(df::global::enabler->renderer);
|
|
|
|
renderer_light *myRender=new renderer_light(enabler->renderer);
|
|
|
|
installNew(myRender,MODE_LIGHT);
|
|
|
|
installNew(myRender,MODE_LIGHT);
|
|
|
|
engine=new lightingEngineViewscreen(myRender);
|
|
|
|
engine=new lightingEngineViewscreen(myRender);
|
|
|
|
|
|
|
|
|
|
|
@ -444,7 +456,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
else
|
|
|
|
else
|
|
|
|
removeOld();
|
|
|
|
removeOld();
|
|
|
|
CoreSuspender guard;
|
|
|
|
CoreSuspender guard;
|
|
|
|
df::global::gps->force_full_display_count++;
|
|
|
|
gps->force_full_display_count++;
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|