⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statusbar.h

📁 MudMaster 2000 的C++源码
💻 H
字号:
/************************************************************************************
	Copyright (c) 2000 Aaron O'Neil
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions
	are met:

		1) Redistributions of source code must retain the above copyright notice, 
				this list of conditions and the following disclaimer.
		2) Redistributions in binary form must reproduce the above copyright notice, 
				this list of conditions and the following disclaimer in the documentation
				and/or other materials provided with the distribution.
		3) Redistributions in binary form must reproduce the above copyright notice on
				program startup. Additional credits for program modification are acceptable
				but original copyright and credits must be visible at startup.
		4) You may charge a reasonable copying fee for any distribution of Mud Master. 
				You may charge any fee you choose for support of Mud Master. You may not 
				charge a fee for Mud Master itself.

  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
	THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**************************************************************************************/

#define DEFAULT_BAR_ARRAY_SIZE	100
#define DEFAULT_BAR_GROW_SIZE		10

struct BAR_ITEM
{
	CString	strItem;		// Name of this item.
	CString	strText;		// Text to display
	int		nLen;			// Max display len
	int		nPos;			// XPos on the bar.
	int 		nFore;		// Foreground attribute.
	int 		nBack;		// Background attribute.
	WORD		wColor;		// Color of the item. 0 to use bar colors.
	BOOL		bSeparator;	// TRUE if this is a separator.
	CString	strGroup;
	BOOL		bEnabled;
};

class CStatusBar
{
public:
	CStatusBar();
	~CStatusBar();

	// Draws the status bar on the screen.  Takes care of adjusting
	// the scrolling lines of the mud window as well as moving the
	// input bar.
	void ShowBar(int nPos);

	// Hides the bar, adjusts the input bar position and number of
	// scrolling lines.
	void HideBar();

	// Redraw the whole status bar and all the items.
	void Redraw();

	void DrawItem(BAR_ITEM *pItem);

	void SetBarFore(int nColor);
	void SetBarBack(int nColor);

	int  GetBarFore()			{ return(m_nFore); }
	int  GetBarBack()			{ return(m_nBack); }

	void SetBarItemFore(BAR_ITEM *pItem, int nColor);
	void SetBarItemBack(BAR_ITEM *pItem, int nColor);

	void ShiftItems(int nStart, int nEnd, int nNum);

	int AddBarItem(const char *pszItem, const char *pszText, int nPos,
		int nLen, int nFore, int nBack, const char *pszGroup);
	int AddSeparator(const char *pszItem, int nPos, const char *pszGroup);

	BOOL Remove(const char *pszItem);
	BOOL Remove(int nIndex);

	BAR_ITEM* GetFirst();
	BAR_ITEM* GetNext();
	BAR_ITEM* GetAt(int nIndex);
	BAR_ITEM* FindItem(const char *pszItem);

	int GetCount()			{ return(m_nCount); }
	int GetFindIndex()	{ return(m_nGetIndex); }

	void RemoveAll();
	int RemoveGroup(const char *pszGroup);

	int DisableGroup(const char *pszGroup);
	int EnableGroup(const char *pszGroup);

private:
	CScreen m_screen;

	// The line to draw the status bar on.
	int m_nLine;

	// Color of the status bar.
	int  m_nFore;
	WORD m_wFore;
	int  m_nBack;
	WORD m_wBack;
	WORD m_wAttr;

	// TRUE when showing.
	BOOL m_bShowing;

	// Whether above or below the status bar.
	int m_nPosition;

	// Keps track of the bar items.
	CPtrArray m_ptrList;
	int m_nCount;
	int m_nGetIndex;

	// Pass in a number from 0 to 7, returns the color attribute.
	WORD BackColorAttribute(int nColor);
	// Pass in a number from 0 to 15, returns the color attribute.
	WORD ForeColorAttribute(int nColor);
};

⌨️ 快捷键说明

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