From 7d104772fdfa39bbca57e2174448a62aecbe2ad4 Mon Sep 17 00:00:00 2001 From: Filtik Date: Fri, 9 May 2014 20:40:18 +0200 Subject: [PATCH] Implement chat history browsing (Client and Python) --- .../pfGameGUIMgr/pfGUIDialogNotifyProc.cpp | 8 ++++++++ .../FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp | 16 +++++++++++++--- .../FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h | 4 +++- .../Plasma/FeatureLib/pfMessage/pfGUINotifyMsg.h | 4 ++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogNotifyProc.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogNotifyProc.cpp index a5d3c081..c04d6d33 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogNotifyProc.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogNotifyProc.cpp @@ -105,6 +105,14 @@ void pfGUIDialogNotifyProc::HandleExtendedEvent( pfGUIControlMod *ctrl, uint32_t //send notify, somebody will do something with that (like python script) ISendNotify( ctrl->GetKey(), pfGUINotifyMsg::kSpecialAction ); } + else if(edit && event == pfGUIEditBoxMod::kWantMessageHistoryUp) + { + ISendNotify( ctrl->GetKey(), pfGUINotifyMsg::kMessageHistoryUp ); + } + else if(edit && event == pfGUIEditBoxMod::kWantMessageHistoryDown) + { + ISendNotify( ctrl->GetKey(), pfGUINotifyMsg::kMessageHistoryDown ); + } } void pfGUIDialogNotifyProc::OnInit( void ) diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp index d71843db..59014757 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp @@ -335,11 +335,11 @@ bool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef { fFirstHalfExitKeyPushed = false; // Use arrow keys to do our dirty work - if( key == KEY_UP || key == KEY_HOME ) + if( key == KEY_HOME ) { SetCursorToHome(); } - else if( key == KEY_DOWN || key == KEY_END ) + else if( key == KEY_END ) { SetCursorToEnd(); } @@ -381,9 +381,19 @@ bool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef } else if (key == KEY_TAB) { - //Send notify for python scripts + // Send notify for python scripts HandleExtendedEvent(kWantAutocomplete); } + else if (key == KEY_UP) + { + // Send notify for python scripts + HandleExtendedEvent(kWantMessageHistoryUp); + } + else if (key == KEY_DOWN) + { + // Send notify for python scripts + HandleExtendedEvent(kWantMessageHistoryDown); + } else if (modifiers & pfGameGUIMgr::kCtrlDown) { if (key == KEY_C) diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h index a478142d..41b1c121 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h @@ -129,7 +129,9 @@ class pfGUIEditBoxMod : public pfGUIControlMod enum ExtendedEvents { kValueChanging, - kWantAutocomplete + kWantAutocomplete, + kWantMessageHistoryUp, + kWantMessageHistoryDown }; }; diff --git a/Sources/Plasma/FeatureLib/pfMessage/pfGUINotifyMsg.h b/Sources/Plasma/FeatureLib/pfMessage/pfGUINotifyMsg.h index cc9b4e90..b42ea69c 100644 --- a/Sources/Plasma/FeatureLib/pfMessage/pfGUINotifyMsg.h +++ b/Sources/Plasma/FeatureLib/pfMessage/pfGUINotifyMsg.h @@ -84,6 +84,8 @@ public: kExitMode, // GUI Exit Mode key was pressed kInterestingEvent, // GUI interesting-ness has changed kSpecialAction, // meaning depends on control functionality (see below) + kMessageHistoryUp, // up key to scroll back in history + kMessageHistoryDown,// down key to scroll forward in history kEndEventList }; @@ -99,6 +101,8 @@ public: // kEditBox // kAction - enter key hit // kSpecialAction - tab key hit (for autocompletion on Python side) +// kMessageHistoryUp - up key hit +// kMessageHistoryDown - down key hit // kUpDownPair // kValueChanged - the value of the pair has been changed // kKnob