text.h

来自「游戏编程精髓里的人工智能源代码很好的源代码!」· C头文件 代码 · 共 75 行

H
75
字号
/* Copyright (C) Steve Rabin, 2000.  * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Steve Rabin, 2000" *///===========================================================================//===========================================================================#ifndef _TEXT_H#define _TEXT_H#include <cstdio>#include <cstdarg>#ifdef _WIN32#include <win32.h>#endif#include "def.h"#define MAX_STR 4096#define TEXT_NONE 0x00#define TEXT_DRAW_BOX 0x04#define TEXT_DRAW_SPACES 0x02#define TEXT_WRAP_SPACES 0x08#define TEXT_DRAW_BACKGROUND 0x01class TextBox {public:	TextBox(int boxL, int boxR, int boxT, int boxB);private:	// Bounding Box	int boxL;	int boxR;	int boxT;	int boxB;	// Text Buffers	char * buffer;	char * drawBufferPtr;	// Info	int pageLineCnt;	int scrollCnt;	int currX;	int currY;	COLOR color;public:	unsigned int mode;public:	void Begin();	void End();	void DrawStr(u16 x, u16 y, char* string);	void Draw();	void Printf(char* fmt, ...);	void Clear() {buffer[0] = '\0';};	void SetColor(COLOR colorIn) {color = colorIn;};	void SetMode(unsigned int modeIn) {mode = modeIn;};	void PageUp() {scrollCnt += pageLineCnt;};	void PageDown() {scrollCnt -= pageLineCnt; if (scrollCnt < 0) scrollCnt = 0;};	void PageReset() {scrollCnt = 0;};private:	void Paginate();		void DrawStr(u16 x, u16 y, u16 maxFlag, u16 maxY, char* string);	void DrawBoundingBox();	void FormatStrCat(char * str);};#endif 

⌨️ 快捷键说明

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