Tutorial: CSQC GUI Menus

Discuss CSQC related programming.
avirox
Posts: 137
Joined: Wed Aug 16, 2006 3:25 pm

Post by avirox »

ceriux wrote:yeah, running dp (so id just have to run the source for this ? and it would be that easy?)
if prydon doesn't already have csqc.. then yes. Otherwise use the tutorial in this thread.

At any rate, I will try to work on a DP build for this when I get the time. I will post it here when I'm done
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

cool thanks
avirox
Posts: 137
Joined: Wed Aug 16, 2006 3:25 pm

Post by avirox »

Well I finally had some free time this morning, so I did a preliminary port for DP using my code from Damascus. This source is radically different than the previous builds' in certain ways, so doing a diff might prove a bit tricky. I moved some files around a bit and split others so that things were more tidy. This source also includes my beta test inventory menus and such.

http://avirox.amnesiagames.com/FTE/csqc_gui_12b1.zip

Please note that there are still bugs with DP, like the view moving around (which shouldn't prove an issue with Prydon I think). Also DP is not liking the pics i try to precache for the menu items.. I'm not sure why :\

Anyhoo, plug it in and try "testmenu1", 2, and 3. I will investigate the DP bugs further a bit later..
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

alright cool, thanks ill see what i can do.
xaGe
Posts: 465
Joined: Wed Mar 01, 2006 8:29 am
Location: Upstate, New York
Contact:

Post by xaGe »

..Did you do anything with it? Did anyone? I haven't seen much of any thing from this publicized at least..

ceriux wrote:alright cool, thanks ill see what i can do.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

oh yeah i loaded that into prydon and all it did was make everything disappear. text wise anyways. i just downloaded it again. after i start my new mod and its past the planning stage. ima see if i can get it to work with that.
avirox
Posts: 137
Joined: Wed Aug 16, 2006 3:25 pm

Post by avirox »

It's functional in MegaTF Coop if you want to see it in action (needs FTE): 74.86.171.201:27500. Other than that, it's a big part of my action/rpg project, Damascus.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Tutorial: CSQC GUI Menus

Post by Cobalt »

Looks like I am getting in real late on the csqc stuff. I asked Frika if we could have a seperate forum where all the csqc stuff can be grouped, with some stickies to the sites that havethe structures and stuff defined....etc. Also posts like this one ought to be moved there IMO. Havingit all centralized in one spot makes it easier to learn.
goldenboy
Posts: 924
Joined: Fri Sep 05, 2008 11:04 pm
Location: Kiel
Contact:

Re: Tutorial: CSQC GUI Menus

Post by goldenboy »

RMQ is also dicking around with CSQC atm. Slowly, though. So, count me as another interested party.
avirox
Posts: 137
Joined: Wed Aug 16, 2006 3:25 pm

Re: Tutorial: CSQC GUI Menus

Post by avirox »

Hi guys, just a quick update about DP support.

While the zip posted in this thread does contain DP support, please be aware that I have found a performance leak in the old code. If you are trying to use CSQC GUI with DarkPlaces, please change the following code under CSQC_UpdateView():

Code: Select all

#ifdef WORKINDP
	// Since CSQC_InputEvent in DP does not pick up mouse movements, parse them here
	if (in_menu) {
		mousemoves = getmousepos();
		CSQC_InputEvent( 2, mousemoves_x, mousemoves_y );
	}
#endif
to:

Code: Select all

#ifdef WORKINDP
	// Since CSQC_InputEvent in DP does not pick up mouse movements, parse them here
	if (in_menu) {
		mousemoves = getmousepos();
		if (mousemoves != oldmousemove) {
			CSQC_InputEvent( 2, mousemoves_x, mousemoves_y );
			oldmousemove = mousemoves;
		}
	}
#endif
Also in your CSQC defs file, add this definition:

Code: Select all

vector oldmousemove;
Peace,
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Tutorial: CSQC GUI Menus

Post by Spike »

LH said he already fixed CSQC_InputEvent, so that code is relevent only for older builds, though it may have been a fairly recent change.
sp4x0r
Posts: 16
Joined: Mon Jul 21, 2008 11:48 am

Re: Tutorial: CSQC GUI Menus

Post by sp4x0r »

Sorry to bump an old thread. I've just been playing around with this (awesome stuff, by the way), and I've had a little success with the mouse in Darkplaces so thought I'd share it.

You can use setcursormode() to stop mouse input from moving the view in DP. This changes how getmousepos() works, though. Instead of getting relative mousemovements you get absolute mouse position. As Spike says, more recent builds of DP (after about August 2011) have CSQC_InputEvent get mouse input using eventttype == 2, but when you use setcursormode() you have to get mouse input using eventtype == 3.

One cool thing about using the absolute mouse position is that it will be the same spot as the prydon cursor, so you can easily go between client side menus and server side interaction with the environment. If you use relative mouse movement the two mouse cursors move differently, and wind up in different spots on the screen.

So here's what I did, I probably missed something important, but it's a start.

in CSQC_defs.qc add:

Code: Select all

	vector oldmousemove, mouse_oldrealpos;
and

Code: Select all

	void(float usecursor) setcursormode = #343;

Open csqc_parse.qc and find SetupMenu()
After the line:

Code: Select all

	CSQCGUI_ClearMenu();	//Clear the current menu
add

Code: Select all

	#ifdef WORKINDP
		setcursormode(1);		// stops the engine from using mouse input to move the view
	#endif
testmenu bypasses SetupMenu(), so we need to put that code in there too. In gui_menus.qc find Menu_TestMenu() and put it in there as well.

After that, open gui_main.qc and find CSQCGUI_ClearMenu(), then add

Code: Select all

	#ifdef WORKINDP
		setcursormode(0);		// allows mouse input to move the view
	#endif
Open gui_drawhud.qc and find CSQC_UpdateView()
Find the code:

Code: Select all

	#ifdef WORKINDP
		// Since CSQC_InputEvent in DP does not pick up mouse movements, parse them here
		if (in_menu) {
			mousemoves = getmousepos();
			if (mousemoves)
				CSQC_InputEvent( 2, mousemoves_x, mousemoves_y );
		}
	#endif
unless you've put in avirox's fix a couple of posts above, in which case it'll look a little different

change this to:

Code: Select all

	#ifdef WORKINDP
		// Since CSQC_InputEvent in DP does not pick up mouse movements, parse them here
		if (in_menu) {
			mousemoves = getmousepos();
			if (mousemoves != oldmousemove)
			{
				CSQC_InputEvent( 3, mousemoves_x, mousemoves_y );	//originally eventtype 2, changing to 3 for DP mouse support
				oldmousemove = mousemoves;
			}
		}
	#endif
Note, I'm using eventtype 3 instead of 2. If you're using one of the more recent builds of darkplaces you don't even need this section, you can just comment it all out.

In the same file, go to CSQC_InputEvent() and go to the end of the function. Near the end, just after the last "return TRUE"

Code: Select all

				}
				return TRUE;
			}
			// WE'LL BE INSERTING CODE HERE
		}
		return FALSE;
	};
I've just copied the existing code for handling eventtype 2, changed it to eventtype 3 and changed it a little for absolute mouse positon, insert it at the spot mentioned above.

Code: Select all


	#ifdef WORKINDP
	if (eventtype == 3 && !(global_menu_flags & MFG_NOCURSOR))
	{
		if (testsize_one_z == TRUE)
		{
			if (edit_button)
			{
				edit_button.size_x += (param1 - mouse_oldrealpos_x);
				edit_button.size_y += (param2 - mouse_oldrealpos_y);
			}
		}
		else
		{
			mousepos_x = param1;
			mousepos_y = param2;
			
			if (edit_button)
			{
				edit_button.origin_x = mousepos_x + edit_button_offset_x;
				edit_button.origin_y = mousepos_y + edit_button_offset_y;
			}
		}
		
		
		mouse_oldrealpos_x = param1;
		mouse_oldrealpos_y = param2;
		
		return TRUE;
	}
	#endif
I should point out that I have no idea what the edit_button code is all about, I just guess that this would be the way to do it. There's some other code at the start of CSQC_InputEvent() to do with edit_view_mode in the case of eventtype 2 that I haven't copied for eventtype 3. This doesn't break anything that I've used, but it probably breaks something. If anybody understands it I'd love to know.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Tutorial: CSQC GUI Menus

Post by Cobalt »

Some guys over on quakeone are making a few multi-configurable csprogs. The one released in the Feral mod was really loaded I thought...it had draggable menus you can close out....and I think it remembered your settings the next time it loaded too. One question I wanted to ask, is say you make one for a ded server, and use this for some fancy motd and or player configuration settings, like picking the player model or whatever.
Could you code it to remember that you already read the server motd, so that next time you connect, it dont show up?



Anyhow Id like to learn more about it....would be great if someone could post a youtube vid or something.
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Tutorial: CSQC GUI Menus

Post by thommoboy »

would this work on the psp?
Jukki
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am

Re: Tutorial: CSQC GUI Menus

Post by Jukki »

IF you code csqc in your engine then yes.
Post Reply