fixed 3 major bugs (LineEdit backspace, input crashes, editor button press and editor actions)

This commit is contained in:
2011-01-30 21:43:04 +01:00
parent 3e05c967ab
commit a27ece921a
10 changed files with 62 additions and 18 deletions
+23 -10
View File
@@ -229,7 +229,6 @@ void View::DrawStars() {
glEnd();
glPopMatrix();
}
void View::Draw() {
@@ -773,12 +772,14 @@ void View::DrawUiEditor() {
// The close button
if (Engine::GUI::Button (1, "X", screen_right - 48, 20, 32, button_height)
|| Engine::GUI::CheckKeyPress(SDLK_ESCAPE)) {
|| Engine::GUI::CheckKeyPressed(SDLK_ESCAPE)) {
if (mEditorState == EditorStateTest) {
mEditorState = EditorStateUnknown;
GetModel()->DoLoadLevel("level_edit_temp.txt");
GetModel()->SetGameState(GameStatePaused);
return;
} else {
PopViewState();
}
@@ -787,26 +788,38 @@ void View::DrawUiEditor() {
if (mEditorState != EditorStateTest) {
if (Engine::GUI::Button (2, "Add", 30, 20, 50, button_height)) {
mEditorState = EditorStateAddEntity;
Engine::LogDebug ("Editor state now Add");
return;
}
if (Engine::GUI::Button (3, "Del", 85, 20, 50, button_height)) {
mEditorState = EditorStateDelEntity;
Engine::LogDebug ("Editor state now Del");
return;
}
if (Engine::GUI::Button (4, "Move", 140, 20, 65, button_height)) {
mEditorState = EditorStateMoveEntity;
Engine::LogDebug ("Editor state now Move");
return;
}
if (Engine::GUI::Button (5, "Spd", 210, 20, 50, button_height)) {
mEditorState = EditorStateEntityVelocity;
Engine::LogDebug ("Editor state now Add");
return;
}
if (Engine::GUI::Button (6, "Save", 265, 20, 65, button_height)) {
mEditorState = EditorStateSave;
Engine::LogDebug ("Editor state now Save");
return;
}
if (Engine::GUI::Button (7, "Load", 335, 20, 65, button_height)) {
mEditorState = EditorStateLoad;
Engine::LogDebug ("Editor state now Load");
return;
}
// we only show the Test button when there is actually something to play
@@ -833,7 +846,7 @@ void View::DrawUiEditor() {
SelectFont ("console.ttf size=12");
Engine::GUI::Label (9999, "Adding", 128, 16);
if (Engine::GUI::CheckKeyPress(MouseButtonLeft)) {
if (Engine::GUI::CheckKeyPressed(MouseButtonLeft)) {
// if there is no entity so far we create a player, otherwise we create
// an asteroid
@@ -856,7 +869,7 @@ void View::DrawUiEditor() {
SelectFont ("console.ttf size=12");
Engine::GUI::Label (9999, "Deleting", 128, 16);
if (controller->GetButtonState(MouseButtonLeft)) {
if (Engine::GUI::CheckKeyPressed(MouseButtonLeft)) {
// Check if there is an entity near the given position
Engine::EntityBase* entity = Engine::GetEntityAt (mouse_world_pos);
@@ -871,7 +884,7 @@ void View::DrawUiEditor() {
SelectFont ("console.ttf size=12");
Engine::GUI::Label (9999, "Moving", 128, 16);
if (controller->GetButtonState(MouseButtonLeft)) {
if (Engine::GUI::CheckKeyPress(MouseButtonLeft)) {
// Check if there is an entity near the given position
Engine::EntityBase* asteroid = Engine::GetEntityAt (mouse_world_pos);
if (asteroid) {
@@ -884,7 +897,7 @@ void View::DrawUiEditor() {
asteroid->mPhysicState->SetPosition (mouse_world_pos);
}
if (!controller->GetButtonState(MouseButtonLeft)) {
if (!Engine::GUI::CheckKeyPress(MouseButtonLeft)) {
if (mEditorEntityId != 0) {
mEditorEntityId = 0;
}
@@ -896,7 +909,7 @@ void View::DrawUiEditor() {
Engine::GUI::Label (9999, "Velocity", 128, 16);
if (mEditorEntityId == 0) {
if (controller->GetButtonState(MouseButtonLeft)) {
if (Engine::GUI::CheckKeyPress(MouseButtonLeft)) {
// Check if there is an entity near the given position
Engine::EntityBase* asteroid = Engine::GetEntityAt (mouse_world_pos);
if (asteroid) {
@@ -912,7 +925,7 @@ void View::DrawUiEditor() {
new_velocity[1] = 0.;
asteroid->mPhysicState->SetVelocity (new_velocity);
if (!controller->GetButtonState(MouseButtonLeft)) {
if (!Engine::GUI::CheckKeyPress(MouseButtonLeft)) {
if (mEditorEntityId != 0) {
mEditorEntityId = 0;
}
@@ -968,8 +981,8 @@ void View::DrawUiEditor() {
mEditorState = EditorStateUnknown;
}
if (controller->GetButtonState(MouseButtonRight)
|| controller->GetButtonState(SDLK_ESCAPE) ) {
if (Engine::GUI::CheckKeyPressed(MouseButtonRight)
|| Engine::GUI::CheckKeyPressed(SDLK_ESCAPE) ) {
mEditorState = EditorStateUnknown;
}
}