summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-01-09 03:00:45 (GMT)
committer jacob1 <jfu614@gmail.com>2013-01-09 03:00:45 (GMT)
commit162a8ecba57a3cea84149aa89d6eee742c1e2cea (patch)
tree9ea3a82a3b0ba704769830eebd362e25b02ad5d8 /src
parent6dad17c2e170abe561da0ba055c99b0c613e74bc (diff)
downloadpowder-162a8ecba57a3cea84149aa89d6eee742c1e2cea.zip
powder-162a8ecba57a3cea84149aa89d6eee742c1e2cea.tar.gz
readd tpt.hud and tpt.set_console commands
Diffstat (limited to 'src')
-rw-r--r--src/cat/LegacyLuaAPI.cpp23
-rw-r--r--src/cat/LuaScriptHelper.h1
-rw-r--r--src/cat/LuaScriptInterface.cpp2
-rw-r--r--src/game/GameController.cpp16
-rw-r--r--src/game/GameController.h2
-rw-r--r--src/game/GameView.cpp5
-rw-r--r--src/game/GameView.h1
7 files changed, 38 insertions, 12 deletions
diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp
index 8c52bfe..c6a41e1 100644
--- a/src/cat/LegacyLuaAPI.cpp
+++ b/src/cat/LegacyLuaAPI.cpp
@@ -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)
{
diff --git a/src/cat/LuaScriptHelper.h b/src/cat/LuaScriptHelper.h
index 1b771e4..b55329f 100644
--- a/src/cat/LuaScriptHelper.h
+++ b/src/cat/LuaScriptHelper.h
@@ -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;
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 8cf35c3..b529255 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -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();
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 2ec2cfc..3b9a64e 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -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()
diff --git a/src/game/GameController.h b/src/game/GameController.h
index 2e02b25..a3057d2 100644
--- a/src/game/GameController.h
+++ b/src/game/GameController.h
@@ -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);
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 5118d17..d6f519c 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -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;
diff --git a/src/game/GameView.h b/src/game/GameView.h
index e17279f..7474da0 100644
--- a/src/game/GameView.h
+++ b/src/game/GameView.h
@@ -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();