Comments (12)
would EventMgr::RegisterEventMonitor
work? similar to how GC already employs that for monitoring global mouse movement.
from gemrb.
Kinda works. All other keys get detected immediately, but tab enters the monitor only after several presses. Doesn't seem to be a timing thing. Quite peculiar.
diff --git a/gemrb/core/GUI/GameControl.cpp b/gemrb/core/GUI/GameControl.cpp
index 50b1bd7a4..1e655a38f 100644
--- a/gemrb/core/GUI/GameControl.cpp
+++ b/gemrb/core/GUI/GameControl.cpp
@@ -119,6 +119,8 @@ GameControl::GameControl(const Region& frame)
EventMgr::EventCallback* cb = new MethodCallback<GameControl, const Event&, bool>(this, &GameControl::OnGlobalMouseMove);
EventMgr::RegisterEventMonitor(cb, Event::MouseMoveMask);
+ EventMgr::EventCallback *cb2 = new MethodCallback<GameControl, const Event&, bool>(this, &GameControl::DispatchEvent);
+ EventMgr::RegisterEventMonitor(cb2, Event::KeyDownMask);
}
//TODO:
@@ -592,6 +594,24 @@ void GameControl::DrawSelf(Region screen, const Region& /*clip*/)
}
}
+// this existly only so tab can be handled
+// it's used both for tooltips everywhere and hp display on game control
+bool GameControl::DispatchEvent(const Event& event)
+{
+ if (event.keyboard.keycode == GEM_TAB) {
+ Game *game = core->GetGame();
+ if (!game) return false;
+ // show partymember hp/maxhp as overhead text
+ for (int pm=0; pm < game->GetPartySize(false); pm++) {
+ Actor *pc = game->GetPC(pm, true);
+ if (!pc) continue;
+ pc->DisplayHeadHPRatio();
+ }
+ return true;
+ }
+ return false;
+}
+
/** Key Press Event */
bool GameControl::OnKeyPress(const KeyboardEvent& Key, unsigned short mod)
{
@@ -630,11 +650,7 @@ bool GameControl::OnKeyPress(const KeyboardEvent& Key, unsigned short mod)
break;
case GEM_TAB:
// show partymember hp/maxhp as overhead text
- for (int pm=0; pm < game->GetPartySize(false); pm++) {
- Actor *pc = game->GetPC(pm, true);
- if (!pc) continue;
- pc->DisplayHeadHPRatio();
- }
+ // this is handled in DispatchEvent due to tab having two functions
break;
case GEM_ESCAPE:
core->SetEventFlag(EF_ACTION|EF_RESETTARGET);
diff --git a/gemrb/core/GUI/GameControl.h b/gemrb/core/GUI/GameControl.h
index fc80b87d4..10021f6ec 100644
--- a/gemrb/core/GUI/GameControl.h
+++ b/gemrb/core/GUI/GameControl.h
@@ -178,6 +178,8 @@ public:
/** Mouse Over Event */
void OnMouseOver(const MouseEvent&);
void OnMouseDrag(const MouseEvent& /*me*/);
+ /** Currently only deals with the GEM_TAB exception */
+ bool DispatchEvent(const Event& event);
/** Mouse Button Down */
void OnMouseDown(const MouseEvent& /*me*/, unsigned short Mod);
diff --git a/gemrb/plugins/GUIScript/GUIScript.cpp b/gemrb/plugins/GUIScript/GUIScript.cpp
index 745a1991b..a7f2187ff 100644
--- a/gemrb/plugins/GUIScript/GUIScript.cpp
+++ b/gemrb/plugins/GUIScript/GUIScript.cpp
@@ -13167,6 +13167,7 @@ bool GUIScript::Init(void)
return false;
}
PyRun_SimpleString( "GEMRB_VERSION = '" GEMRB_STRING "'" );
+// PyModule_AddStringConstant(pGemRB, "GEMRB_VERSION", GEMRB_STRING);
// Detect GameType if it was set to auto
if (stricmp( core->GameType, "auto" ) == 0) {
from gemrb.
might have something to do with repeat key events (just shooting in the dark)
from gemrb.
I doubt it, it's reproducible way over the threshold. Just holding it down of course get the results faster.
from gemrb.
it looks like the event monitor stuff at the bottom of EventMgr::DispatchEvent
just needs to be moved to the top below e.time = GetTickCount();
.
from gemrb.
not so simple, since then it eats up all input and you can't get past the first screen. :)
from gemrb.
wait why not? the monitors don't (shouldn't) eat events:
EventCallback* cb = it->second.get();
(*cb)(e);
it is just invoking them. the problem is that hot key code runs before it and that does cause a return before the monitors run.
from gemrb.
oh, but apparently WindowManager
gets its events via a monitor, so yeah, not that simple. Hmmm.
from gemrb.
maybe WindowManager
shouldn't eat GEM_TAB
by using a hotkey, and instead handle that in its own monitor callback, same as GC.
from gemrb.
I'll try it tomorrow; please fix the opcodes before you forget.
from gemrb.
yeah, that does it nicely. It now triggers also out of gc for some reason, but that's nothing to lose sleep over.
from gemrb.
heh, some might say that is a feature :)
I think if we cared we would have to do go back to using a hot key and have the GEM_TAB
case of WindowManager::HotKey
return hoverWin != gameWin
so that it will consume the key only if the mouse is over a window. It doesn't matter to me; i can see the appeal of both.
I'll open an issue for the opcodes, I wont be back in town until Monday.
from gemrb.
Related Issues (20)
- inventory: unusuable items blink the whole overlay HOT 5
- Crash on moving the cursor badly while loading HOT 5
- Crash after BG2 switch screen HOT 3
- More Efficient Text Rendering HOT 1
- SDL2: items drawn over fog HOT 5
- Map Fog drawing tanks performance HOT 5
- Convert `Point` from short -> int HOT 1
- msgwin causes optwin and/or portraitwin drawing issue HOT 8
- can't use enter to move through dialog HOT 14
- soa intro shows broken fades HOT 5
- looting the painting container reliably crashes HOT 1
- odd hotkey crash HOT 6
- rightclicking on msgwin TA shows textedit cursor HOT 3
- f1-f12 hotkeys not working for actionbar actions
- tooltip text: eating up newlines / bad width calc HOT 3
- SDL1: movement target reticles drawn incorectly
- no easy way to reset the action bar HOT 2
- trying to worldmap travel triggers an assert HOT 1
- Assertion `key.character == 0' failed HOT 1
- scroll bams not displaying in shops HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gemrb.