| 2943 | } |
| 2944 | |
| 2945 | void BattleView::eventOccurred(Event *e) |
| 2946 | { |
| 2947 | baseForm->eventOccured(e); |
| 2948 | bool eventWithin = false; |
| 2949 | for (auto &f : itemForms) |
| 2950 | { |
| 2951 | if (f->Enabled) |
| 2952 | { |
| 2953 | f->eventOccured(e); |
| 2954 | if (f->eventIsWithin(e)) |
| 2955 | { |
| 2956 | eventWithin = true; |
| 2957 | } |
| 2958 | } |
| 2959 | } |
| 2960 | // Exclude mouse down events that are over the form |
| 2961 | if (eventWithin || activeTab->eventIsWithin(e) || baseForm->eventIsWithin(e)) |
| 2962 | { |
| 2963 | // We pass this event so that scroll can work |
| 2964 | if (e->type() != EVENT_MOUSE_MOVE) |
| 2965 | { |
| 2966 | return; |
| 2967 | } |
| 2968 | } |
| 2969 | |
| 2970 | switch (e->type()) |
| 2971 | { |
| 2972 | case EVENT_MOUSE_MOVE: |
| 2973 | { |
| 2974 | Vec2<float> screenOffset = {getScreenOffset().x, getScreenOffset().y}; |
| 2975 | // Offset by 4 since ingame 4 is the typical height of the ground, and game displays |
| 2976 | // cursor |
| 2977 | // on top of the ground |
| 2978 | setSelectedTilePosition(screenToTileCoords( |
| 2979 | Vec2<float>((float)e->mouse().X, (float)e->mouse().Y + 4) - screenOffset, |
| 2980 | (float)getZLevel() - 1.0f)); |
| 2981 | // do not return, pass on to allow scrolling |
| 2982 | break; |
| 2983 | } |
| 2984 | case EVENT_KEY_DOWN: |
| 2985 | if (handleKeyDown(e)) |
| 2986 | { |
| 2987 | return; |
| 2988 | } |
| 2989 | break; |
| 2990 | case EVENT_KEY_UP: |
| 2991 | if (handleKeyUp(e)) |
| 2992 | { |
| 2993 | return; |
| 2994 | } |
| 2995 | break; |
| 2996 | case EVENT_MOUSE_DOWN: |
| 2997 | if (handleMouseDown(e)) |
| 2998 | { |
| 2999 | return; |
| 3000 | } |
| 3001 | break; |
| 3002 | case EVENT_MOUSE_SCROLL: |
nothing calls this directly
no test coverage detected