Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 11/20/26 18:10
FXCM => AVA Trade Plugin???
by Martin_HH. 11/17/26 17:02
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
Removing outliers from files
by jcl. 11/04/26 10:30
[MED] Import from FBX (2010) missing!!!
by rayp. 11/03/26 14:33
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (AndrewAMD, LucasJoshua, EW_bytes, 1 invisible), 39,613 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rht, MaliceTheMaker, Haitao_Ren, JimSimons, julienp
19249 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Wanted to share my OOP C++ InputBox Class #232032
10/18/08 22:51
10/18/08 22:51
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
I'm working on this class to make/customize my own gui stuff.
This is the first working example.
The constructor takes all the args so u'd define it like so:

Code:
NG_InputBox mybox(_VAR(0),_VAR(50),_str("LoginID->"),_VAR(24),_VAR(3));


Then in your main loop you'd just call its Process_Keys method
(if you want it processed ie: if(keyactive == true) {mybox.processkeys();} etc,,etc...)

anyway here is the well working w/ keythrottle but nowhere near finished NewGoo.h

Code:
//Written Specifically for 3DGS 7 
//MUST BE INCLUDED AFTER adll.h to function.

class NG_InputBox {
public:
	NG_InputBox(var x,var y,STRING* Label,var maxlen,var layer);
	void ProcessKeys();
	void NG_InputBox::SetPos(var x,var y);
	TEXT* tInput;
	bool allow_space;
	STRING* entrytxt;
	STRING* entrytxt2;
	var MaxLen;
	PANEL* pIB;
	TEXT* tInputLabel;
	int entry;
	//Detour Loop
	var typerate;	

};

NG_InputBox::NG_InputBox(var x,var y,STRING* Label,var maxlen,var layer) {
	allow_space = 1; //Set to zero for NO SPACES (ie: usernames, email addresses, etc.. :) duh
	entry = 1;
	typerate = 0;
	entrytxt=str_create(" ");
	entrytxt2=str_create(" ");
	str_cpy(entrytxt,"");
	MaxLen = maxlen;
	tInputLabel = txt_create(_VAR(1),layer);
	tInput = txt_create(_VAR(1),layer);
	tInputLabel->pos_x = x ;
	tInputLabel->pos_y = y + _VAR(8);
	tInput->pos_x = x + 8 * (str_len(_chr(Label))-3);
	tInput->pos_y = y + _VAR(8);
	str_cpy(tInputLabel->pstring[0],_chr(Label));
	pIB = pan_create("bmap = ng_Dialog.bmp;",1);
	pIB->flags |= VISIBLE;
	pIB->flags |= OVERLAY;
	tInputLabel->flags |= VISIBLE;
	tInput->flags |= VISIBLE;
	pIB->pos_x  = x;
	pIB->pos_y  = y;
	pIB->scale_x = (_VAR(8) * (str_len(_chr(Label)) + maxlen)) / bmap_width(pIB->bmap);
	pIB->scale_y = _VAR(0.05);
};

void NG_InputBox::SetPos(var x,var y) {
	pIB->pos_x  = x;
	pIB->pos_y  = y;
	tInputLabel->pos_x = x ;
	tInputLabel->pos_y = y + _VAR(8);
	tInput->pos_x = x + 8 * (str_len(_chr(tInputLabel->pstring[0]))-3);
	tInput->pos_y = y + _VAR(8);
}

void NG_InputBox::ProcessKeys() {
	typerate += v(time_step);
	if (entry == 1 && v(key_any)  ) {
		str_cpy(entrytxt2,_chr(entrytxt));
		if (v(key_lastpressed) != _VAR(78) && v(key_lastpressed) != _VAR(76) && v(key_lastpressed) != _VAR(53) && v(key_lastpressed) != _VAR(55) && v(key_lastpressed) != _VAR(74)) {
			entrytxt=str_for_key(NULL,v(key_lastpressed));
		} else {
			entrytxt=str_for_key(NULL,_VAR(41));
		}
		if (str_cmp(entrytxt,_chr(entrytxt2)) && typerate <= (v(time_step) * 200) ) {
			//str_cpy(tDebug->pstring[0],"TYPERATE/TIME_STEP ");
			//str_cat_num(tDebug->pstring[0],"= %f",typerate); 
			//str_cat_num(tDebug->pstring[0],"/%f",v(time_step)); 
		} else {
			typerate = v(time_step);
			if (str_len(_chr(entrytxt)) < _VAR(2) && str_len(_chr(entrytxt)) > _VAR(0)) {
				if (str_len(_chr(tInput->pstring[0])) < MaxLen) {
					str_cat(tInput->pstring[0],_chr(entrytxt));
				} else {
					//str_cpy(tDebug->pstring[1],"MAXIMUM LENGTH REACHED!");
				}
			} else {
				if (str_cmp(entrytxt,"bksp")){
					//str_cpy(tDebug->pstring[0],"");
					if (str_len(_chr(tInput->pstring[0])) > _VAR(0)) {
						str_trunc(tInput->pstring[0],_VAR(1));
					}
				} else if (str_cmp(entrytxt,"space")){
					if(allow_space){  //if
						str_cat(tInput->pstring[0]," "); //do it
					} else {
						//umm... dont
					}
					//str_cpy(tDebug->pstring[1],"NO SPACES PLEASE");
				} else {
					//str_cpy(tDebug->pstring[1],"Discarded KeyStr : ");
					//str_cat(tDebug->pstring[1],_chr(entrytxt));
				}
			}
		}
	}
}


L8rz,
Neurosys


See more code and crap @ www.neuroticnetworks.com
Re: Wanted to share my OOP C++ InputBox Class [Re: Neurosys] #232182
10/20/08 00:35
10/20/08 00:35
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
ok so, this is clearly not finished working on this next... but i did get my socket code implemented... see my next post...


See more code and crap @ www.neuroticnetworks.com

Moderated by  TWO 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1