|
|
@@ -15,7 +15,7 @@
|
|
|
INLINE void ChatInput::
|
|
|
set_max_chars(int max_chars) {
|
|
|
_max_chars = max_chars;
|
|
|
- _has_max_chars = true;
|
|
|
+ _flags |= F_max_chars;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -26,7 +26,7 @@ set_max_chars(int max_chars) {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void ChatInput::
|
|
|
clear_max_chars() {
|
|
|
- _has_max_chars = false;
|
|
|
+ _flags &= ~F_max_chars;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -37,7 +37,7 @@ clear_max_chars() {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE bool ChatInput::
|
|
|
has_max_chars() const {
|
|
|
- return _has_max_chars;
|
|
|
+ return (_flags & F_max_chars) != 0;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -52,6 +52,111 @@ get_max_chars() const {
|
|
|
return _max_chars;
|
|
|
}
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::set_max_lines
|
|
|
+// Access: Public
|
|
|
+// Description: Sets a limit on the number of lines the user is
|
|
|
+// allowed to type. This makes sense only when wordwrap
|
|
|
+// is enabled on the TextNode; otherwise, it will always
|
|
|
+// be only one line. When this limit is exceeded, no
|
|
|
+// more characters will be accepted, and the event
|
|
|
+// "chat_overflow" is thrown.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void ChatInput::
|
|
|
+set_max_lines(int max_lines) {
|
|
|
+ _max_lines = max_lines;
|
|
|
+ _flags |= F_max_lines;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::clear_max_lines
|
|
|
+// Access: Public
|
|
|
+// Description: Removes the limit on the maximum number of
|
|
|
+// characters.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void ChatInput::
|
|
|
+clear_max_lines() {
|
|
|
+ _flags &= ~F_max_lines;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::has_max_lines
|
|
|
+// Access: Public
|
|
|
+// Description: Returns true if the maximum number of characters has
|
|
|
+// been set by a call to set_max_lines().
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE bool ChatInput::
|
|
|
+has_max_lines() const {
|
|
|
+ return (_flags & F_max_lines) != 0;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::get_max_lines
|
|
|
+// Access: Public
|
|
|
+// Description: If has_max_lines() returns true, this will return the
|
|
|
+// maximum number of characters that was set.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE int ChatInput::
|
|
|
+get_max_lines() const {
|
|
|
+ nassertr(has_max_lines(), 0);
|
|
|
+ return _max_lines;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::set_max_width
|
|
|
+// Access: Public
|
|
|
+// Description: Sets a limit on the total width of the line the user
|
|
|
+// is allowed to type. When this limit is exceeded, no
|
|
|
+// more characters will be accepted, and the event
|
|
|
+// "chat_overflow" is thrown.
|
|
|
+//
|
|
|
+// This is different than set_max_chars(), as some
|
|
|
+// letters use more width than others; capital W, for
|
|
|
+// instance, takes up more space than a lowercase i. It
|
|
|
+// only makes sense to set this option when wordwrap is
|
|
|
+// *off* for the TextNode. To limit the text length
|
|
|
+// with wordwrap on, use set_max_lines().
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void ChatInput::
|
|
|
+set_max_width(float max_width) {
|
|
|
+ _max_width = max_width;
|
|
|
+ _flags |= F_max_width;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::clear_max_width
|
|
|
+// Access: Public
|
|
|
+// Description: Removes the limit on the maximum number of
|
|
|
+// characters.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void ChatInput::
|
|
|
+clear_max_width() {
|
|
|
+ _flags &= ~F_max_width;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::has_max_width
|
|
|
+// Access: Public
|
|
|
+// Description: Returns true if the maximum number of characters has
|
|
|
+// been set by a call to set_max_width().
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE bool ChatInput::
|
|
|
+has_max_width() const {
|
|
|
+ return (_flags & F_max_width) != 0;
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: ChatInput::get_max_width
|
|
|
+// Access: Public
|
|
|
+// Description: If has_max_width() returns true, this will return the
|
|
|
+// maximum number of characters that was set.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE float ChatInput::
|
|
|
+get_max_width() const {
|
|
|
+ nassertr(has_max_width(), 0.0);
|
|
|
+ return _max_width;
|
|
|
+}
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: ChatInput::get_string
|
|
|
// Access: Public
|