fixed 3 major bugs (LineEdit backspace, input crashes, editor button press and editor actions)
This commit is contained in:
@@ -164,6 +164,7 @@ void ControllerBase::IMGUIFinish () {
|
||||
// also reset the last keysym such that old values will not be reported
|
||||
uistate.last_keysym = SDLK_FIRST;
|
||||
uistate.last_key = SDLK_FIRST;
|
||||
uistate.keypressed_set.clear();
|
||||
}
|
||||
|
||||
/** \brief Keyboard processing */
|
||||
@@ -175,6 +176,7 @@ bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
|
||||
// Only when Unicode processing is activated store the unicode value
|
||||
if (SDL_EnableUNICODE(-1)) {
|
||||
uistate.last_unicode = keysym.unicode;
|
||||
// LogMessage ("Received key down of %s and unicode %d", convert_keycode(keysym.sym), keysym.unicode);
|
||||
}
|
||||
|
||||
if (mView->mOverlayManager.SendKeyDown (keysym))
|
||||
@@ -191,6 +193,7 @@ bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
|
||||
/** \brief Keyboard processing */
|
||||
bool ControllerBase::OnKeyUp (const SDL_keysym &keysym) {
|
||||
mButtonStates.set(keysym.sym, false);
|
||||
uistate.keypressed_set.insert (keysym.sym);
|
||||
|
||||
if (mView->mOverlayManager.SendKeyUp (keysym))
|
||||
return true;
|
||||
@@ -228,6 +231,7 @@ bool ControllerBase::OnMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos)
|
||||
bool ControllerBase::OnMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
||||
MouseButton mouse_button = convert_sdl_button (button);
|
||||
mButtonStates.set(mouse_button, false);
|
||||
uistate.keypressed_set.insert (mouse_button);
|
||||
|
||||
if (mView->mOverlayManager.SendMouseButtonUp (button, xpos, ypos))
|
||||
return true;
|
||||
|
||||
@@ -21,6 +21,7 @@ struct IMGUIState {
|
||||
SDLKey last_keysym;
|
||||
Uint16 last_unicode;
|
||||
int last_key;
|
||||
std::set<int> keypressed_set;
|
||||
|
||||
int lastwidget;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <bitset>
|
||||
#include <limits>
|
||||
|
||||
+16
-2
@@ -322,6 +322,9 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
||||
DrawBlock (x, y, w, h);
|
||||
}
|
||||
|
||||
SDL_EnableKeyRepeat(500, 50);
|
||||
|
||||
|
||||
// Rendering of the current value
|
||||
float width, height;
|
||||
view = EngineGetView ();
|
||||
@@ -383,7 +386,10 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
||||
if (maxlength > 0 && text_value.size() < maxlength) {
|
||||
if (controller->uistate.last_unicode) {
|
||||
if ((controller->uistate.last_unicode & 0xFF80) == 0) {
|
||||
text_value += controller->uistate.last_unicode & 0x7F;
|
||||
// we do not want to add special characters such as backspaces
|
||||
// etc.
|
||||
if ((controller->uistate.last_unicode & 0xFFFF) >= 0x20)
|
||||
text_value += controller->uistate.last_unicode & 0x7F;
|
||||
controller->uistate.last_unicode = 0;
|
||||
return true;
|
||||
} else {
|
||||
@@ -508,11 +514,19 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
|
||||
}
|
||||
|
||||
bool CheckKeyPress (int keycode) {
|
||||
if (controller->uistate.last_key == keycode)
|
||||
if (controller->GetButtonState(keycode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckKeyPressed (int keycode) {
|
||||
if (controller->uistate.keypressed_set.find(keycode) != controller->uistate.keypressed_set.end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -38,14 +38,19 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
||||
|
||||
float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float max_value, float &value);
|
||||
|
||||
/** \brief Checks whether a given key was pressed
|
||||
/** \brief Checks whether a given key is currently pressed
|
||||
*
|
||||
* This function can be used to check whether a single key (e.g. ESC) was
|
||||
* This function can be used to check whether a single key (e.g. ESC) is currently
|
||||
* pressed. This is useful when one wants to abort an action or quit from the
|
||||
* main screen by pressing a single key.
|
||||
*/
|
||||
bool CheckKeyPress (int keycode);
|
||||
|
||||
/** \brief Checks whether a key press was completed for a given key
|
||||
*
|
||||
*/
|
||||
bool CheckKeyPressed (int keycode);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -72,6 +72,10 @@
|
||||
* todos within the code have a look at the \ref todo.
|
||||
*
|
||||
* \todo [high] Create a simple racing or asteroids game
|
||||
* \todo [high] fix collisions that go over boundaries
|
||||
*
|
||||
* These are the (for now) postponed todos:
|
||||
*
|
||||
* \todo [med] Use shared_ptr instead of raw pointers for the Entities
|
||||
* \todo [med] Clear all references of EntityVisualState and EntityGameState
|
||||
* \todo [med] Clarify functionalities of CreateEntity, KillEntity, RegisterEntity, UnregisterEntity (which frees memory, which does only change the state of the Model?)
|
||||
@@ -87,6 +91,9 @@
|
||||
* Engine::Module::Init()
|
||||
*
|
||||
* Done:
|
||||
* \todo [med] (30-01-2011) add Engine::GUI::CheckKeyPressed that checks for completed key presses
|
||||
* \todo [med] (30-01-2011) fix LineEdit input which generates blanks when entering backspace for an empty edit
|
||||
* \todo [high] (30-01-2011) fix random crashes for certain characters (has to do with boundary box computation in OGLFT) fix: disabled debug assertion for proper boundary box merging.
|
||||
* \todo [high] (28-11-2010) Enable saving of music and effects volume
|
||||
* \todo [high] (28-11-2010) Allow transitions when player dies
|
||||
* \todo [high] (11-09-2010) Since introduction of the IMGUI pressing 'space' in the menu crashes the game
|
||||
|
||||
@@ -440,9 +440,8 @@ namespace OGLFT {
|
||||
<< " advance.dx: " << bbox.advance_.dx_
|
||||
|
||||
<< std::endl;
|
||||
*/
|
||||
assert (bbox.y_max_ - bbox.y_min_ != 0.);
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user