r667 - trunk/game

black at icculus.org black at icculus.org
Wed Mar 8 15:40:12 EST 2006


Author: black
Date: 2006-03-08 15:40:12 -0500 (Wed, 08 Mar 2006)
New Revision: 667

Modified:
   trunk/game/m_menucore.c
   trunk/game/m_menucore.h
Log:
First round:
Changed the menucore to use the N* types and added a Menu_Rect struct
to replace the various anonymous struct declarations.


Modified: trunk/game/m_menucore.c
===================================================================
--- trunk/game/m_menucore.c	2006-03-08 17:15:53 UTC (rev 666)
+++ trunk/game/m_menucore.c	2006-03-08 20:40:12 UTC (rev 667)
@@ -89,7 +89,7 @@
 void Menu_Generic_MouseMoveSelectable(void *item, Menu_Inheritance *inh)
 {
 	Menu_Item *thisi = item;
-	int j;
+	NUint j;
 
 	for (j = 0; j < 2; j++)
 	{
@@ -98,8 +98,7 @@
 	}
 
 	if (thisi->parent->selecteditem != thisi)
-
-	thisi->parent->selecteditem = thisi;	//mouse is in us.	
+		thisi->parent->selecteditem = thisi;	//mouse is in us.	
 }
 void Menu_Generic_MouseMoveNonSelectable(UNUSED void *item, UNUSED Menu_Inheritance *inh)
 {	
@@ -121,7 +120,7 @@
 
 	Mem_Free(&item);
 }
-Menu_Item *Menu_CreateGenericItem(Menu_SubMenu *parent, int x, int y, int bytes)
+Menu_Item *Menu_CreateGenericItem(Menu_SubMenu *parent, NSint x, NSint y, NSint bytes)
 {
 	Menu_Item *it;
 	it = Mem_Alloc(Menu.menu_zone, bytes);
@@ -173,7 +172,7 @@
 	}
 	return false;
 }
-Menu_TextItem *Menu_CreateTextItem(Menu_SubMenu *parent, int x, int y, char *text, void *command, void (*UseTextItem) (struct Menu_TextItem *item))
+Menu_TextItem *Menu_CreateTextItem(Menu_SubMenu *parent, NSint x, NSint y, char *text, void *command, void (*UseTextItem) (struct Menu_TextItem *item))
 {
 	Menu_TextItem *it;
 	it = (Menu_TextItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_TextItem));
@@ -284,7 +283,7 @@
 	}
 	return false;
 }
-Menu_EditItem *Menu_CreateEditItem(Menu_SubMenu *parent, int x, int y, char *text)
+Menu_EditItem *Menu_CreateEditItem(Menu_SubMenu *parent, NSint x, NSint y, char *text)
 {
 	Menu_EditItem *it;
 	it = (Menu_EditItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_EditItem));
@@ -362,14 +361,15 @@
 
 Nbool Menu_Combo_KeyPress (void *item, UNUSED NUint mod, UNUSED NUint sym, UNUSED NUint character, UNUSED Nbool downevent)
 {
-	int i;
-	Menu_TextItem *txt;
-	Menu_ComboItem *thisi = item;
-	Menu_ComboOption *option;
-	Menu_SubMenu *interior;
-	int pixels;
 	if (sym == SDLK_RETURN || sym == MOUSE1)
 	{
+		Menu_TextItem *txt;
+		Menu_ComboItem *thisi = item;
+		Menu_ComboOption *option;
+		Menu_SubMenu *interior;
+		NSint pixels;
+		NUint i;
+
 		thisi->popup = Menu_CreateMenu(&Menu.rootmenu);
 		Menu_BringToFront(thisi->popup);
 		interior = Menu_CreateMenu(thisi->popup);
@@ -407,12 +407,8 @@
 	Menu_Generic_Destroy(item);
 }
 
-Menu_ComboItem *Menu_CreateComboItem(Menu_SubMenu *parent, int x, int y, int w, char *defalt, char *list)
+Menu_ComboItem *Menu_CreateComboItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, char *defalt, char *list)
 {
-	char *pipe;
-	int chars;
-	int ident;
-	Menu_ComboOption *option;
 	//list is pipe-sperated
 	Menu_ComboItem *it;
 	it = (Menu_ComboItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_ComboItem));
@@ -430,6 +426,10 @@
 
 	if (*list)
 	{
+		char *pipe;
+		NUint chars;
+		NSint ident;
+		Menu_ComboOption *option;
 		ident = 0;
 		for (pipe = list; ; pipe++)
 		{
@@ -480,7 +480,7 @@
 	}
 	return false;
 }
-Menu_PictureItem *Menu_CreatePictureItem(Menu_SubMenu *parent, int x, int y, int w, int h, char *imagename, char *command)
+Menu_PictureItem *Menu_CreatePictureItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, char *imagename, char *command)
 {
 	Menu_PictureItem *it;
 	it = (Menu_PictureItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_PictureItem));
@@ -513,7 +513,7 @@
 {
 	Menu_SliderItem *thisi = item;
 
-	float frac;
+	Nfloat frac;
 
 //	R_SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 //	R_SetColor(1, 1, 1, 1);
@@ -582,7 +582,7 @@
 	}
 	return false;
 }
-Menu_SliderItem *Menu_CreateHSliderItem(Menu_SubMenu *parent, int x, int y, int w, int h, float minv, float maxv, float defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data)
+Menu_SliderItem *Menu_CreateHSliderItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, Nfloat minv, Nfloat maxv, Nfloat defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data)
 {
 	Menu_SliderItem *it;
 	it = (Menu_SliderItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_SliderItem));
@@ -616,7 +616,7 @@
 void Menu_SliderV_Draw(void *item, Menu_Inheritance *inh)
 {
 	Menu_SliderItem *thisi = item;
-	float frac;
+	Nfloat frac;
 
 //	R_SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 //	R_SetColor(1, 1, 1, 1);
@@ -654,7 +654,7 @@
 	R_DrawString("A", 0, thisi->super.pos[0] + inh->addpos[0], thisi->super.pos[1] + inh->addpos[1], thisi->scale, thisi->scale, Console_DefaultColorTable, Console_DefaultColorTableSize, thisi->super.parent->selecteditem == &thisi->super);
 	R_DrawString("V", 0, thisi->super.pos[0] + inh->addpos[0], thisi->super.pos[1] + inh->addpos[1] - thisi->scale + (thisi->super.size[1]), thisi->scale, thisi->scale, Console_DefaultColorTable, Console_DefaultColorTableSize, thisi->super.parent->selecteditem == &thisi->super);
 }
-Menu_SliderItem *Menu_CreateVSliderItem(Menu_SubMenu *parent, int x, int y, int w, int h, float minv, float maxv, float defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data)
+Menu_SliderItem *Menu_CreateVSliderItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, Nfloat minv, Nfloat maxv, Nfloat defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data)
 {
 	Menu_SliderItem *it;
 	it = (Menu_SliderItem*)Menu_CreateGenericItem(parent, x, y, sizeof(Menu_SliderItem));
@@ -692,8 +692,7 @@
 	Menu_SubMenu *thisi = item;
 	Menu_Item *subitem;
 	Menu_Inheritance ninh;
-	int j;
-	int wmin, wmax;
+	NUint j;
 
 	if (Menu.grabs == &thisi->super && thisi->dragable)
 	{
@@ -708,6 +707,7 @@
 
 	for (j = 0; j < 2; j++)
 	{
+		NSint wmin, wmax;
 /*		if (Input.mouse[j] < thisi->subwindow.pos[j]+inh->addpos[j] || Input.mouse[j] > thisi->subwindow.pos[j]+inh->addpos[j] + thisi->subwindow.size[j])
 		{
 			thisi->indrag = false;
@@ -748,8 +748,7 @@
 	Menu_SubMenu *thisi = item;
 	Menu_Item *subitem, *next;
 	Menu_Inheritance ninh;
-	int wmin, wmax;
-	int j;
+	NUint j;
 
 	if (thisi->super.parent)
 	{
@@ -762,6 +761,7 @@
 
 	for (j = 0; j < 2; j++)
 	{
+		NSint wmin, wmax;
 		wmin = inh->addpos[j] + thisi->super.pos[j];
 		wmax = wmin + thisi->super.size[j];
 		if (wmin < inh->window.pos[j])
@@ -883,7 +883,7 @@
 void Menu_FinishMenu(Menu_SubMenu *menu)
 {
 	Menu_Item *subitem;
-	int maxpos[2];
+	NSint maxpos[2];
 	if (!menu)
 		return;
 
@@ -905,12 +905,12 @@
 	menu->subwindow.size[1] = maxpos[1];
 }
 
-void Menu_ArrangeSubItems(Menu_SubMenu *menu, Nbool horizontal, int pad, Menu_ArrangeStyle arrange)
+void Menu_ArrangeSubItems(Menu_SubMenu *menu, Nbool horizontal, NSint pad, Menu_ArrangeStyle arrange)
 {
 	Menu_Item *sitem;
-	int axis, otheraxis;
-	int val = 0;
-	int maxval=0;
+	NSint axis, otheraxis;
+	NSint val = 0;
+	NSint maxval=0;
 
 	//axis is usually the 'vertical' axis, where each field is spaced with padding
 	//otheraxis is the axis on which we align stuff (rather than just space it)
@@ -1003,13 +1003,13 @@
 
 
 
-float sliderscale = 8;
-float imagesize = 512;
-float windowsize = 128;
+Nfloat sliderscale = 8;
+Nfloat imagesize = 512;
+Nfloat windowsize = 128;
 void MoveMenuH(Menu_SliderItem *it)
 {
 	Menu_SubMenu *menu = it->data;
-//	it->value = 16*(int)(it->value/16);
+//	it->value = 16*(NSint)(it->value/16);
 	menu->subwindow.pos[0] = it->value;
 
 }

Modified: trunk/game/m_menucore.h
===================================================================
--- trunk/game/m_menucore.h	2006-03-08 17:15:53 UTC (rev 666)
+++ trunk/game/m_menucore.h	2006-03-08 20:40:12 UTC (rev 667)
@@ -2,16 +2,18 @@
 #ifndef M_MENUCORE_H
 #define M_MENUCORE_H
 
+typedef struct Menu_Rect
+{
+	NSint32 pos[2];
+	NSint32 size[2];
+}
+Menu_Rect;
+
 typedef struct Menu_Inheritance
 {
-	int addpos[2];
+	NSint addpos[2];
 
-	struct
-	{
-		NSint32 pos[2];
-		NSint32 size[2];
-	}
-	window;
+	Menu_Rect window;
 }
 Menu_Inheritance;
 
@@ -34,12 +36,7 @@
 {
 	Menu_Item super;
 
-	struct
-	{
-		NSint32 pos[2];
-		NSint32 size[2];
-	}
-	subwindow;
+	Menu_Rect subwindow;
 
 	Nbool dragable;
 	Nbool allowclose;
@@ -66,16 +63,16 @@
 	Menu_Item super;
 
 	char *text;	//what it currently says
-	int cursorpos; //where the cursor is, set between 0 and strlen(text)
-	int scrollpos; //fixme
-	int maxchars;  //0 for unlimited
+	NUint cursorpos; //where the cursor is, set between 0 and strlen(text)
+	NSint scrollpos; //fixme
+	NUint maxchars;  //0 for unlimited
 }
 Menu_EditItem;
 
 typedef struct Menu_ComboOption
 {
 	char *text;	//the text of the item
-	int ident;	//if you wish to assosiate an int key with the item.
+	NSint ident;	//if you wish to assosiate an int key with the item.
 	struct Menu_ComboOption *next;
 }
 Menu_ComboOption;
@@ -89,9 +86,9 @@
 	struct Menu_ComboOption *selected;	//set 
 
 	char *text;
-	int cursorpos;
-	int scrollpos;
-	int maxchars;
+	NSint cursorpos;
+	NUint scrollpos;
+	NUint maxchars;
 
 	struct Menu_SubMenu *popup;
 }
@@ -111,12 +108,12 @@
 	Menu_Item super;
 
 	void *data;	//for custom stuff
-	float value;//set and used in the slider code
+	Nfloat value;//set and used in the slider code
 
-	float minv;//min value
-	float maxv;//max (can be inverted)
+	Nfloat minv;//min value
+	Nfloat maxv;//max (can be inverted)
 
-	float scale;//size of slider, in pixels.
+	Nfloat scale;//size of slider, in pixels.
 
 	//notification function
 	void (*SliderChanged) (struct Menu_SliderItem *slider);	//the user just changed the slider->value
@@ -155,11 +152,11 @@
 
 
 Menu_SubMenu *Menu_CreateMenu(Menu_SubMenu *parent);
-Menu_SliderItem *Menu_CreateVSliderItem(Menu_SubMenu *parent, int x, int y, int w, int h, float minv, float maxv, float defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data);//vertical scrolling bar
-Menu_SliderItem *Menu_CreateHSliderItem(Menu_SubMenu *parent, int x, int y, int w, int h, float minv, float maxv, float defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data);//horizontal scrolling bar
-Menu_TextItem *Menu_CreateTextItem(Menu_SubMenu *parent, int x, int y, char *text, void *command, void (*UseTextItem) (struct Menu_TextItem *item)); //if usetextitem == null, interpret as a console command. if not null, command can be used as a magic cookie. If both null, item is non-selectable.
-Menu_EditItem *Menu_CreateEditItem(Menu_SubMenu *parent, int x, int y, char *text); //an item for editing text (fixme: needs callbacks and stuff)
-Menu_ComboItem *Menu_CreateComboItem(Menu_SubMenu *parent, int x, int y, int w, char *defalt, char *list);//a list of multiple choices.
-Menu_PictureItem *Menu_CreatePictureItem(Menu_SubMenu *parent, int x, int y, int w, int h, char *imagename, char *command); //just a simple picture. clicking it can give a console command (fixme: make like text)
+Menu_SliderItem *Menu_CreateVSliderItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, Nfloat minv, Nfloat maxv, Nfloat defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data);//vertical scrolling bar
+Menu_SliderItem *Menu_CreateHSliderItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, Nfloat minv, Nfloat maxv, Nfloat defaultv, void (*ChangeNotification)(Menu_SliderItem*), void (*UpdateSlider)(Menu_SliderItem*), void *data);//horizontal scrolling bar
+Menu_TextItem *Menu_CreateTextItem(Menu_SubMenu *parent, NSint x, NSint y, char *text, void *command, void (*UseTextItem) (struct Menu_TextItem *item)); //if usetextitem == null, interpret as a console command. if not null, command can be used as a magic cookie. If both null, item is non-selectable.
+Menu_EditItem *Menu_CreateEditItem(Menu_SubMenu *parent, NSint x, NSint y, char *text); //an item for editing text (fixme: needs callbacks and stuff)
+Menu_ComboItem *Menu_CreateComboItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, char *defalt, char *list);//a list of multiple choices.
+Menu_PictureItem *Menu_CreatePictureItem(Menu_SubMenu *parent, NSint x, NSint y, NUint w, NUint h, char *imagename, char *command); //just a simple picture. clicking it can give a console command (fixme: make like text)
 
 #endif




More information about the neither-commits mailing list