mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
remove old chat library
This commit is contained in:
parent
2991a6562c
commit
7d0aea37ba
@ -1,22 +0,0 @@
|
||||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
dtoolutil:c dtoolbase:c dtool:m
|
||||
|
||||
#begin lib_target
|
||||
#define TARGET chat
|
||||
#define LOCAL_LIBS \
|
||||
putil dgraph display text event graph
|
||||
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
|
||||
|
||||
#define SOURCES \
|
||||
chatHelpers.h chatInput.I chatInput.h config_chat.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
chatHelpers.cxx chatInput.cxx config_chat.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
chatHelpers.h chatInput.I chatInput.h
|
||||
|
||||
#define IGATESCAN all
|
||||
|
||||
#end lib_target
|
@ -1,55 +0,0 @@
|
||||
// Filename: chatHelpers.cxx
|
||||
// Created by: mike (09Jan97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "chatHelpers.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: add_line_wraps
|
||||
// Description: Take an input string and format it so that lines
|
||||
// will wrap before they reach line_length (unless
|
||||
// there is no whitespace).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string add_line_wraps(const string& str, int line_length) {
|
||||
string new_str;
|
||||
string old_str = str;
|
||||
|
||||
if ((int)str.length() <= line_length)
|
||||
return old_str;
|
||||
|
||||
int length_so_far = 0;
|
||||
string::size_type ws;
|
||||
|
||||
do {
|
||||
ws = old_str.find(' ');
|
||||
string sub_str;
|
||||
if (ws != string::npos) {
|
||||
sub_str = old_str.substr(0, ws+1);
|
||||
old_str = old_str.substr(ws+1, string::npos);
|
||||
} else
|
||||
sub_str = old_str;
|
||||
int sub_str_len = sub_str.length();
|
||||
if (length_so_far + sub_str_len > line_length) {
|
||||
new_str += '\n';
|
||||
length_so_far = 0;
|
||||
}
|
||||
new_str += sub_str;
|
||||
length_so_far += sub_str_len;
|
||||
} while (ws != string::npos);
|
||||
|
||||
return new_str;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
// Filename: chatHelpers.h
|
||||
// Created by: mike (09Jan97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef CHATHELPERS_H
|
||||
#define CHATHELPERS_H
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#include <pandabase.h>
|
||||
|
||||
string add_line_wraps(const string& str, int line_length);
|
||||
|
||||
#endif
|
@ -1,182 +0,0 @@
|
||||
// Filename: chatInput.I
|
||||
// Created by: drose (04Jul00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::set_max_chars
|
||||
// Access: Public
|
||||
// Description: Sets a limit on the number of characters the user is
|
||||
// allowed to type. When this limit is exceeded, no
|
||||
// more characters will be accepted, and the event
|
||||
// "chat_overflow" is thrown.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ChatInput::
|
||||
set_max_chars(int max_chars) {
|
||||
_max_chars = max_chars;
|
||||
_flags |= F_max_chars;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::clear_max_chars
|
||||
// Access: Public
|
||||
// Description: Removes the limit on the maximum number of
|
||||
// characters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ChatInput::
|
||||
clear_max_chars() {
|
||||
_flags &= ~F_max_chars;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::has_max_chars
|
||||
// Access: Public
|
||||
// Description: Returns true if the maximum number of characters has
|
||||
// been set by a call to set_max_chars().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ChatInput::
|
||||
has_max_chars() const {
|
||||
return (_flags & F_max_chars) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::get_max_chars
|
||||
// Access: Public
|
||||
// Description: If has_max_chars() returns true, this will return the
|
||||
// maximum number of characters that was set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int ChatInput::
|
||||
get_max_chars() const {
|
||||
nassertr(has_max_chars(), 0);
|
||||
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
|
||||
// Description: Returns the current string the user has entered so
|
||||
// far.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &ChatInput::
|
||||
get_string() const {
|
||||
return _str;
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
// Filename: chatInput.cxx
|
||||
// Created by: mike (09Jan97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "chatInput.h"
|
||||
|
||||
#include "buttonEventDataTransition.h"
|
||||
#include "buttonEvent.h"
|
||||
#include "keyboardButton.h"
|
||||
#include "throw_event.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Static variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TypeHandle ChatInput::_type_handle;
|
||||
|
||||
TypeHandle ChatInput::_button_events_type;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
ChatInput::
|
||||
ChatInput(TextNode* text_node, const string& name) : DataNode(name) {
|
||||
assert(text_node != NULL);
|
||||
_text_node = text_node;
|
||||
_max_chars = 0;
|
||||
_max_lines = 0;
|
||||
_max_width = 0.0;
|
||||
_flags = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::reset
|
||||
// Access: Public
|
||||
// Description: Empties the string and prepares to accept new input;
|
||||
// does not reset the max_chars setting.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ChatInput::
|
||||
reset() {
|
||||
_str = "";
|
||||
_text_node->set_text(_str);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ChatInput::transmit_data
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ChatInput::
|
||||
transmit_data(AllTransitionsWrapper &data) {
|
||||
// Look for keyboard events.
|
||||
const ButtonEventDataTransition *b;
|
||||
if (get_transition_into(b, data, _button_events_type)) {
|
||||
ButtonEventDataTransition::const_iterator bi;
|
||||
for (bi = b->begin(); bi != b->end(); ++bi) {
|
||||
const ButtonEvent &be = (*bi);
|
||||
|
||||
if (be._down) {
|
||||
if (be._button == KeyboardButton::enter()) {
|
||||
throw_event("chat_exit");
|
||||
|
||||
} else if (be._button == KeyboardButton::backspace()) {
|
||||
if (!_str.empty()) {
|
||||
_str = _str.substr(0, _str.length()-1);
|
||||
_text_node->set_text(_str);
|
||||
}
|
||||
|
||||
} else if (be._button.has_ascii_equivalent()) {
|
||||
char ch = be._button.get_ascii_equivalent();
|
||||
|
||||
if (isprint(ch)) {
|
||||
if (!append_character(ch)) {
|
||||
throw_event("chat_overflow");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: init_type
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ChatInput::
|
||||
init_type(void) {
|
||||
DataNode::init_type();
|
||||
register_type(_type_handle, "ChatInput",
|
||||
DataNode::get_class_type());
|
||||
|
||||
ButtonEventDataTransition::init_type();
|
||||
register_data_transition(_button_events_type, "ButtonEvents",
|
||||
ButtonEventDataTransition::get_class_type());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: append
|
||||
// Access: Public
|
||||
// Description: Appends the indicated string to the end of the
|
||||
// currently typed string, as if it were typed by the
|
||||
// user. No bounds checking is performed.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ChatInput::
|
||||
append(const string &str) {
|
||||
_str += str;
|
||||
_text_node->set_text(_str);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: append_character
|
||||
// Access: Public
|
||||
// Description: Adds the indicated character to the end of the
|
||||
// string, as if it were typed. Bounds checking is
|
||||
// performed; the character must fit within the limits
|
||||
// set by set_max_chars(), set_max_width(), and
|
||||
// set_max_lines(). Returns true if the character fit
|
||||
// (and was appended correctly), or false if it did not
|
||||
// fit (in which case nothing is changed).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool ChatInput::
|
||||
append_character(char ch) {
|
||||
if (has_max_chars() && (int)_str.size() >= get_max_chars()) {
|
||||
// This is an easy test.
|
||||
return false;
|
||||
}
|
||||
|
||||
string text = _str + ch;
|
||||
if (_text_node->has_wordwrap()) {
|
||||
text =
|
||||
_text_node->wordwrap_to(text, _text_node->get_wordwrap(), false);
|
||||
}
|
||||
|
||||
if (has_max_width()) {
|
||||
nassertr(!_text_node->has_wordwrap(), false);
|
||||
|
||||
float width = _text_node->calc_width(text);
|
||||
if (width > get_max_width()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_max_lines()) {
|
||||
// Count up the number of lines in the text. This is one more
|
||||
// than the number of newline characters.
|
||||
int num_lines = 1;
|
||||
string::const_iterator pi;
|
||||
for (pi = text.begin(); pi != text.end(); ++pi) {
|
||||
if (*pi == '\n') {
|
||||
++num_lines;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_lines > get_max_lines()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_str += ch;
|
||||
_text_node->set_text(_str);
|
||||
return true;
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
// Filename: chatInput.h
|
||||
// Created by: mike (09Jan97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CHATINPUT_H
|
||||
#define CHATINPUT_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "dataNode.h"
|
||||
#include "pointerTo.h"
|
||||
#include "textNode.h"
|
||||
#include "allTransitionsWrapper.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ChatInput
|
||||
// Description : Reads keyboard input in as that of a chat.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ChatInput : public DataNode {
|
||||
PUBLISHED:
|
||||
ChatInput(TextNode* text_node, const string& name = "");
|
||||
void reset(void);
|
||||
|
||||
INLINE void set_max_chars(int max_chars);
|
||||
INLINE void clear_max_chars();
|
||||
INLINE bool has_max_chars() const;
|
||||
INLINE int get_max_chars() const;
|
||||
|
||||
INLINE void set_max_lines(int max_lines);
|
||||
INLINE void clear_max_lines();
|
||||
INLINE bool has_max_lines() const;
|
||||
INLINE int get_max_lines() const;
|
||||
|
||||
INLINE void set_max_width(float max_width);
|
||||
INLINE void clear_max_width();
|
||||
INLINE bool has_max_width() const;
|
||||
INLINE float get_max_width() const;
|
||||
|
||||
INLINE const string &get_string() const;
|
||||
|
||||
void append(const string &str);
|
||||
bool append_character(char ch);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// From parent class DataNode
|
||||
////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual void
|
||||
transmit_data(AllTransitionsWrapper &data);
|
||||
AllTransitionsWrapper _attrib;
|
||||
// inputs
|
||||
static TypeHandle _button_events_type;
|
||||
|
||||
protected:
|
||||
PT(TextNode) _text_node;
|
||||
string _str;
|
||||
int _max_chars;
|
||||
int _max_lines;
|
||||
float _max_width;
|
||||
|
||||
enum Flags {
|
||||
F_max_chars = 0x001,
|
||||
F_max_lines = 0x002,
|
||||
F_max_width = 0x004,
|
||||
};
|
||||
int _flags;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type();
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "chatInput.I"
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
|
||||
#include "config_chat.cxx"
|
||||
#include "chatHelpers.cxx"
|
||||
#include "chatInput.cxx"
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Filename: chat_headers.h
|
||||
// Created by: georges (30May01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "chatInput.h"
|
||||
|
||||
#pragma hdrstop
|
||||
|
@ -1,28 +0,0 @@
|
||||
// Filename: config_chat.cxx
|
||||
// Created by: drose (04May00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "chatInput.h"
|
||||
#include "config_chat.h"
|
||||
#include <dconfig.h>
|
||||
|
||||
Configure(config_chat);
|
||||
NotifyCategoryDef(chat, "");
|
||||
|
||||
ConfigureFn(config_chat) {
|
||||
ChatInput::init_type();
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
// Filename: config_chat.h
|
||||
// Created by: drose (04May00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CONFIG_CHAT_H
|
||||
#define CONFIG_CHAT_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <notifyCategoryProxy.h>
|
||||
|
||||
NotifyCategoryDecl(chat, EXPCL_PANDA, EXPTP_PANDA);
|
||||
|
||||
#endif
|
@ -26,15 +26,6 @@
|
||||
|
||||
#end bin_target
|
||||
|
||||
#begin test_bin_target
|
||||
#define TARGET chat
|
||||
#define LOCAL_LIBS $[LOCAL_LIBS] chat
|
||||
|
||||
#define SOURCES \
|
||||
chat_test.cxx
|
||||
|
||||
#end test_bin_target
|
||||
|
||||
#begin test_bin_target
|
||||
#define TARGET downloader
|
||||
|
||||
|
@ -1,106 +0,0 @@
|
||||
// Filename: chat_test.cxx
|
||||
// Created by:
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <eventHandler.h>
|
||||
#include <chancfg.h>
|
||||
#include <textNode.h>
|
||||
#include <mouse.h>
|
||||
#include <graphicsWindow.h>
|
||||
#include <chatInput.h>
|
||||
#include <camera.h>
|
||||
#include <transformTransition.h>
|
||||
#include <lightTransition.h>
|
||||
#include <chatHelpers.h>
|
||||
#include <notify.h>
|
||||
#include <pt_NamedNode.h>
|
||||
#include <framework.h>
|
||||
#include <dataRelation.h>
|
||||
|
||||
PT(ChatInput) chat_input;
|
||||
PT(TextNode) input_text_node;
|
||||
PT(TextNode) output_text_node;
|
||||
|
||||
bool in_chat_mode = false;
|
||||
|
||||
extern int framework_main(int argc, char *argv[]);
|
||||
extern void (*define_keys)(EventHandler&);
|
||||
|
||||
void event_enter(CPT_Event) {
|
||||
if (!in_chat_mode) {
|
||||
nout << "Enter chat mode" << endl;
|
||||
chat_input->reset();
|
||||
new DataRelation(mak, chat_input);
|
||||
in_chat_mode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void event_chat_exit(CPT_Event) {
|
||||
if (in_chat_mode) {
|
||||
nout << "Exit chat mode" << endl;
|
||||
remove_child(mak, chat_input, DataRelation::get_class_type());
|
||||
output_text_node->set_text(chat_input->get_string());
|
||||
in_chat_mode = false;
|
||||
}
|
||||
}
|
||||
|
||||
void event_chat_overflow(CPT_Event) {
|
||||
nout << "Too many characters." << endl;
|
||||
}
|
||||
|
||||
void chat_keys(EventHandler& eh) {
|
||||
eh.add_hook("enter", event_enter);
|
||||
eh.add_hook("chat_exit", event_chat_exit);
|
||||
eh.add_hook("chat_overflow", event_chat_overflow);
|
||||
|
||||
PT_Node font = loader.load_sync("ttf-comic");
|
||||
|
||||
// Create the input text node
|
||||
input_text_node = new TextNode("input_text_node");
|
||||
input_text_node->set_billboard(false);
|
||||
input_text_node->set_font(font.p());
|
||||
input_text_node->set_text("Press Enter to begin chat mode.");
|
||||
input_text_node->set_wordwrap(12.0);
|
||||
RenderRelation *text_arc = new RenderRelation(cameras, input_text_node);
|
||||
LMatrix4f mat = LMatrix4f::scale_mat(0.25);
|
||||
mat.set_row(3, LVector3f(-3, 8, -1.4));
|
||||
text_arc->set_transition(new TransformTransition(mat));
|
||||
LightTransition *no_light = new LightTransition(LightTransition::all_off());
|
||||
text_arc->set_transition(no_light);
|
||||
|
||||
chat_input = new ChatInput(input_text_node, "chat input");
|
||||
chat_input->set_max_lines(2);
|
||||
|
||||
// Create the output text node
|
||||
output_text_node = new TextNode("output_text_node");
|
||||
output_text_node->set_billboard(true);
|
||||
output_text_node->set_font(font.p());
|
||||
output_text_node->set_text_color(0, 0, 0, 1);
|
||||
output_text_node->set_card_as_margin(0.2, 0.2, 0.2, 0.2);
|
||||
output_text_node->set_card_color(1, 1, 1, 1);
|
||||
output_text_node->set_align(TM_ALIGN_CENTER);
|
||||
output_text_node->set_wordwrap(10.0);
|
||||
output_text_node->set_text("Output text");
|
||||
|
||||
RenderRelation *out_arc = new RenderRelation(root, output_text_node);
|
||||
out_arc->set_transition(no_light);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
define_keys = &chat_keys;
|
||||
return framework_main(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user