chanim.h

来自「Windows上的MUD客户端程序」· C头文件 代码 · 共 467 行 · 第 1/2 页

H
467
字号
/*----------------------------------------------------------------------------
                        _                              _ _       
        /\             | |                            | (_)      
       /  \   _ __   __| |_ __ ___  _ __ ___   ___  __| |_  __ _ 
      / /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
     / ____ \| | | | (_| | | | (_) | | | | | |  __/ (_| | | (_| |
    /_/    \_\_| |_|\__,_|_|  \___/|_| |_| |_|\___|\__,_|_|\__,_|

    The contents of this file are subject to the Andromedia Public
	License Version 1.0 (the "License"); you may not use this file
	except in compliance with the License. You may obtain a copy of
	the License at http://www.andromedia.com/APL/

    Software distributed under the License is distributed on an
	"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
	implied. See the License for the specific language governing
	rights and limitations under the License.

    The Original Code is Pueblo client code, released November 4, 1998.

    The Initial Developer of the Original Code is Andromedia Incorporated.
	Portions created by Andromedia are Copyright (C) 1998 Andromedia
	Incorporated.  All Rights Reserved.

	Andromedia Incorporated                         415.365.6700
	818 Mission Street - 2nd Floor                  415.365.6701 fax
	San Francisco, CA 94103

    Contributor(s):
	--------------------------------------------------------------------------
	   Chaco team:  Dan Greening, Glenn Crocker, Jim Doubek,
	                Coyote Lussier, Pritham Shetty.

					Wrote and designed original codebase.

------------------------------------------------------------------------------

	Interface for the ChAnimView class.

----------------------------------------------------------------------------*/

// $Header: /home/cvs/chaco/modules/client/msw/ChGraphx/ChAnim.h,v 2.11 1996/07/02 19:41:13 pritham Exp $

#include "grheader.h"
#if !defined( _CHANIM_H )
#define _CHANIM_H

#include <ChHook.h>
#include <ChGraphx.h>
#include "ChGrVw.h"
#include <ChSplay.h>
#include "ChSpritN.h"
#include "ChSprite.h"
#include "ChSpLstN.h"
#include "ChSprLst.h"
#include "ChPhSprt.h"
#include <fstream.h>
//#include <ChDibImage.h>
#include <ChDibBmp.h>

#define CH_ANIM_SCRIPT_GO_TO  -2
#define CH_ANIM_SCRIPT_STOP  -1

/*----------------------------------------------------------------------------
	ChAnimView class	-- enhanced graphic view for graphic module
----------------------------------------------------------------------------*/

class ChAnimView;
class ChAnimAnchor;
class ChAnimCastMember;
								// make it a class and it can serialize itself ??
								// ought to be able to do loops in a character's
								// script, maybe by using a union or special
								// value.
#if 0
typedef struct _ChCell {
    int x;
    int y;
    int z;
	int	sprite;	// sprite id ??
    int row;
    int col;
    //CWave* pSnd;   // needs to be id ?
} ChCell;

Moved ChCell class to ChGraphx.h - needed by messages

#endif
 
								 // ChAnimAnchor is a hotspot which initiates
								 // character action, some sort of 
								 // message to callback. (Module can then 
								 // do as it wishes. It also posts a CH_MSG_ANCHOR
								 // to m_moduleId
class ChAnimAnchor
{
	CH_FRIEND_MESSAGE_HANDLER( animatorLoadAnchorHandler );
	CH_FRIEND_MESSAGE_HANDLER( graphicPaletteChangeHandler );

	friend class ChAnimCastMember;
	friend class ChAnimView;

	public:
		typedef enum { rect = 1, cast } type;

	public:
		ChAnimAnchor();
		ChAnimAnchor( chuint32 id, CRect& rcHot );
		ChAnimAnchor( chuint32 id, chuint32 hotCastId );
	
		virtual ~ChAnimAnchor();

	public:
	    inline void SetId( chuint32 id ) { m_id = id; }
	    inline void SetRect(CRect& rcHot) { m_type = rect; m_rcHot = rcHot; }
		chuint32 GetId( ) { return m_id; }; 
	    CRect& GetRect() {return m_rcHot; };
		string& GetHint() { return m_strHint; };
		inline chuint32 GetCursorId() { return m_cursor; };

		void SetHint( string & strHint ) {m_strHint = strHint;};
		void SetCmd( string & strCmdArg ) {m_strCmdArg = strCmdArg;};
		void SetCast( chuint32 castId ) {m_pCast = 0; m_castId = castId;};
		void SetStartFrame( chint32 lStartCell ) {m_lStartCell = lStartCell;};
		inline void SetCursorId( chuint32 cursor ) {m_cursor = cursor;};
		void SetCursor( string& cursorName );
		inline type GetType() { return m_type; };
		inline chuint32 GetHotCastId() { return m_hotCastId; }
		inline void SetHotCastId(chuint32 hotCastId) { m_type = cast; m_pHotCast = 0; m_hotCastId = hotCastId; }
		inline ChAnimCastMember * GetHotCast() { return m_pHotCast; }
		inline chuint32 GetCastId() const { return m_castId; }
		inline ChAnimCastMember * GetCast();

		inline ChAnimView * GetView() const { return m_pView; }

		// called by view; pt is in image coordinates
		bool HitTest(const CPoint & pt ) const
			{
				return m_rcHot.PtInRect(*LPPOINT(&pt));	// Test point for containment
			};

		//  called if Anchored
		virtual bool Notify(CPoint &point);	// derive to get this notification
		virtual bool Post(CPoint &point);

		#if 0
		void Serialize(ChArchive& archive)
			{
				if( archive.GetMode() == modeRead )
				{
					archive >> m_id;
					archive >> (chint32)m_rcHot.TopLeft().x;
					archive >> (chint32)m_rcHot.TopLeft().y;
					archive >> (chint32)m_rcHot.BottomRight().x;
					archive >> (chint32)m_rcHot.BottomRight().y;
					archive >> m_moduleId;
					archive >> m_strHint;
				}
				else
				{
					// oughta do something for versions??????
					archive << m_id;
					archive << (chint32)m_rcHot.TopLeft().x;
					archive << (chint32)m_rcHot.TopLeft().y;
					archive << (chint32)m_rcHot.BottomRight().x;
					archive << (chint32)m_rcHot.BottomRight().y;
					archive << m_moduleId;
	 				archive << m_strHint;
				}
			}
		#endif

    protected:
		void SetView( ChAnimView *const pView )
				{
					m_pView = pView;
				}

    protected:
											// Anchoring objects
		type				m_type;
		chuint32			m_id;
	    CRect 				m_rcHot;	  	//  a 'union' class of ChAnimCastMember and rect
	    ChAnimCastMember*	m_pHotCast;
		chuint32			m_hotCastId;	// for as-yet unloaded

											// resultant objects
	    ChAnimCastMember*	m_pCast;		// only fill in if used
		chuint32			m_castId;	  	// for as-yet unloaded; null means none
	    chint32				m_lStartCell;	// mandatory if cast supplied

											//  messaging
		//ChModuleID		m_moduleId;
		string				m_strCmdArg;
											// user feedback
		string				m_strHint;
		chuint32			m_cursor;
											/* Set the view when added to a
												view, so it's available to
												notifyees */
		ChAnimView*			m_pView;
};

typedef ChAnimAnchor *pChAnimAnchor;




class ChCharacter						 // thought we needed this, but whatever . . .
{
	public:
		//ChCharacter();
		//virtual ~ChCharacter();
		virtual bool Tick(chuint32 luCurrMsec) = 0; 			// Move one step
		virtual void GetBounds(CRect* pRect) = 0;	// return bounding rect
		virtual void Draw(CDC * pDC ) = 0;	// draw yourself to DC
		virtual bool HitTest(const CPoint & pt ) = 0;	// Test point for containment

};

class ChAnimParser;
class ChAnimCastMember : public ChCharacter
{

	friend class ChAnimParser;

	public:
		ChAnimCastMember(chuint32 luId = 1);
		virtual ~ChAnimCastMember();
		virtual bool Tick(chuint32 luCurrMsec); 			// Move one step
		virtual void GetBounds(CRect* pRect);	// return bounding rect
		virtual void Draw(CDC * pDC );	// draw yourself to DC
		virtual bool HitTest(const CPoint & pt );	// Test point for containment
		void	Show( bool boolVisible = true );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?