|
|
|
@ -28,6 +28,21 @@ using df::viewscreen_dwarfmodest;
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
using std::vector;
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("rendermax");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
|
{
|
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
@ -93,34 +105,34 @@ void removeOld()
|
|
|
|
|
engine=0;
|
|
|
|
|
}
|
|
|
|
|
if(current_mode!=MODE_DEFAULT)
|
|
|
|
|
delete df::global::enabler->renderer;
|
|
|
|
|
delete enabler->renderer;
|
|
|
|
|
|
|
|
|
|
current_mode=MODE_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
void installNew(df::renderer* r,RENDERER_MODE newMode)
|
|
|
|
|
{
|
|
|
|
|
df::global::enabler->renderer=r;
|
|
|
|
|
enabler->renderer=r;
|
|
|
|
|
current_mode=newMode;
|
|
|
|
|
}
|
|
|
|
|
static void lockGrids()
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
return ;
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
|
r->dataMutex.lock();
|
|
|
|
|
}
|
|
|
|
|
static void unlockGrids()
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
return ;
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
|
r->dataMutex.unlock();
|
|
|
|
|
}
|
|
|
|
|
static void resetGrids()
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
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++)
|
|
|
|
|
{
|
|
|
|
|
r->foreMult[i]=rgbf(1,1,1);
|
|
|
|
@ -133,16 +145,16 @@ static int getGridsSize(lua_State* L)
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
return -1;
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
|
|
|
|
|
lua_pushnumber(L,df::global::gps->dimx);
|
|
|
|
|
lua_pushnumber(L,df::global::gps->dimy);
|
|
|
|
|
renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
|
|
|
|
|
lua_pushnumber(L,gps->dimx);
|
|
|
|
|
lua_pushnumber(L,gps->dimy);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
static int getCell(lua_State* L)
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
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 y=luaL_checknumber(L,2);
|
|
|
|
|
int id=r->xyToTile(x,y);
|
|
|
|
@ -193,7 +205,7 @@ static int setCell(lua_State* L)
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
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 y=luaL_checknumber(L,2);
|
|
|
|
|
|
|
|
|
@ -242,7 +254,7 @@ static int invalidate(lua_State* L)
|
|
|
|
|
{
|
|
|
|
|
if(current_mode!=MODE_LUA)
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
r->invalidate();
|
|
|
|
@ -324,7 +336,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
{
|
|
|
|
|
if(parameters.size()==0)
|
|
|
|
|
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");
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
@ -333,7 +345,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
if(cmd=="trippy")
|
|
|
|
|
{
|
|
|
|
|
removeOld();
|
|
|
|
|
installNew(new renderer_trippy(df::global::enabler->renderer),MODE_TRIPPY);
|
|
|
|
|
installNew(new renderer_trippy(enabler->renderer),MODE_TRIPPY);
|
|
|
|
|
return CR_OK;
|
|
|
|
|
}
|
|
|
|
|
else if(cmd=="truecolor")
|
|
|
|
@ -341,7 +353,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
if(current_mode!=MODE_TRUECOLOR)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
@ -356,10 +368,10 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
else if(col=="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);
|
|
|
|
|
int h=df::global::gps->dimy;
|
|
|
|
|
int w=df::global::gps->dimx;
|
|
|
|
|
int h=gps->dimy;
|
|
|
|
|
int w=gps->dimx;
|
|
|
|
|
int cx=w/2;
|
|
|
|
|
int cy=h/2;
|
|
|
|
|
int rad=cx;
|
|
|
|
@ -385,7 +397,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
else if(cmd=="lua")
|
|
|
|
|
{
|
|
|
|
|
removeOld();
|
|
|
|
|
installNew(new renderer_lua(df::global::enabler->renderer),MODE_LUA);
|
|
|
|
|
installNew(new renderer_lua(enabler->renderer),MODE_LUA);
|
|
|
|
|
lockGrids();
|
|
|
|
|
resetGrids();
|
|
|
|
|
unlockGrids();
|
|
|
|
@ -396,7 +408,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
if(current_mode!=MODE_LIGHT)
|
|
|
|
|
{
|
|
|
|
|
removeOld();
|
|
|
|
|
renderer_light *myRender=new renderer_light(df::global::enabler->renderer);
|
|
|
|
|
renderer_light *myRender=new renderer_light(enabler->renderer);
|
|
|
|
|
installNew(myRender,MODE_LIGHT);
|
|
|
|
|
engine=new lightingEngineViewscreen(myRender);
|
|
|
|
|
|
|
|
|
@ -444,7 +456,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
|
|
|
|
|
else
|
|
|
|
|
removeOld();
|
|
|
|
|
CoreSuspender guard;
|
|
|
|
|
df::global::gps->force_full_display_count++;
|
|
|
|
|
gps->force_full_display_count++;
|
|
|
|
|
return CR_OK;
|
|
|
|
|
}
|
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|