DPrint Source Code

Posts 1–7 of 7 · Page 1 of 1
DPrint Source Code

Print
DPrint Source Code v.1.0


Created By: why06 For: MPGH.net


My hope is for this Project to be open source. So I've included the code below. This way people can contribute code as well as take away code for their own use.

Code:
	//********************************************************************************
	//funtion:	DPrint()
	//purpose:	Contructs new Dprint object
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//startx:	The beginning x screen coordinate for Println
	//starty:	The beginning y screen coordinate for Println
	//vertical_spacing:	The vertical spacing between each subsequent line using Println
	//pdevice:	The D3D Device
	//********************************************************************************
	DPrint(int startx, int starty, int vertical_spacing, LPDIRECT3DDEVICE9 pdevice);
	/*Creates with autoFilter Settings*/
	//autoFilter:	Turn auto filter on or off
	//filterTime:	the frequency of auto filtration
	DPrint(int startx, int starty, int vertical_spacing, LPDIRECT3DDEVICE9 pdevice, bool autoFilter, UINT filterTime=10000);
	
	//********************************************************************
	//function: TestPrint
	//purpose:	Tests boundaries of a line of text, preparing to be written.
	//returns:	An array of RECTs holding the calculated size of each character 
	//			block in the text and the whole length of the text.
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//Rectarr:	An array of RECT that one must past to the function which will 
	//			be filled with the location, width and height of each character printed
	//pFormat:	A reference to the Format which holds one's font preferences
	//str:		The string to test.
	//********************************************************************
	void TestPrintln(RECT* Rectarr, LPFFORMAT pFormat, char* str);

	//*******************************************************************************************
	//function:	CalcConcat
	//purpose:	will return the least amount of letters that must be erased for a string in order
	//			for that string to be concatenated with a new string and still fit in the pixel
	//			limitations supplied.
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//Rectarr:	An array of RECT that one must past to the function which will 
	//			be filled with the location, width and height of each character printed.
	//bufout:	bufin will be concatenated to this string.
	//bufin:	The initial string to be concatenated.
	//maxpixwidth:	The concatenated string will not be longer then maxpixwidth, if it is the string 
	//				will be shortened until it fits within the horizontal limitations of maxpixwidth.
	//pFormat:	Naturally different fonts take up different amounts of screen realistate, so one must
	//			specify which font is to be made to fit in maxpixwidth.
	//*******************************************************************************************
	int CalcConcat(RECT* RectArr, char* bufout, char* bufin, int maxpixwidth, LPFFORMAT pFormat);

	//*********************************************************************
	//funtion: Println
	//purpose: Will print a new line of text to screen 
	//returns: A reactangle holding the size of the text drawn in Rectptr
	//remarks: Starts at the locations specified by startx and starty. On each call
	//		   the cursor moves down vertically vspacing pixels until ResetCursor is
	//		   called which resets the cursor.
	//
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//Rectarr:	An array of RECT that one must past to the function which will 
	//			be filled with the location, width and height of each character printed.
	//fontColor:The color for the text to be printed.
	//pFormat:	The Format for the text to be printed
	//str:		The text to be printed.
	//*********************************************************************
	void Println(RECT* Rectptr, D3DCOLOR fontColor, LPFFORMAT pFormat, char* str);

	//*********************************************************************
	//funtion: Print
	//purpose: Will print text to the size of the RECT provided
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//rbox:		A reference to a RECT. Holds coordinates for text to be printed
	//fontColor:The color for the text to be printed.
	//pFormat:	The Format for the text to be printed.
	//str:		The text to be printed.
	//*********************************************************************
	void Print(RECT* rbox, D3DCOLOR fontColor, LPFFORMAT pFormat, char* str);
	
	//*******************************************************
	// function: DrawBox
	// purpose: Will draw a box based on dimensions and color specified.
	// NOTE: Not mine. Leeched code.
	//*******************************************************
	void DrawBox(int x, int y, int w, int h, D3DCOLOR col);

	//********************************************************
	// function: TextBox
	// purpose: Will try to draw text in the given RECT
	/////////////////////////////PARAMETERS///////////////////////////////////////////////
	//Rectarr:		An array of RECT that one must past to the function which will 
	//				be filled with the location, width and height of each character printed.
	//FormatRect:	A reference to a RECT. Holds coordinates for text to be printed.
	//text:			Text to be printed.
	//pFormat:		The Format for the text to be printed.
	//inside:		Color of inside of textbox.
	//border:		Color of border of textbox.
	//textcol:		Color of text to be printed in box.
	// *******************************************************
	void TextBox(RECT* Rectptr, RECT* FormatRect, string text, LPFFORMAT pFormat,  D3DCOLOR inside, D3DCOLOR border, D3DCOLOR textcol);


//Font Functions
	void Filter();											//manual filter
	void SetFilter(bool autoFilter, UINT cycletime = 10000);//automatic filter settings

//Set Functions
	void SetCursor(int newx, int newy);	//Set X and Y coords for text printing
	void ResetCursor();					//sets Println cursor back to starty and startx.
	void Setvspc(int vertical_spacing); //change vertical spacing.

//Get Functions
	int getx();//startx
	int gety();//starty
	int getvspc();// get vertical spacing

//Resets Font Pointers
	void PreReset();	//OnLostDevice
	void PostReset();	//OnResetDevice

//RECT HELPERS
	static RECT* rectcpy(RECT* out, RECT* in); 
	static int rectw(RECT* in);	//width
	static int recth(RECT* in);	//height

//TEXT HELPERS
	// a bit misleading. Does not tick all the way through only to end of text. Does not loop.
	static int TickerText(char* strin, char* strout, unsigned int constraint, int wait, int time);
DPrintTestApp.rarattachment deleted · 155 downloads before removal
DPrintLibrary.rarattachment deleted · 124 downloads before removal
Moved to DirectX and Stickied
Thanks Next.
Not a problem, I am always for long term projects that are open source and have potential.

Maybe we should make our own Open Source Project Site for MPGH
very thanks !
Hmmm... just looked back at this after all these years. I used an atrocious ordinal system in the code to access each font by a unique number value. I could have just used a multi-dimensional array with the Font size, weight, color, etc. representing specific indexes in the array.
Quote Originally Posted by why06 View Post
Hmmm... just looked back at this after all these years. I used an atrocious ordinal system in the code to access each font by a unique number value. I could have just used a multi-dimensional array with the Font size, weight, color, etc. representing specific indexes in the array.
Sounds gay.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us