readd tpt.hud and tpt.set_console commands

This commit is contained in:
jacob1 2013-01-08 22:00:45 -05:00
parent 6dad17c2e1
commit 162a8ecba5
7 changed files with 38 additions and 12 deletions

View File

@ -12,7 +12,7 @@
#include "dialogues/ErrorMessage.h"
#include "dialogues/InformationMessage.h"
#include "dialogues/TextPrompt.h"
#include "dialogues/ConfirmPrompt.h"
#include "dialogues/ConfirmPrompt.h"
#include "simulation/Simulation.h"
#include "game/GameModel.h"
@ -803,11 +803,12 @@ int luatpt_togglewater(lua_State* l)
int luatpt_setconsole(lua_State* l)
{
/*int consolestate;
int consolestate;
consolestate = luaL_optint(l, 1, 0);
console_mode = (consolestate==0?0:1);
return 0;*/
//TODO IMPLEMENT
if (consolestate)
luacon_controller->ShowConsole();
else
luacon_controller->HideConsole();
return 0;
}
@ -1640,12 +1641,12 @@ int luatpt_getPartIndex(lua_State* l)
}
int luatpt_hud(lua_State* l)
{
/*int hudstate;
hudstate = luaL_optint(l, 1, 0);
hud_enable = (hudstate==0?0:1);
return 0;*/
//TODO IMPLEMENT
return 0;
int hudstate = luaL_optint(l, 1, 0);
if (hudstate)
luacon_controller->SetHudEnable(1);
else
luacon_controller->SetHudEnable(0);
return 0;
}
int luatpt_gravity(lua_State* l)
{

View File

@ -9,6 +9,7 @@
#define LUASCRIPTHELPER_H_
extern GameModel * luacon_model;
extern GameController * luacon_controller;
extern Simulation * luacon_sim;
extern LuaScriptInterface * luacon_ci;
extern Graphics * luacon_g;

View File

@ -55,6 +55,7 @@ extern "C"
}
GameModel * luacon_model;
GameController * luacon_controller;
Simulation * luacon_sim;
LuaScriptInterface * luacon_ci;
Graphics * luacon_g;
@ -91,6 +92,7 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
luacon_mousedown(false)
{
luacon_model = m;
luacon_controller = c;
luacon_sim = m->GetSimulation();
luacon_g = ui::Engine::Ref().g;
luacon_ren = m->GetRenderer();

View File

@ -892,6 +892,11 @@ void GameController::ShowGravityGrid()
gameModel->UpdateQuickOptions();
}
void GameController::SetHudEnable(bool hudState)
{
gameView->SetHudEnable(hudState);
}
void GameController::SetActiveColourPreset(int preset)
{
gameModel->SetActiveColourPreset(preset);
@ -1107,7 +1112,16 @@ void GameController::ShowConsole()
{
if(!console)
console = new ConsoleController(NULL, commandInterface);
ui::Engine::Ref().ShowWindow(console->GetView());
if (console->GetView() != ui::Engine::Ref().GetWindow())
ui::Engine::Ref().ShowWindow(console->GetView());
}
void GameController::HideConsole()
{
if(!console)
return;
if (console->GetView() == ui::Engine::Ref().GetWindow())
ui::Engine::Ref().CloseWindow();
}
void GameController::OpenRenderOptions()

View File

@ -96,6 +96,7 @@ public:
void SetDecoration(bool decorationState);
void SetDecoration();
void ShowGravityGrid();
void SetHudEnable(bool hudState);
void SetActiveMenu(Menu * menu);
void SetActiveTool(int toolSelection, Tool * tool);
void SetActiveColourPreset(int preset);
@ -123,6 +124,7 @@ public:
void Vote(int direction);
void ChangeBrush();
void ShowConsole();
void HideConsole();
void FrameStep();
void TranslateSave(ui::Point point);
void TransformSave(matrix2d transform);

View File

@ -564,6 +564,11 @@ void GameView::SetSample(SimulationSample sample)
this->sample = sample;
}
void GameView::SetHudEnable(bool hudState)
{
showHud = hudState;
}
ui::Point GameView::GetMousePosition()
{
return mousePosition;

View File

@ -126,6 +126,7 @@ public:
//Breaks MVC, but any other way is going to be more of a mess.
ui::Point GetMousePosition();
void SetSample(SimulationSample sample);
void SetHudEnable(bool hudState);
bool CtrlBehaviour(){ return ctrlBehaviour; }
bool ShiftBehaviour(){ return shiftBehaviour; }
void ExitPrompt();