Jump to content
Sign in to follow this  
Fortran

Dialog Cursor?

Recommended Posts

Just started getting into Dialog to try and build some extra functionality for my F117A. Having a major headache as the learning curve feels quite steep (have read the Dialog Control biki entry numerous times).

Basically what I am trying to achieve is simply to add a crosshair (image) which moves with the mouse when the dialog is open. Everything is functioning how I want, but I just cannot get an image to attach and move with the mouse. Ultimately I would really like to totally replace the arrow cursor which appears during the dialog and just use an image. Here is where I am at so far but no matter what I try I just cannot seem to get the "marker" control to use an image, or if I do it is static and then the mouse handler functionality no longer works. The background image ("Picture") part works just fine.

If anybody can help me out with this I would seriously appreciate it.

#include "constants.hpp"


class TestText
{
access = 0;
type = 11;
style = 2;
color[] = { 0, 0, 0, 1 };
colorActive[] = { 0.3, 0.4, 0, 1 };
soundEnter[] = { "", 0.1, 1 };
soundPush[] = { "", 0.1, 1 };
soundClick[] = { "", 0.1, 1 };
soundEscape[] = { "", 0.1, 1 };
text = "";
default = 0;
idc = -1;
x = 0;
y = 0;
h = 0.035;
w = 0.035;
font = "Zeppelin32";
sizeEx = 0.03921;
colortext[] = { 0, 0, 0, 1 };
};

class Test
{
idd = -1;
       controls[] = {"marker"};
       controlsBackground[] = {"picture"};

class picture { 
      idc = -1; 
      type = CT_STATIC; 
      style = ST_PICTURE;  
      colorText[] = { 0, 0, 0, 1 }; 
      colorBackground[] = { 1, 1, 1, 0.75 }; 
      font = FontM; 
      sizeEx = 0.023; 
      x = 0.1; y = 0.1; 
      w = 1; h = 1; 
      text = "mybackgroundimage.paa"; 
};

class marker : TestText {
idc = 50;
style = 48;  
x = -1;
y = -1;
w = 3;
h = 3;
text = "mycursorimage.paa"; 
color[] = {0, 0, 0, 0};
colorActive[] = {0, 0, 0, 0};
onMouseMoving = "mousePos = [ _this select 1,_this select 2 ];";
onMouseButtonClick = "closeDialog 0; dummy = [] exec ""world2.sqs"";";

};
};

Share this post


Link to post
Share on other sites

I want also to know the method of hide the mouse cursor. But, the way might not exist.

Share this post


Link to post
Share on other sites

Its not possible to hide the cursor afik.

ways to remove the mouse cursor is by makeing a mod and replace the current cursor with a super tiny dot or something.. this is not a opton imo since it will affect all dialogs.

Basically what I am trying to achieve is simply to add a crosshair (image) which moves with the mouse when the dialog is open

That is verry possible. :)

The dialog code can look something like this.

class MYDIALOG
{
idd = 1000;
moving = false;
movingEnable = false;
movingEnabled = false;
onLoad="uiNamespace setVariable ['MYDisplay', _this select 0]"; 
controlsBackground[ ]={};
objects[ ]={ };
controls[ ]={MOUSEAREA,CROSSHAIR};
class MOUSEAREA
{
	idc = -1;
	type = 0;
	style = 16;
	colorText[ ]={ 0,0,0,0 };
	colorBackground[ ]={ 1,1,1,0 };
	font = "Zeppelin32";
	sizeEx = 0.05;
	lineSpacing = 0;
	x = 0;
	y = 0;
	w = 1;
	h = 1;
	text = "";
	onMouseMoving = "mousePos = [ _this select 1,_this select 2 ];";
};
class CROSSHAIR
{
	idc = 1001;
	type = 0;
	style = 48;
	colorText[ ]={ 0,0,0,1 };
	colorBackground[ ]={ 0.4,0.4,0.4,1 };
	font = "Zeppelin32";
	sizeEx = 0.01;
	lineSpacing = 0;
	x = 0.5;//center
	y = 0.5;//center of screen

	w = 0.5; //play with thise to set size
	h = 0.5; //to set size
	border = 0;
	borderSize = 0;
	text = "pics\crosshair.paa";
};	
};

ok now in your script, something like this

example:


while {(dialog)} do
{
   _mx = mousePos select 0;
   _my = mousePos select 1;
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlSetPosition [_mx,_my];
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlCommit 0;
   sleep 0.1;
};

hope this helps :)

Edited by nuxil

Share this post


Link to post
Share on other sites

Fantastic! Many thanks Nuxil that works a treat, have actually been looking through your TV guided script attempting to learn some of the more advanced Dialog/GUI features from it :) Is there any other way to get the mouse to update in the "while {(dialog)} do" section without placing it inside a loop or is there a way I can script "if not in dialog then goto exit"? I understand that "while" should execute while the condition is true, but it doesn't seem to update unless I place it inside a loop. Anyway thanks again mate, really appreciate your help.

EDIT: Also just trying it, changing the x/y values in the crosshair class does indeed set the crosshair image nearer to the center of the cursor, but as soon as the mouse position updates the crosshair image jumps so the top left hand corner of the image is aligned with the mouse pointer, is there any way to force the image to stay centred to the cursor ? ie like this :

+

[_____]

[_____]

[_____]

where as I need this:

[_____]

[__+__]

[_____]

Edited by Fortran

Share this post


Link to post
Share on other sites

You welcome.

im suck at english so i'll try to explain the best :p

let say you have a script that creates your dialog.

example: somescript.sqf

blah blah code..
_dlg = createdialog "THENAME";
sleep .; // let the dialog be created.. 
//execvm,  spawn, call or what ever function you want to use. make it here..
[] execvm "CrossHairPos.sqf";

more blah code;

CrossHairPos.sqf

while {(dialog)} do
{
   _mx = mousePos select 0;
   _my = mousePos select 1;
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlSetPosition [_mx,_my];
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlCommit 0;
   sleep 0.1;
};

now you see. once you exit the dialog. the CrossHairPos.sqf script exsits since

while{(dialog)} is no longer true.

once you create the dialog by somescript. the CrossHairPos.sqf is run again.

im sure there are other way of doing it.. best one i could come up woth right now

edit: im sure you also could put CrossHairPos.sqf in onLoad instead

centring the mousecursor on the pic require that you know the size "hight/with" of the Crosshair picture.. then take away 1/2 the values from x & y this needs to be played with.. if h=0.5 and w= 0.5 you need to x - 0.25 and y - 0.25 in the CrossHairPos.sqf script

Edited by nuxil

Share this post


Link to post
Share on other sites

Hi Nuxil thanks again man, you have been a huge help with this (and your English is perfect btw!) Now managed to centre the crosshair on the cursor which is great :) Last thing I just can't get working is to have CrossHairPos.sqf running without a loop.

CrossHairPos.sqf looks like this:

while {(dialog)} do
{
   _m2x = mousePos select 0;
   _m2y = mousePos select 1;
   _m3x = _m2x - 0.125;
   _m3y = _m2y - 0.125;
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlSetPosition [_m3x,_m3y];
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlCommit 0;
   sleep 0.1;

and "controls.sqs" which is executed from a user action looks like this:

_dlg = createdialog "MYDIALOG";
[] execvm "CrossHairPos.sqf";

However for some reason it just doesn't work? I can't seem to figure out why. If I add a loop to the CrossHairPos.sqf like this:

#myloop
while {(dialog)} do
{
   _m2x = mousePos select 0;
   _m2y = mousePos select 1;
   _m3x = _m2x - 0.125;
   _m3y = _m2y - 0.125;
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlSetPosition [_m3x,_m3y];
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlCommit 0;
   sleep 0.1;
goto "myloop";

then it works, but without the loop it doesnt ?

Thanks again anyway man, got alot of this working thanks to your help!

Share this post


Link to post
Share on other sites

Because i wrote the code in sqf in you put in sqs commands.

if your still scripting in sqs i suggest you start convert to sqf instead. sqf is superior to sqs

btw [] execvm "CrossHairPos.sqf" put that in Onload instead.. like

onLoad="uiNamespace setVariable ['MYDisplay', _this select 0];execvm 'crosshair.sqf'";

then you dont need it in control.sqs

now make CrossHair presicly like:

sleep 0.3;
while {(dialog)} do
{
   _m2x = mousePos select 0;
   _m2y = mousePos select 1;
   _m3x = _m2x - 0.125;
   _m3y = _m2y - 0.125;
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlSetPosition [_m3x,_m3y];
   ((uiNamespace getVariable 'MYDisplay') displayCtrl 1001) ctrlCommit 0;
   sleep 0.1;
};

an save it as sqf, remember to use execvm and not exec on sqf scripts

if you want th crosshair to update faster.. change sleep 0.1 to example sleep 0.05 instaed. i think 0.1 is to slow.. but its your choise

Edited by nuxil

Share this post


Link to post
Share on other sites

Perfect :) Thanks man, seriously appreciate your help, very new to scripting so finding what works in sqs or sqf is still a bit outside my knowledge. Anyway its all working great now! Thanks again Nuxil.

Share this post


Link to post
Share on other sites

In about 2 weeks from now lol. I am just finishing up getting the F117A fully animated in O2 and the question in this thread is directly related to the FLIR/DLIR sensor turret system I am implementing for it. As in real-life the jet can now self laser-designate targets and has it own mouse driven scripted turret system (thanks to some major help from Gigan). Basically attempting to replicate the real-life sensor/weapon system of the F-117A as closely as my knowledge and the engine will allow me to.

Edited by Fortran

Share this post


Link to post
Share on other sites

Wonderful stuff mate !

Would that mouse driven scripted turret system by useful on an AC130 Spectre gunship for instance (hint hint) :)

Share this post


Link to post
Share on other sites

Its possible perhaps, the trouble is you can't fire during a dialog which occurs when the turret is in operation, but I am sure there would be a method to jump in and out of the script between shots perhaps. Maybe Gigan might be able to assist with that.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×