summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-24 23:33:32 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-24 23:33:32 (GMT)
commit35858ef6073092f8447bbec8b18b768061cf8bd0 (patch)
tree1ad7e7e9272f6a640289bc422ebe7d34fe025bf0 /src
parent04e4a2346d3d7ef6e0f0b38d8eafc928dc6e30bd (diff)
downloadpowder-35858ef6073092f8447bbec8b18b768061cf8bd0.zip
powder-35858ef6073092f8447bbec8b18b768061cf8bd0.tar.gz
Fix textbox
Diffstat (limited to 'src')
-rw-r--r--src/PowderToy.cpp12
-rw-r--r--src/client/Client.cpp2
-rw-r--r--src/game/GameController.cpp12
-rw-r--r--src/interface/Engine.cpp2
-rw-r--r--src/interface/Textbox.cpp2
-rw-r--r--src/login/LoginController.cpp13
-rw-r--r--src/login/LoginController.h1
-rw-r--r--src/login/LoginView.cpp12
-rw-r--r--src/login/LoginView.h1
9 files changed, 50 insertions, 7 deletions
diff --git a/src/PowderToy.cpp b/src/PowderToy.cpp
index 0d3c75c..c7b6da0 100644
--- a/src/PowderToy.cpp
+++ b/src/PowderToy.cpp
@@ -32,6 +32,7 @@ SDL_Surface * SDLOpen()
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
return 0;
}
+ SDL_EnableUNICODE(1);
#if defined(WIN32) && defined(WINCONSOLE)
//On Windows, SDL redirects stdout to stdout.txt, which can be annoying when debugging, here we redirect back to the console
if (console)
@@ -84,7 +85,7 @@ int main(int argc, char * argv[])
engine->Exit();
break;
case SDL_KEYDOWN:
- engine->onKeyPress(event.key.keysym.sym, false, false, false);
+ engine->onKeyPress(event.key.keysym.unicode, false, false, false);
break;
case SDL_KEYUP:
break;
@@ -133,7 +134,14 @@ int main(int argc, char * argv[])
fps = (((float)currentFrame)/((float)elapsedTime))*1000.0f;
currentFrame = 0;
lastTime = currentTime;
- delta = 60.0f/fps;
+ if(ui::Engine::Ref().FpsLimit > 2.0f)
+ {
+ delta = ui::Engine::Ref().FpsLimit/fps;
+ }
+ else
+ {
+ delta = 1.0f;
+ }
}
}
ui::Engine::Ref().CloseWindow();
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 94c3dbc..d0bfd97 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -20,7 +20,7 @@
Client::Client()
{
int i = 0;
- http_init("wwwcache.lancs.ac.uk:8080");
+ http_init(NULL);
for(i = 0; i < THUMB_CACHE_SIZE; i++)
{
thumbnailCache[i] = NULL;
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 5358c4b..b00c802 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -28,14 +28,22 @@ GameController::~GameController()
{
if(search)
{
- ui::Engine::Ref().CloseWindow();
+ if(ui::Engine::Ref().GetWindow() == search->GetView())
+ ui::Engine::Ref().CloseWindow();
delete search;
}
if(renderOptions)
{
- ui::Engine::Ref().CloseWindow();
+ if(ui::Engine::Ref().GetWindow() == renderOptions->GetView())
+ ui::Engine::Ref().CloseWindow();
delete renderOptions;
}
+ if(loginWindow)
+ {
+ if(ui::Engine::Ref().GetWindow() == loginWindow->GetView())
+ ui::Engine::Ref().CloseWindow();
+ delete loginWindow;
+ }
delete gameView;
delete gameModel;
}
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index a505635..9778a5d 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -144,7 +144,7 @@ void Engine::Tick(float dt)
{
state_->Position.Y += windowTargetPosition.Y/20;
}*/
- windowOpenState += 0.05f*dt;
+ windowOpenState += 0.05f;//*dt;
}
/*if(statequeued_ != NULL)
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 380ad59..328ccb5 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -1,4 +1,5 @@
#include <string>
+#include <iostream>
#include <stdexcept>
#include "Config.h"
#include "Global.h"
@@ -157,6 +158,7 @@ void Textbox::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
if(cursor == text.length())
{
text += key;
+ //std::cout << key << std::endl;
}
else
{
diff --git a/src/login/LoginController.cpp b/src/login/LoginController.cpp
index 3172398..64c8221 100644
--- a/src/login/LoginController.cpp
+++ b/src/login/LoginController.cpp
@@ -22,7 +22,18 @@ void LoginController::Login(string username, string password)
loginModel->Login(username, password);
}
+void LoginController::Exit()
+{
+ if(ui::Engine::Ref().GetWindow() == loginView)
+ {
+ ui::Engine::Ref().CloseWindow();
+ loginView = NULL;
+ }
+}
+
LoginController::~LoginController() {
- // TODO Auto-generated destructor stub
+ if(loginView)
+ delete loginView;
+ delete loginModel;
}
diff --git a/src/login/LoginController.h b/src/login/LoginController.h
index ecd30a3..2df28ab 100644
--- a/src/login/LoginController.h
+++ b/src/login/LoginController.h
@@ -22,6 +22,7 @@ class LoginController {
public:
LoginController();
void Login(string username, string password);
+ void Exit();
LoginView * GetView() { return loginView; }
virtual ~LoginController();
diff --git a/src/login/LoginView.cpp b/src/login/LoginView.cpp
index bb88c15..9becd17 100644
--- a/src/login/LoginView.cpp
+++ b/src/login/LoginView.cpp
@@ -18,6 +18,17 @@ public:
}
};
+class LoginView::CancelAction : public ui::ButtonAction
+{
+ LoginView * v;
+public:
+ CancelAction(LoginView * _v) { v = _v; }
+ void ActionCallback(ui::Button * sender)
+ {
+ v->c->Exit();
+ }
+};
+
LoginView::LoginView():
ui::Window(ui::Point(-1, -1), ui::Point(200, 100)),
loginButton(new ui::Button(ui::Point(200-50, 100-16), ui::Point(50, 16), "Login")),
@@ -32,6 +43,7 @@ LoginView::LoginView():
loginButton->SetActionCallback(new LoginAction(this));
AddComponent(cancelButton);
cancelButton->SetAlignment(AlignCentre, AlignBottom);
+ cancelButton->SetActionCallback(new CancelAction(this));
AddComponent(titleLabel);
titleLabel->SetAlignment(AlignLeft, AlignBottom);
AddComponent(usernameField);
diff --git a/src/login/LoginView.h b/src/login/LoginView.h
index 2646e99..1099278 100644
--- a/src/login/LoginView.h
+++ b/src/login/LoginView.h
@@ -27,6 +27,7 @@ class LoginView: public ui::Window {
ui::Textbox * passwordField;
public:
class LoginAction;
+ class CancelAction;
LoginView();
void AttachController(LoginController * c_) { c = c_; }
void NotifyStatusChanged(LoginModel * sender);