Add ren.showBrush to the LUA api to allow hiding the brush

This commit is contained in:
Doxin 2021-03-18 20:44:59 +01:00 committed by jacob1
parent b1506e15d4
commit cc2022504a
6 changed files with 42 additions and 1 deletions

View File

@ -1044,6 +1044,16 @@ bool GameController::GetHudEnable()
return gameView->GetHudEnable(); return gameView->GetHudEnable();
} }
void GameController::SetBrushEnable(bool brushState)
{
gameView->SetBrushEnable(brushState);
}
bool GameController::GetBrushEnable()
{
return gameView->GetBrushEnable();
}
void GameController::SetDebugHUD(bool hudState) void GameController::SetDebugHUD(bool hudState)
{ {
gameView->SetDebugHUD(hudState); gameView->SetDebugHUD(hudState);

View File

@ -104,6 +104,8 @@ public:
void ShowGravityGrid(); void ShowGravityGrid();
void SetHudEnable(bool hudState); void SetHudEnable(bool hudState);
bool GetHudEnable(); bool GetHudEnable();
void SetBrushEnable(bool brushState);
bool GetBrushEnable();
void SetDebugHUD(bool hudState); void SetDebugHUD(bool hudState);
bool GetDebugHUD(); bool GetDebugHUD();
void SetDebugFlags(unsigned int flags) { debugFlags = flags; } void SetDebugFlags(unsigned int flags) { debugFlags = flags; }

View File

@ -172,6 +172,7 @@ GameView::GameView():
ctrlBehaviour(false), ctrlBehaviour(false),
altBehaviour(false), altBehaviour(false),
showHud(true), showHud(true),
showBrush(true),
showDebug(false), showDebug(false),
delayedActiveMenu(-1), delayedActiveMenu(-1),
wallBrush(false), wallBrush(false),
@ -460,6 +461,16 @@ bool GameView::GetHudEnable()
return showHud; return showHud;
} }
void GameView::SetBrushEnable(bool brushState)
{
showBrush = brushState;
}
bool GameView::GetBrushEnable()
{
return showBrush;
}
void GameView::SetDebugHUD(bool mode) void GameView::SetDebugHUD(bool mode)
{ {
showDebug = mode; showDebug = mode;
@ -1940,7 +1951,7 @@ void GameView::OnDraw()
ren->clearScreen(1.0f); ren->clearScreen(1.0f);
ren->RenderBegin(); ren->RenderBegin();
ren->SetSample(c->PointTranslate(currentMouse).X, c->PointTranslate(currentMouse).Y); ren->SetSample(c->PointTranslate(currentMouse).X, c->PointTranslate(currentMouse).Y);
if (selectMode == SelectNone && (!zoomEnabled || zoomCursorFixed) && activeBrush && (isMouseDown || (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES))) if (showBrush && selectMode == SelectNone && (!zoomEnabled || zoomCursorFixed) && activeBrush && (isMouseDown || (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES)))
{ {
ui::Point finalCurrentMouse = c->PointTranslate(currentMouse); ui::Point finalCurrentMouse = c->PointTranslate(currentMouse);
ui::Point initialDrawPoint = drawPoint1; ui::Point initialDrawPoint = drawPoint1;

View File

@ -46,6 +46,7 @@ private:
bool ctrlBehaviour; bool ctrlBehaviour;
bool altBehaviour; bool altBehaviour;
bool showHud; bool showHud;
bool showBrush;
bool showDebug; bool showDebug;
int delayedActiveMenu; int delayedActiveMenu;
bool wallBrush; bool wallBrush;
@ -142,6 +143,8 @@ public:
void SetSample(SimulationSample sample); void SetSample(SimulationSample sample);
void SetHudEnable(bool hudState); void SetHudEnable(bool hudState);
bool GetHudEnable(); bool GetHudEnable();
void SetBrushEnable(bool hudState);
bool GetBrushEnable();
void SetDebugHUD(bool mode); void SetDebugHUD(bool mode);
bool GetDebugHUD(); bool GetDebugHUD();
bool GetPlacingSave(); bool GetPlacingSave();

View File

@ -2177,6 +2177,7 @@ void LuaScriptInterface::initRendererAPI()
{"decorations", renderer_decorations}, //renderer_debugHUD {"decorations", renderer_decorations}, //renderer_debugHUD
{"grid", renderer_grid}, {"grid", renderer_grid},
{"debugHUD", renderer_debugHUD}, {"debugHUD", renderer_debugHUD},
{"showBrush", renderer_showBrush},
{"depth3d", renderer_depth3d}, {"depth3d", renderer_depth3d},
{"zoomEnabled", renderer_zoomEnabled}, {"zoomEnabled", renderer_zoomEnabled},
{"zoomWindow", renderer_zoomWindowInfo}, {"zoomWindow", renderer_zoomWindowInfo},
@ -2362,6 +2363,19 @@ int LuaScriptInterface::renderer_debugHUD(lua_State * l)
return 0; return 0;
} }
int LuaScriptInterface::renderer_showBrush(lua_State * l)
{
int acount = lua_gettop(l);
if (acount == 0)
{
lua_pushnumber(l, luacon_controller->GetBrushEnable());
return 1;
}
int brush = luaL_optint(l, 1, -1);
luacon_controller->SetBrushEnable(brush);
return 0;
}
int LuaScriptInterface::renderer_depth3d(lua_State * l) int LuaScriptInterface::renderer_depth3d(lua_State * l)
{ {
return luaL_error(l, "This feature is no longer supported"); return luaL_error(l, "This feature is no longer supported");

View File

@ -119,6 +119,7 @@ class LuaScriptInterface: public CommandInterface
static int renderer_decorations(lua_State * l); static int renderer_decorations(lua_State * l);
static int renderer_grid(lua_State * l); static int renderer_grid(lua_State * l);
static int renderer_debugHUD(lua_State * l); static int renderer_debugHUD(lua_State * l);
static int renderer_showBrush(lua_State * l);
static int renderer_depth3d(lua_State * l); static int renderer_depth3d(lua_State * l);
static int renderer_zoomEnabled(lua_State *l); static int renderer_zoomEnabled(lua_State *l);
static int renderer_zoomWindowInfo(lua_State *l); static int renderer_zoomWindowInfo(lua_State *l);