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

View File

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

View File

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

View File

@ -892,6 +892,11 @@ void GameController::ShowGravityGrid()
gameModel->UpdateQuickOptions(); gameModel->UpdateQuickOptions();
} }
void GameController::SetHudEnable(bool hudState)
{
gameView->SetHudEnable(hudState);
}
void GameController::SetActiveColourPreset(int preset) void GameController::SetActiveColourPreset(int preset)
{ {
gameModel->SetActiveColourPreset(preset); gameModel->SetActiveColourPreset(preset);
@ -1107,7 +1112,16 @@ void GameController::ShowConsole()
{ {
if(!console) if(!console)
console = new ConsoleController(NULL, commandInterface); 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() void GameController::OpenRenderOptions()

View File

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

View File

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

View File

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