diff --git a/src/framework/platform/platformevent.h b/src/framework/platform/platformevent.h index 748ccc09..ee5978a9 100644 --- a/src/framework/platform/platformevent.h +++ b/src/framework/platform/platformevent.h @@ -25,6 +25,7 @@ #include +//TODO: move the next enums to const.h enum InputKeyCode { KC_UNKNOWN = 0x00, KC_ESCAPE = 0x01, @@ -196,6 +197,7 @@ enum PlatformEventType { EventMouseWheelDown = EventMouseAction | EventMouseWheel | EventDown }; +//TODO: rework platform events, make more compatible with UI events struct PlatformEvent { int type; Point mousePos; diff --git a/src/framework/ui/uilineedit.cpp b/src/framework/ui/uilineedit.cpp index 2d1bf477..37b4462b 100644 --- a/src/framework/ui/uilineedit.cpp +++ b/src/framework/ui/uilineedit.cpp @@ -274,8 +274,27 @@ void UILineEdit::setCursorEnabled(bool enable) update(); } +void UILineEdit::appendText(std::string text) +{ + if(m_cursorPos >= 0) { + // replace characters that are now allowed + boost::replace_all(text, "\n", ""); + boost::replace_all(text, "\r", " "); + + if(text.length() > 0) { + m_text.insert(m_cursorPos, text); + m_cursorPos += text.length(); + blinkCursor(); + update(); + } + } +} + void UILineEdit::appendCharacter(char c) { + if(c == '\n' || c == '\r') + return; + if(m_cursorPos >= 0) { std::string tmp; tmp = c; @@ -384,6 +403,8 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers) setCursorPos(0); else if(keyCode == KC_END) // move cursor to last character setCursorPos(m_text.length()); + else if(keyCode == KC_V && keyboardModifiers == Fw::KeyboardCtrlModifier) + appendText(g_platform.getClipboardText()); else if(keyCode == KC_TAB) { if(UIWidgetPtr parent = getParent()) parent->focusNextChild(Fw::TabFocusReason); diff --git a/src/framework/ui/uilineedit.h b/src/framework/ui/uilineedit.h index 0a848116..70c625d5 100644 --- a/src/framework/ui/uilineedit.h +++ b/src/framework/ui/uilineedit.h @@ -41,6 +41,7 @@ public: void clearText() { setText(""); } void moveCursor(bool right); + void appendText(std::string text); void appendCharacter(char c); void removeCharacter(bool right); diff --git a/src/otclient/const.h b/src/otclient/const.h index f42463f5..f64cd68d 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -27,6 +27,9 @@ namespace Otc { + static const char* AppName = "OTClient"; + static const char* AppVersion = "0.4.0"; + static const char* CipsoftPublicRSA = "1321277432058722840622950990822933849527763264961655079678763618" "4334395343554449668205332383339435179772895415509701210392836078" "6959821132214473291575712138800495033169914814069637740318278150" diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index fcef4db6..c63fcf50 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -46,10 +46,10 @@ void OTClient::init(std::vector args) m_stopping = false; // print client information - logInfo("OTClient 0.2.0"); + logInfo(Otc::AppName, " ", Otc::AppVersion); // initialize platform related stuff - g_platform.init(this, "OTClient"); + g_platform.init(this, Otc::AppName); // initialize script environment g_lua.init(); @@ -72,7 +72,7 @@ void OTClient::init(std::vector args) int windowHeight = Fw::fromstring(g_configs.get("window height"), minHeight); bool maximized = Fw::fromstring(g_configs.get("window maximized"), false); g_platform.createWindow(windowX, windowY, windowWidth, windowHeight, minWidth, minHeight, maximized); - g_platform.setWindowTitle("OTClient"); + g_platform.setWindowTitle(Otc::AppName); // initialize graphics g_graphics.init();