summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-24 20:19:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-24 20:19:19 (GMT)
commit97b35bc47059315d4138c8e0827842d2c03de152 (patch)
treefeaf7a8c018982ba9d7ca1b8e6e15294abfdfc84 /src/game
parent04488081d3fa0cd3dfb2939e5d902bc894df150d (diff)
downloadpowder-97b35bc47059315d4138c8e0827842d2c03de152.zip
powder-97b35bc47059315d4138c8e0827842d2c03de152.tar.gz
Various
Diffstat (limited to 'src/game')
-rw-r--r--src/game/GameController.cpp4
-rw-r--r--src/game/GameController.h2
-rw-r--r--src/game/GameModel.cpp4
-rw-r--r--src/game/GameView.cpp19
-rw-r--r--src/game/GameView.h1
5 files changed, 22 insertions, 8 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index b79da06..5358c4b 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -6,6 +6,7 @@
#include "GameModel.h"
#include "search/SearchController.h"
#include "render/RenderController.h"
+#include "login/LoginController.h"
#include "interface/Point.h"
using namespace std;
@@ -126,7 +127,8 @@ void GameController::OpenSearch()
void GameController::OpenLogin()
{
- //TODO: Implement
+ loginWindow = new LoginController();
+ ui::Engine::Ref().ShowWindow(loginWindow->GetView());
}
void GameController::OpenTags()
diff --git a/src/game/GameController.h b/src/game/GameController.h
index f945cce..67afdc4 100644
--- a/src/game/GameController.h
+++ b/src/game/GameController.h
@@ -8,6 +8,7 @@
#include "simulation/Simulation.h"
#include "search/SearchController.h"
#include "render/RenderController.h"
+#include "login/LoginController.h"
#include "Menu.h"
using namespace std;
@@ -22,6 +23,7 @@ private:
GameModel * gameModel;
SearchController * search;
RenderController * renderOptions;
+ LoginController * loginWindow;
public:
GameController();
~GameController();
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 91b1c8d..8f16f49 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -19,12 +19,12 @@ GameModel::GameModel():
menuList.clear();
for(int i = 0; i < 12; i++)
{
- menuList.push_back(new Menu('q', "Simon"));
+ menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name));
}
//Build menus from Simulation elements
for(int i = 0; i < PT_NUM; i++)
{
- if(sim->ptypes[i].menusection < 12)
+ if(sim->ptypes[i].menusection < 12 && sim->ptypes[i].enabled && sim->ptypes[i].menu)
{
Tool * tempTool = new ElementTool(i, sim->ptypes[i].name, PIXR(sim->ptypes[i].pcolors), PIXG(sim->ptypes[i].pcolors), PIXB(sim->ptypes[i].pcolors));
menuList[sim->ptypes[i].menusection]->AddTool(tempTool);
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index f7e0682..8438e1b 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -9,7 +9,8 @@ GameView::GameView():
pointQueue(queue<ui::Point*>()),
isMouseDown(false),
ren(NULL),
- activeBrush(NULL)
+ activeBrush(NULL),
+ currentMouse(0, 0)
{
int currentX = 1;
//Set up UI
@@ -344,6 +345,7 @@ void GameView::NotifyBrushChanged(GameModel * sender)
void GameView::OnMouseMove(int x, int y, int dx, int dy)
{
+ currentMouse = ui::Point(x, y);
if(isMouseDown)
{
pointQueue.push(new ui::Point(x-dx, y-dy));
@@ -353,8 +355,11 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
void GameView::OnMouseDown(int x, int y, unsigned button)
{
- isMouseDown = true;
- pointQueue.push(new ui::Point(x, y));
+ if(currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES)
+ {
+ isMouseDown = true;
+ pointQueue.push(new ui::Point(x, y));
+ }
}
void GameView::OnMouseUp(int x, int y, unsigned button)
@@ -389,6 +394,10 @@ void GameView::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
void GameView::OnTick(float dt)
{
+ if(isMouseDown)
+ {
+ pointQueue.push(new ui::Point(currentMouse));
+ }
if(!pointQueue.empty())
{
c->DrawPoints(pointQueue);
@@ -404,8 +413,8 @@ void GameView::OnDraw()
ren->render_fire();
ren->render_signs();
}
- if(activeBrush)
+ if(activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES)
{
- activeBrush->Render(ui::Engine::Ref().g, ui::Point(ui::Engine::Ref().GetMouseX(),ui::Engine::Ref().GetMouseY()));
+ activeBrush->Render(ui::Engine::Ref().g, currentMouse);
}
}
diff --git a/src/game/GameView.h b/src/game/GameView.h
index 3881795..ef35536 100644
--- a/src/game/GameView.h
+++ b/src/game/GameView.h
@@ -36,6 +36,7 @@ private:
ui::Button * simulationOptionButton;
ui::Button * displayModeButton;
ui::Button * pauseButton;
+ ui::Point currentMouse;
public:
GameView();
void AttachController(GameController * _c){ c = _c; }