From: Brad A. <br...@us...> - 2013-01-28 20:57:41
|
gemrb: Infinity Engine emulator The branch master has been updated via b27a0039ef4956acce27ab6442b2757e6c2392e8 (commit) via 4280d4d155623b7afac20787ed390d79efbfa6c8 (commit) via 27d38d4bc78df895f95357dd7999ead724187c88 (commit) Summary of changes: gemrb/core/Font.cpp | 9 +++-- gemrb/core/GUI/Button.cpp | 8 ++-- gemrb/core/GUI/Button.h | 2 +- gemrb/core/GUI/Console.cpp | 7 +++- gemrb/core/GUI/Console.h | 4 +- gemrb/core/GUI/Control.cpp | 35 ++--------------------- gemrb/core/GUI/Control.h | 20 ++++++------ gemrb/core/GUI/EventMgr.cpp | 15 ++++++++-- gemrb/core/GUI/GameControl.cpp | 54 ++++++++++++++++++------------------ gemrb/core/GUI/GameControl.h | 6 ++-- gemrb/core/GUI/MapControl.cpp | 27 +---------------- gemrb/core/GUI/MapControl.h | 4 +-- gemrb/core/GUI/TextArea.cpp | 19 +++++++----- gemrb/core/GUI/TextArea.h | 4 +- gemrb/core/GUI/TextEdit.cpp | 11 ++++--- gemrb/core/GUI/TextEdit.h | 4 +- gemrb/core/GUI/WorldMapControl.cpp | 15 +-------- gemrb/core/GUI/WorldMapControl.h | 4 +-- gemrb/core/Interface.h | 1 + gemrb/core/KeyMap.cpp | 7 ++-- gemrb/core/KeyMap.h | 2 +- 21 files changed, 105 insertions(+), 153 deletions(-) from 69e50f807b19ea0f2ce5ad6937e5ca2abb2b117f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=b27a0039ef4956acce27ab6442b2757e6c2392e8 commit b27a0039ef4956acce27ab6442b2757e6c2392e8 Author: Brad Allred <bra...@me...> Date: Mon Jan 28 13:56:59 2013 -0700 Key Events: have key handles return a bool to indicate if the even was handled this way event manager can selectively trigger hot keys only when the event is not eaten by a responder this enables hot keys (eg 'i' for inventory) to both open and close the inventory window and do so even when in another screen diff --git a/gemrb/core/GUI/Button.cpp b/gemrb/core/GUI/Button.cpp index 86d18d9..bdc7bf5 100644 --- a/gemrb/core/GUI/Button.cpp +++ b/gemrb/core/GUI/Button.cpp @@ -382,23 +382,23 @@ void Button::SetFont(Font* newfont) font = newfont; } /** Handling The default button (enter) */ -void Button::OnSpecialKeyPress(unsigned char Key) +bool Button::OnSpecialKeyPress(unsigned char Key) { if (State != IE_GUI_BUTTON_DISABLED && State != IE_GUI_BUTTON_LOCKED) { if (Key == GEM_RETURN) { if (Flags & IE_GUI_BUTTON_DEFAULT ) { RunEventHandler( ButtonOnPress ); - return; + return true; } } else if (Key == GEM_ESCAPE) { if (Flags & IE_GUI_BUTTON_CANCEL ) { RunEventHandler( ButtonOnPress ); - return; + return true; } } } - Control::OnSpecialKeyPress(Key); + return Control::OnSpecialKeyPress(Key); } /** Mouse Button Down */ diff --git a/gemrb/core/GUI/Button.h b/gemrb/core/GUI/Button.h index e5a1566..b8a2b8a 100644 --- a/gemrb/core/GUI/Button.h +++ b/gemrb/core/GUI/Button.h @@ -166,7 +166,7 @@ public: // Public Events /** Mouse wheel scroll */ void OnMouseWheelScroll(short x, short y); /** A special key has been pressed */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); /** Set handler for specified event */ bool SetEvent(int eventType, EventHandler handler); /** Button Pressed Event Script Function Name */ diff --git a/gemrb/core/GUI/Console.cpp b/gemrb/core/GUI/Console.cpp index 46eb5c6..20308e4 100644 --- a/gemrb/core/GUI/Console.cpp +++ b/gemrb/core/GUI/Console.cpp @@ -101,7 +101,7 @@ void Console::SetText(const char* string) strncpy( ( char * ) Buffer, string, max ); } /** Key Press Event */ -void Console::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) +bool Console::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) { if (Key >= 0x20) { size_t len = strlen( ( char* ) Buffer ); @@ -112,10 +112,12 @@ void Console::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) Buffer[CurPos++] = Key; Buffer[len + 1] = 0; } + return true; } + return false; } /** Special Key Press */ -void Console::OnSpecialKeyPress(unsigned char Key) +bool Console::OnSpecialKeyPress(unsigned char Key) { size_t len; @@ -169,6 +171,7 @@ void Console::OnSpecialKeyPress(unsigned char Key) Changed = true; break; } + return true; } //ctrl-up diff --git a/gemrb/core/GUI/Console.h b/gemrb/core/GUI/Console.h index 89000df..198091c 100644 --- a/gemrb/core/GUI/Console.h +++ b/gemrb/core/GUI/Console.h @@ -82,9 +82,9 @@ private: public: //Events /** Key Press Event */ - void OnKeyPress(unsigned char Key, unsigned short Mod); + bool OnKeyPress(unsigned char Key, unsigned short Mod); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); void SetFocus(bool focus); bool SetEvent(int eventType, EventHandler handler); private: diff --git a/gemrb/core/GUI/Control.cpp b/gemrb/core/GUI/Control.cpp index e313829..b3fc039 100644 --- a/gemrb/core/GUI/Control.cpp +++ b/gemrb/core/GUI/Control.cpp @@ -137,36 +137,6 @@ int Control::RunEventHandler(EventHandler handler) return 1; } -/** Key Press Event */ -void Control::OnKeyPress(unsigned char /*Key*/, unsigned short /*Mod*/) -{ - //print("OnKeyPress: CtrlID = 0x%08X, Key = %c(0x%02hX)",(unsigned int) ControlID, Key, Key); -} - -/** Key Release Event */ -void Control::OnKeyRelease(unsigned char /*Key*/, unsigned short /*Mod*/) -{ - //print("OnKeyRelease: CtrlID = 0x%08X, Key = %c(0x%02hX)",(unsigned int) ControlID, Key, Key); -} - -/** Mouse Enter Event */ -void Control::OnMouseEnter(unsigned short /*x*/, unsigned short /*y*/) -{ - //print("OnMouseEnter: CtrlID = 0x%08X, x = %hd, y = %hd",(unsigned int) ControlID, x, y); -} - -/** Mouse Leave Event */ -void Control::OnMouseLeave(unsigned short /*x*/, unsigned short /*y*/) -{ - //print("OnMouseLeave: CtrlID = 0x%08X, x = %hd, y = %hd",(unsigned int) ControlID, x, y); -} - -/** Mouse Over Event */ -void Control::OnMouseOver(unsigned short /*x*/, unsigned short /*y*/) -{ - //print("OnMouseOver: CtrlID = 0x%08X, x = %hd, y = %hd",(unsigned int) ControlID, x, y); -} - /** Mouse Button Down */ void Control::OnMouseDown(unsigned short x, unsigned short y, unsigned short Button, unsigned short Mod) @@ -196,14 +166,15 @@ void Control::OnMouseWheelScroll( short x, short y) } /** Special Key Press */ -void Control::OnSpecialKeyPress(unsigned char Key) +bool Control::OnSpecialKeyPress(unsigned char Key) { if (Key == GEM_UP || Key == GEM_DOWN) { Control *ctrl = Owner->GetScrollControl(); if (ctrl && (ctrl!=this)) { - ctrl->OnSpecialKeyPress(Key); + return ctrl->OnSpecialKeyPress(Key); } } + return false; } void Control::SetFocus(bool focus) { diff --git a/gemrb/core/GUI/Control.h b/gemrb/core/GUI/Control.h index 221f73a..cbd31b0 100644 --- a/gemrb/core/GUI/Control.h +++ b/gemrb/core/GUI/Control.h @@ -127,25 +127,25 @@ public: //Events /** Run specified handler, it may return error code */ int RunEventHandler(EventHandler handler); /** Key Press Event */ - virtual void OnKeyPress(unsigned char Key, unsigned short Mod); + virtual bool OnKeyPress(unsigned char /*Key*/, unsigned short /*Mod*/) { return false; }; /** Key Release Event */ - virtual void OnKeyRelease(unsigned char Key, unsigned short Mod); + virtual bool OnKeyRelease(unsigned char /*Key*/, unsigned short /*Mod*/) { return false; }; /** Mouse Enter Event */ - virtual void OnMouseEnter(unsigned short x, unsigned short y); + virtual void OnMouseEnter(unsigned short /*x*/, unsigned short /*y*/) {}; /** Mouse Leave Event */ - virtual void OnMouseLeave(unsigned short x, unsigned short y); + virtual void OnMouseLeave(unsigned short /*x*/, unsigned short /*y*/) {}; /** Mouse Over Event */ - virtual void OnMouseOver(unsigned short x, unsigned short y); + virtual void OnMouseOver(unsigned short /*x*/, unsigned short /*y*/) {}; /** Mouse Button Down */ - virtual void OnMouseDown(unsigned short x, unsigned short y, - unsigned short Button, unsigned short Mod); + virtual void OnMouseDown(unsigned short /*x*/, unsigned short /*y*/, + unsigned short /*Button*/, unsigned short /*Mod*/); /** Mouse Button Up */ - virtual void OnMouseUp(unsigned short x, unsigned short y, - unsigned short Button, unsigned short Mod); + virtual void OnMouseUp(unsigned short /*x*/, unsigned short /*y*/, + unsigned short /*Button*/, unsigned short /*Mod*/); /** Mouse wheel scroll */ virtual void OnMouseWheelScroll( short x, short y); /** Special Key Press */ - virtual void OnSpecialKeyPress(unsigned char Key); + virtual bool OnSpecialKeyPress(unsigned char Key); virtual bool IsPixelTransparent(unsigned short /*x*/, unsigned short /*y*/) { return false; } diff --git a/gemrb/core/GUI/EventMgr.cpp b/gemrb/core/GUI/EventMgr.cpp index 6daf018..a7602d0 100644 --- a/gemrb/core/GUI/EventMgr.cpp +++ b/gemrb/core/GUI/EventMgr.cpp @@ -25,7 +25,9 @@ #include "win32def.h" #include "ie_cursors.h" +#include "Game.h" #include "Interface.h" +#include "KeyMap.h" #include "Video.h" #include "GUI/Window.h" @@ -335,18 +337,25 @@ void EventMgr::KeyPress(unsigned char Key, unsigned short Mod) { if (last_win_focused == NULL) return; Control *ctrl = last_win_focused->GetFocus(); - if (ctrl == NULL) return; - ctrl->OnKeyPress( Key, Mod ); + if (!ctrl || !ctrl->OnKeyPress( Key, Mod )) { + // FIXME: need a better way to determine when to call ResolveKey/SetHotKey + if (core->GetGameControl() + && !core->IsPresentingModalWindow() + && !core->GetKeyMap()->ResolveKey(Key, 0)) { + core->GetGame()->SetHotKey(toupper(Key)); + } + } } + /** BroadCast Key Release Event */ void EventMgr::KeyRelease(unsigned char Key, unsigned short Mod) { if (last_win_focused == NULL) return; - Control *ctrl = last_win_focused->GetFocus(); if (Key == GEM_GRAB) { core->GetVideoDriver()->ToggleGrabInput(); return; } + Control *ctrl = last_win_focused->GetFocus(); if (ctrl == NULL) return; ctrl->OnKeyRelease( Key, Mod ); } diff --git a/gemrb/core/GUI/GameControl.cpp b/gemrb/core/GUI/GameControl.cpp index fcc5549..8dd5ce9 100644 --- a/gemrb/core/GUI/GameControl.cpp +++ b/gemrb/core/GUI/GameControl.cpp @@ -33,7 +33,6 @@ #include "ImageMgr.h" #include "Interface.h" #include "Item.h" -#include "KeyMap.h" #include "PathFinder.h" #include "SaveGameIterator.h" #include "ScriptEngine.h" @@ -687,14 +686,14 @@ void GameControl::Draw(unsigned short x, unsigned short y) } /** Key Press Event */ -void GameControl::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) +bool GameControl::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) { if (DialogueFlags&DF_IN_DIALOG) { - return; + return false; } unsigned int i, pc; Game* game = core->GetGame(); - if (!game) return; + if (!game) return false; switch (Key) { case '0': @@ -742,12 +741,12 @@ void GameControl::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) break; case 'c': // show containers in ANDROID, GEM_ALT is not possible to use DebugFlags |= DEBUG_SHOW_CONTAINERS; - return; + break; #endif default: - core->GetGame()->SetHotKey(toupper(Key)); - break; + return false; } + return true; } //Select (or deselect) a new actor (or actors) @@ -788,16 +787,16 @@ static EffectRef heal_ref = { "CurrentHPModifier", -1 }; static EffectRef damage_ref = { "Damage", -1 }; /** Key Release Event */ -void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) +bool GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) { unsigned int i; Game* game = core->GetGame(); if (!game) - return; + return false; if (DialogueFlags&DF_IN_DIALOG) { - if (Mod) return; + if (Mod) return false; switch(Key) { case '1': case '2': @@ -811,12 +810,12 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) { TextArea *ta = core->GetMessageTextArea(); if (ta) { - ta->OnKeyPress(Key,Mod); + return ta->OnKeyPress(Key,Mod); } } break; } - return; + return false; } if (Mod & GEM_MOD_SHIFT) { Key = toupper(Key); @@ -825,11 +824,11 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) //cheatkeys with ctrl- if (Mod & GEM_MOD_CTRL) { if (!core->CheatEnabled()) { - return; + return false; } Map* area = game->GetCurrentArea( ); if (!area) - return; + return false; Actor *lastActor = area->GetActorByGlobalID(lastActorID); Point p(lastMouseX, lastMouseY); core->GetVideoDriver()->ConvertToGame( p.x, p.y ); @@ -1117,7 +1116,7 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) Log(MESSAGE, "GameControl", "KeyRelease:%d - %d", Key, Mod ); break; } - return; //return from cheatkeys + return true; //return from cheatkeys } switch (Key) { //FIXME: move these to guiscript @@ -1134,9 +1133,9 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) DebugFlags &= ~DEBUG_SHOW_CONTAINERS; break; default: - core->GetKeyMap()->ResolveKey(Key,0); - break; + return false; } + return true; } void GameControl::DisplayTooltip() { @@ -2406,7 +2405,7 @@ void GameControl::UpdateTargetMode() { } /** Special Key Press */ -void GameControl::OnSpecialKeyPress(unsigned char Key) +bool GameControl::OnSpecialKeyPress(unsigned char Key) { if (DialogueFlags&DF_IN_DIALOG) { switch(Key) { @@ -2415,10 +2414,10 @@ void GameControl::OnSpecialKeyPress(unsigned char Key) core->GetGUIScriptEngine()->RunFunction("GUIWORLD", "CloseContinueWindow"); break; } - return; //don't accept keys in dialog + return false; //don't accept keys in dialog } Game *game = core->GetGame(); - if (!game) return; + if (!game) return false; int partysize = game->GetPartySize(false); int pm; @@ -2439,7 +2438,7 @@ void GameControl::OnSpecialKeyPress(unsigned char Key) break; case GEM_ALT: DebugFlags |= DEBUG_SHOW_CONTAINERS; - return; + break; case GEM_TAB: // show partymember hp/maxhp as overhead text for (pm=0; pm < partysize; pm++) { @@ -2447,24 +2446,25 @@ void GameControl::OnSpecialKeyPress(unsigned char Key) if (!pc) continue; pc->DisplayHeadHPRatio(); } - return; + break; case GEM_MOUSEOUT: moveX = 0; moveY = 0; - return; + break; case GEM_ESCAPE: core->GetGUIScriptEngine()->RunFunction("GUICommonWindows", "EmptyControls"); core->SetEventFlag(EF_ACTION|EF_RESETTARGET); - return; + break; case GEM_PGUP: core->GetGUIScriptEngine()->RunFunction("CommonWindow","OnIncreaseSize"); - return; + break; case GEM_PGDOWN: core->GetGUIScriptEngine()->RunFunction("CommonWindow","OnDecreaseSize"); - return; + break; default: - return; + return false; } + return true; } void GameControl::CalculateSelection(const Point &p) diff --git a/gemrb/core/GUI/GameControl.h b/gemrb/core/GUI/GameControl.h index d8dca74..abf1e86 100644 --- a/gemrb/core/GUI/GameControl.h +++ b/gemrb/core/GUI/GameControl.h @@ -150,9 +150,9 @@ private: bool AlwaysRun; public: //Events /** Key Press Event */ - void OnKeyPress(unsigned char Key, unsigned short Mod); + bool OnKeyPress(unsigned char Key, unsigned short Mod); /** Key Release Event */ - void OnKeyRelease(unsigned char Key, unsigned short Mod); + bool OnKeyRelease(unsigned char Key, unsigned short Mod); /** Mouse Over Event */ void OnMouseOver(unsigned short x, unsigned short y); /** Global Mouse Move Event */ @@ -165,7 +165,7 @@ public: //Events unsigned short Mod); void OnMouseWheelScroll(short x, short y); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); void DisplayTooltip(); void UpdateScrolling(); void SetScrolling(bool scroll); diff --git a/gemrb/core/GUI/MapControl.cpp b/gemrb/core/GUI/MapControl.cpp index 19afa56..048e1a4 100644 --- a/gemrb/core/GUI/MapControl.cpp +++ b/gemrb/core/GUI/MapControl.cpp @@ -281,30 +281,6 @@ void MapControl::Draw(unsigned short XWin, unsigned short YWin) } } -/** Key Press Event */ -//void MapControl::OnKeyPress(unsigned char /*Key*/, unsigned short /*Mod*/) -//{ -//} - -/** Key Release Event */ -void MapControl::OnKeyRelease(unsigned char Key, unsigned short Mod) -{ - switch (Key) { - case '\t': - //not GEM_TAB - Log(MESSAGE, "MapControl", "TAB released"); - return; - case 'f': - if (Mod & GEM_MOD_CTRL) - core->GetVideoDriver()->ToggleFullscreenMode(); - break; - default: - break; - } - if (!core->CheatEnabled()) { - return; - } -} /** Mouse Over Event */ void MapControl::OnMouseOver(unsigned short x, unsigned short y) { @@ -486,7 +462,7 @@ void MapControl::OnMouseUp(unsigned short x, unsigned short y, unsigned short Bu } /** Special Key Press */ -void MapControl::OnSpecialKeyPress(unsigned char Key) +bool MapControl::OnSpecialKeyPress(unsigned char Key) { ieDword keyScrollSpd = 64; core->GetDictionary()->Lookup("Keyboard Scroll Speed", keyScrollSpd); @@ -521,6 +497,7 @@ void MapControl::OnSpecialKeyPress(unsigned char Key) ScrollX = 0; if (ScrollY < 0) ScrollY = 0; + return true; } bool MapControl::SetEvent(int eventType, EventHandler handler) diff --git a/gemrb/core/GUI/MapControl.h b/gemrb/core/GUI/MapControl.h index 6f72f79..f4bf40a 100644 --- a/gemrb/core/GUI/MapControl.h +++ b/gemrb/core/GUI/MapControl.h @@ -92,10 +92,8 @@ public: /** Mouse Button Up */ void OnMouseUp(unsigned short x, unsigned short y, unsigned short Button, unsigned short Mod); - /** Key Release Event */ - void OnKeyRelease(unsigned char Key, unsigned short Mod); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); /** Set handler for specified event */ bool SetEvent(int eventType, EventHandler handler); private: diff --git a/gemrb/core/GUI/TextArea.cpp b/gemrb/core/GUI/TextArea.cpp index 842bfcf..2b749b2 100644 --- a/gemrb/core/GUI/TextArea.cpp +++ b/gemrb/core/GUI/TextArea.cpp @@ -461,7 +461,7 @@ void TextArea::SetFonts(Font* init, Font* text) } /** Key Press Event */ -void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) +bool TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) { if (Flags & IE_GUI_TEXTAREA_EDITABLE) { if (Key >= 0x20) { @@ -480,24 +480,24 @@ void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) CalcRowCount(); RunEventHandler( TextAreaOnChange ); } - return; + return true; } //Selectable=false for dialogs, rather unintuitive, but fact if ((Flags & IE_GUI_TEXTAREA_SELECTABLE) || ( Key < '1' ) || ( Key > '9' )) - return; + return false; GameControl *gc = core->GetGameControl(); if (gc && (gc->GetDialogueFlags()&DF_IN_DIALOG) ) { Changed = true; seltext=minrow-1; if ((unsigned int) seltext>=lines.size()) { - return; + return true; } for(int i=0;i<Key-'0';i++) { do { seltext++; if ((unsigned int) seltext>=lines.size()) { - return; + return true; } } while (strnicmp( lines[seltext], "[s=", 3 ) != 0 ); @@ -507,20 +507,22 @@ void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) if (idx==-1) { //this kills this object, don't use any more data! gc->dialoghandler->EndDialog(); - return; + return true; } gc->dialoghandler->DialogChoose( idx ); + return true; } + return false; } /** Special Key Press */ -void TextArea::OnSpecialKeyPress(unsigned char Key) +bool TextArea::OnSpecialKeyPress(unsigned char Key) { int len; int i; if (!(Flags&IE_GUI_TEXTAREA_EDITABLE)) { - return; + return false; } Owner->Invalidate(); Changed = true; @@ -632,6 +634,7 @@ void TextArea::OnSpecialKeyPress(unsigned char Key) } CalcRowCount(); RunEventHandler( TextAreaOnChange ); + return true; } /** Returns Row count */ diff --git a/gemrb/core/GUI/TextArea.h b/gemrb/core/GUI/TextArea.h index 6e219be..fa6368a 100644 --- a/gemrb/core/GUI/TextArea.h +++ b/gemrb/core/GUI/TextArea.h @@ -161,9 +161,9 @@ private: //internal functions public: //Events /** Key Press Event */ - void OnKeyPress(unsigned char Key, unsigned short Mod); + bool OnKeyPress(unsigned char Key, unsigned short Mod); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); /** Mousewheel scroll */ void OnMouseWheelScroll(short x, short y); /** Mouse Over Event */ diff --git a/gemrb/core/GUI/TextEdit.cpp b/gemrb/core/GUI/TextEdit.cpp index e6959d4..1df4ddb 100644 --- a/gemrb/core/GUI/TextEdit.cpp +++ b/gemrb/core/GUI/TextEdit.cpp @@ -125,11 +125,11 @@ void TextEdit::SetBackGround(Sprite2D* back) } /** Key Press Event */ -void TextEdit::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) +bool TextEdit::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) { if (Key >= 0x20) { if (Value && ( (Key<'0') || (Key>'9') ) ) - return; + return false; Owner->Invalidate(); Changed = true; int len = ( int ) strlen( ( char* ) Buffer ); @@ -142,10 +142,12 @@ void TextEdit::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) CurPos++; } RunEventHandler( EditOnChange ); + return true; } + return false; } /** Special Key Press */ -void TextEdit::OnSpecialKeyPress(unsigned char Key) +bool TextEdit::OnSpecialKeyPress(unsigned char Key) { int len; @@ -188,10 +190,9 @@ void TextEdit::OnSpecialKeyPress(unsigned char Key) break; case GEM_RETURN: RunEventHandler( EditOnDone ); - return; - } RunEventHandler( EditOnChange ); + return true; } void TextEdit::SetFocus(bool focus) diff --git a/gemrb/core/GUI/TextEdit.h b/gemrb/core/GUI/TextEdit.h index 478550b..4ebfde0 100644 --- a/gemrb/core/GUI/TextEdit.h +++ b/gemrb/core/GUI/TextEdit.h @@ -92,9 +92,9 @@ private: Palette* palette; public: //Events /** Key Press Event */ - void OnKeyPress(unsigned char Key, unsigned short Mod); + bool OnKeyPress(unsigned char Key, unsigned short Mod); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); /** Set handler for specified event */ bool SetEvent(int eventType, EventHandler handler); void SetFocus(bool focus); diff --git a/gemrb/core/GUI/WorldMapControl.cpp b/gemrb/core/GUI/WorldMapControl.cpp index ef6740e..58af600 100644 --- a/gemrb/core/GUI/WorldMapControl.cpp +++ b/gemrb/core/GUI/WorldMapControl.cpp @@ -183,18 +183,6 @@ void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin) video->SetClipRect(&clipbackup); } -/** Key Release Event */ -void WorldMapControl::OnKeyRelease(unsigned char Key, unsigned short Mod) -{ - switch (Key) { - case 'f': - if (Mod & GEM_MOD_CTRL) - core->GetVideoDriver()->ToggleFullscreenMode(); - break; - default: - break; - } -} void WorldMapControl::AdjustScrolling(short x, short y) { WorldMap* worldmap = core->GetWorldMap(); @@ -355,7 +343,7 @@ void WorldMapControl::OnMouseWheelScroll(short x, short y) } /** Special Key Press */ -void WorldMapControl::OnSpecialKeyPress(unsigned char Key) +bool WorldMapControl::OnSpecialKeyPress(unsigned char Key) { ieDword keyScrollSpd = 64; core->GetDictionary()->Lookup("Keyboard Scroll Speed", keyScrollSpd); @@ -379,6 +367,7 @@ void WorldMapControl::OnSpecialKeyPress(unsigned char Key) Log(MESSAGE, "WorldMapControl", "TAB pressed"); break; } + return true; } bool WorldMapControl::SetEvent(int eventType, EventHandler handler) diff --git a/gemrb/core/GUI/WorldMapControl.h b/gemrb/core/GUI/WorldMapControl.h index df07de4..eed00cb 100644 --- a/gemrb/core/GUI/WorldMapControl.h +++ b/gemrb/core/GUI/WorldMapControl.h @@ -107,10 +107,8 @@ private: unsigned short Mod); /** Mouse Wheel Event */ void OnMouseWheelScroll(short x, short y); - /** Key Release Event */ - void OnKeyRelease(unsigned char Key, unsigned short Mod); /** Special Key Press */ - void OnSpecialKeyPress(unsigned char Key); + bool OnSpecialKeyPress(unsigned char Key); /** DisplayTooltip */ void DisplayTooltip(); }; diff --git a/gemrb/core/KeyMap.cpp b/gemrb/core/KeyMap.cpp index da5406c..d4f2ef1 100644 --- a/gemrb/core/KeyMap.cpp +++ b/gemrb/core/KeyMap.cpp @@ -135,7 +135,7 @@ bool KeyMap::InitializeKeyMap(const char *inifile, const char *tablefile) //group can be: //main gamecontrol -void KeyMap::ResolveKey(int key, int group) +bool KeyMap::ResolveKey(int key, int group) { Function *fun; void *tmp; @@ -147,16 +147,17 @@ void KeyMap::ResolveKey(int key, int group) print("Looking up key: %c(%s) ", key, keystr); if (!keymap.Lookup(keystr, tmp) ) { - return; + return false; } fun = (Function *) tmp; if (fun->group!=group) { - return; + return false; } Log(MESSAGE, "KeyMap", "RunFunction(%s::%s)", fun->module, fun->function); core->GetGUIScriptEngine()->RunFunction(fun->module, fun->function); + return true; } diff --git a/gemrb/core/KeyMap.h b/gemrb/core/KeyMap.h index 6ac515f..fbcc6ed 100644 --- a/gemrb/core/KeyMap.h +++ b/gemrb/core/KeyMap.h @@ -35,7 +35,7 @@ public: KeyMap(); ~KeyMap(); bool InitializeKeyMap(const char *inifile, const char *keyfile); - void ResolveKey(int key, int group); + bool ResolveKey(int key, int group); }; class Function { http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=4280d4d155623b7afac20787ed390d79efbfa6c8 commit 4280d4d155623b7afac20787ed390d79efbfa6c8 Author: Brad Allred <bra...@me...> Date: Mon Jan 28 13:51:53 2013 -0700 Interface: add method for seeing if we are presenting a modal window diff --git a/gemrb/core/Interface.h b/gemrb/core/Interface.h index 0936922..8863017 100644 --- a/gemrb/core/Interface.h +++ b/gemrb/core/Interface.h @@ -445,6 +445,7 @@ public: /** Loads a Window in the Window Manager */ int LoadWindow(unsigned short WindowID); /** Creates a Window in the Window Manager */ + bool IsPresentingModalWindow() {return (bool)(ModalWindow);}; #ifdef WIN32 #ifdef CreateWindow #undef CreateWindow http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=27d38d4bc78df895f95357dd7999ead724187c88 commit 27d38d4bc78df895f95357dd7999ead724187c88 Author: Brad Allred <bra...@me...> Date: Mon Jan 28 12:35:10 2013 -0700 Font: more whitespace / comment cleanup also make this empty loop more clear that it is intentionally empty. (fix compiler warning) diff --git a/gemrb/core/Font.cpp b/gemrb/core/Font.cpp index 2dbfa17..f39dced 100644 --- a/gemrb/core/Font.cpp +++ b/gemrb/core/Font.cpp @@ -45,7 +45,7 @@ Font::Font() // TODO: list incomplete // maybe want to externalize this - // list compiled form wiki: http://www.gemrb.org/wiki/doku.php?id=engine:encodings&s[]=tlk + // list compiled form wiki: http://www.gemrb.org/wiki/doku.php?id=engine:encodings const char* multibyteEncodings[] = { // Chinese "GBK", "BIG5", @@ -395,7 +395,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, sscanf( tag, "capital=%d", &capital); continue; } - + if (strnicmp( tag, "color=", 6 ) == 0) { unsigned int r,g,b; if (sscanf( tag, "color=%02X%02X%02X", &r, &g, &b ) != 3) @@ -438,7 +438,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, x = initials->PrintInitial( x, y, rgn, currChar ); continue; } - + if (i > 0) { // kerning x -= GetKerningOffset(tmp[i-1], currChar); @@ -630,7 +630,8 @@ int Font::dbStrLen(const ieWord* string) const { if (string == NULL) return 0; int count = 0; - for ( ; string[count] != 0; count++); + for ( ; string[count] != 0; count++) + continue; // intentionally empty loop return count; } ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |