Jump to content
The Dark Mod Forums

Moving gui images


freyk

Recommended Posts

Can somebody help me with the following task:

 

For my upcoming cyberpunk-based mission, i'm working on a new mapviewer.

Its a menu, with a "viewpoint"-window (inside this a map) and navigation buttons.

 

I would like to re-position the map, after the player clicked on a navigation button.

And to zoom -in and -out, if the player click on the + and minus button.

Can you help me to code this?

 

i got the following code:

 

 

//left,down,w,h
#define mapposleft -15
#define mapposdown 29
#define mapposwitdh 384
#define mapposheight 311


windowDef Desktop
{
	rect	0, 0, 640, 480
	visible	1
	menugui	1

	onActivate {
		
		set "MapviewerWindow::visible" "1" ;
		//set "gui::mapposleft" "-15";
		//set "gui::mapposdown" "29";
		//set "gui::mapposwitdh" "384";
		//set "gui::mapposheight" "311";
	}

	windowDef MapviewerWindow
	{
		rect	3,-8,580,350
		visible	1
		background	"guis/assets/mainmenu/lumi-tooltipblueback"
	}
	windowDef MapViewerWindowClose
	{
		rect	0,0,40,40
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		forecolor	0,0,1,1
		text	"X"
		textscale	0.8
		textalign	1
		font	MPV_GUI_FONT
	}
	windowDef MapLabel
	{
		rect	56,-1,462,31
		visible	1
		forecolor	1,1,1,1
		text	"Officesite 3"
		textscale	0.5
		textalign	1
		bordersize	1
		bordercolor	1,0,0,1
	}
	windowDef MapViewerMapViewpoint
	{
		rect	57,46,280,217
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		windowDef MapViewerMap
		{
			//rect	-15,29,384,311
			rect mapposleft, mapposdown, mapposwitdh, mapposheight
			visible	1
			bordersize	1
			bordercolor	0,0,1,1
			background	"MPV_GUI_MAP"
			matcolor	1,1,1,1
			forecolor	1,1,1,1
			text	"asfdasdfasdfsdfasdfsadfasdfasdfasdasfdasdfdfasdasfdasdfasdfsadfasdfasdfasd"
			textscale	1
			backcolor	0,0,1,1
		}
	}
	windowDef MapViewerMapNavUp
	{
		rect	409,166,40,40
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		forecolor	0,0,1,1
		text	^
		textscale	0.8
		textalign	1
	}
	windowDef MapViewerMapDown
	{
		rect	408,211,40,40
		visible	1
		bordersize	1
		forecolor	0,0,1,1
		bordercolor	1,0,0,1
		text	v
		textscale	0.8
		textalign	1
	}
	windowDef MapViewerMapLeft
	{
		rect	372,182,40,40
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		forecolor	0,0,1,1
		backcolor	0, 0, 0, 0.8
		text	"<"
		textscale	0.8
		textalign	0
	}
	windowDef MapViewerMapRight
	{
		rect	452,186,40,40
		visible	1
		bordersize	1
		forecolor	0,0,1,1
		bordercolor	1,0,0,1
		text	">"
		textscale	0.8
		textalign	1
		
		onAction{
			set "gui::mapposleft" + 1
			set mapposleft + 1
		}
		
	}
	windowDef MapViewerMapZoomIn
	{
		rect	370,124,40,40
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		forecolor	0,0,1,1
		text	"+"
		textscale	0.8
		textalign	1
	}
	windowDef MapViewerMapZoomOut
	{
		rect	453,125,40,40
		visible	1
		bordersize	1
		bordercolor	1,0,0,1
		forecolor	0,0,1,1
		text	"-"
		textscale	0.8
		textalign	1
	}
}

post-13309-0-78310100-1488405394_thumb.jpg

Edited by freyk
  • Like 1

Info: My portfolio and darkmod graphical installer
Amnesty for Bikerdude!

Link to comment
Share on other sites

So, you want the windowDef holding your map image to render a specific section of the material? That's an interesting problem to tackle.

 

I'm not the most experienced with the GUI scripting system, but looking here, it seems like using the matscalex and matscaley properties might be the way to go for the scaling, at least.

 

So, something like:

windowDef MapviewerWindow
{
	rect	3,-8,580,350
	visible	1
	background	"guis/assets/mainmenu/lumi-tooltipblueback"
}

windowDef MapViewerMapZoomIn
{
    rect    370,124,40,40
    visible    1
    bordersize    1
    bordercolor    1,0,0,1
    forecolor    0,0,1,1
    text    "+"
    textscale    0.8
    textalign    1

    onAction
    {
        set "MapviewerWindow::matscalex" "MapviewerWindow::matscalex + 0.2"
        set "MapviewerWindow::matscaley" "MapviewerWindow::matscaley + 0.2"
    }
}

windowDef MapViewerMapZoomOut 
{
    rect    453,125,40,40
    visible    1
    bordersize    1
    bordercolor    1,0,0,1
    forecolor    0,0,1,1
    text    "-"
    textscale    0.8
    textalign    1

    onAction
    {
        set "MapviewerWindow::matscalex" "MapviewerWindow::matscalex + 0.2"
        set "MapviewerWindow::matscaley" "MapviewerWindow::matscaley + 0.2"
    }
}

 

Note that I'm not 100% confident you can call variables you're trying to set as arguments (i.e. the "MapviewerWindow::matscalex + 0.2" statements), but in the format of this scripting language there's not really a way to use a += or -= statement.

 

Try that and see if it works.

Link to comment
Share on other sites

you have to run this via a script. and an overlay_handle, so that the gui can get the varibles from the script and change the gui on the screen, without a overlay_handle you can't target the gui and update the information it contains that need changing. like matscalex and matscaley.

 

for an interactive gui it needs to be controlled via a script, else its just runs like an animation with no control.

 

buttons on the gui control scripts in the script file. those scripts then control what happens with the gui.

Link to comment
Share on other sites

GUI scripting for idtech 4 is a Arte in it self, i'm still a total noob when it comes to gui scripting, but this links even tho not TDM specific should help you.

 

 

Doom 3

 

https://modwiki.xnet.fi/GUI_scripting

 

http://idtechforums.fuzzylogicinc.com/index.php?topic=531.msg5825;topicseen#msg5825

 

This one is for Quake 4 so some things don't work in normal idtech 4 but is still a good reference.

 

https://www.iddevnet.com/quake4/GUIEditor

Edited by HMart
Link to comment
Share on other sites

Thanks for all the suggestions.

 

Today i came with a other idea:

Changing the layer order.

  • (lowest) put MapViewerMap.
  • MapviewerWindow (backgroundimage with a "hole").
  • the navigation buttons, map label, etc
As result: see the attachtment.

Its a work-around sollution, but it works.

 

Now i can rotate mapviewermap, using command transition.

But which commands can/should I use to zoom in-out and move the mapviewermap?

 

 

 

windowDef Desktop
{
	rect	0, 0, 640, 480
	visible	1
	menugui	1

  windowDef MapViewerMap
  {
    //rect	-15,29,384,311
    rect mapposleft, mapposdown, mapposwitdh, mapposheight
    visible	1			
    background	"MPV_GUI_MAP"
    matcolor	1,1,1,1
    forecolor	1,1,1,1
    text	"asfdasdfasdfasdfasdasfsdasfdasdfasdfsadfasdfasdfasd"
    textscale	1
    bordersize	1
    bordercolor	0,0,1,1
    backcolor	0,0,1,1
  }

  windowDef MapviewerWindow
  {
   rect	3,-8,580,350
   visible	1
   background	"guis/assets/mainmenu/lumi-tooltipblueblackwithhole"
  }

  windowDef MapViewerMapZoomIn
  {
   rect	370,124,40,40
   visible	1
   bordersize	1
   bordercolor	1,0,0,1
   forecolor	0,0,1,1
   text	"+"
   textscale	0.8
   textalign	1
		
   onAction
   {
    //set "MapViewerMap::matscalex" "MapViewerMap::matscalex + 0.2"
    //set "MapViewerMap::matscaley" "MapViewerMap::matscaley + 0.2"
    transition "MapViewerMap::rotate" "5" "-60" "33000";
    }
  }

//end desktop
}

post-13309-0-95803900-1488489378_thumb.jpg

Edited by freyk

Info: My portfolio and darkmod graphical installer
Amnesty for Bikerdude!

Link to comment
Share on other sites

I think for a simple WindowDef you could use

 matscalex   2
 matscaley   2

To change the size of the image and simulate zoom, but i'm not sure, like i said just a noob on this stuff.

 

 

 

IMO you could also use a 3D version of the map in that way you have more control over the scene and it would look more futuristic

 

Like this example

renderDef MarsRender {
    rect        0, 20, 640, 430
    visible     1
    backcolor   0, 0, 0, 0.4
    model       "models/wipes/planet2.lwo"
    needsRender     1
    modelRotate     0, time * 0.001, 0, 0
    modelOrigin     -80, 0, -25, 0
    viewOffset  -300, -28, 0, 0
    lightOrigin     0, 0, 0, 0
    lightColor  1, 1, 1, 1
    notime      1
    definevec4  "$marsRotate"   0, time * 0.001, 0, 0
    float starmove  0
}

Viewoffset or modelOrigin could be a option just change the values when clicking the buttons and you will have zoom. :)

Edited by HMart
Link to comment
Share on other sites

I dont have any experience yet with animating renderdef.
for now I keep it easy and work with windowdef.

Moving the image using transition works (a bit).

transition "MapViewerMap::rect" "mapposleft mapposdown mapposwitdh mapposheight" "50 0 80 80" "400" "1" "33000";

but now i have to search howto count up a variable.
following transition codeline doesnt work for me
(snipt out some code)

#define mapposleft 1
windowDef MapViewerMap
{
rect mapposleft, mapposdown, mapposwitdh, mapposheight
visible 1
background "guis/assets/maps/map-indus" 
}

windowDef MapViewerMapRight
{
rect 452,186,40,40
text ">"
onAction{
transition "MapViewerMap::rect" "mapposleft mapposdown mapposwitdh mapposheight" "(mapposleft + 20) mapposdown mapposwitdh mapposheight" "400" "1" "33000";
}
}
Edited by freyk

Info: My portfolio and darkmod graphical installer
Amnesty for Bikerdude!

Link to comment
Share on other sites

Instead of using "rect 452, 168, 40, 40", can you define and use variables like in the upper part? Thus, in the lower part you start with "rect mapposleft, mapposdown, mapposwitdh, mapposheight". This way the script will always have the current value of the variable as a starting point and the mapview have the last used part visible.

Link to comment
Share on other sites

but now i have to search howto count up a variable.

 

 

On the gui where you want to update the variable (this gui needs to be assigned to a object with the key/val "gui/guiname.gui"), on the "desktop" windowdef write " float foo = 0;"

 

then inside some windowdef put something like

windowdef somename
{
   if( gui::foo > x )
   {
      do stuff
   }
{

or 

windowDef TextItemName
{
rect	10,5,50,10
visible	1
text	"gui::foo" // for this one you need to use $game_object.setGuiParm("foo","sometext"); instead of setGuiFloat
}

then on a script use the command $entity.setGuiFloat("foo","newValue");

 

example

float count;

for (count = 0; count < x; count++)
{
  $game_entity.setGuiFloat("foo", "count");
}

I hope this helps, if not I got more or less this info from here

 

https://web.archive.org/web/20121104025750/http://www.doom3world.org/phpbb2/viewtopic.php?t=3504

Edited by HMart
Link to comment
Share on other sites

Thanks, i will try to create a script.

 

I have tried several variable methods.

Its difficult to see, when you have to use "gui:myvar","myvar", ("myvar"), etc.

If i dont use the variables correctly, the image disappears or has the wrong values.

 

At this moment my map moves to a position using "transition:rect"-command and static positions.

(set can also used)

Edited by freyk

Info: My portfolio and darkmod graphical installer
Amnesty for Bikerdude!

Link to comment
Share on other sites

I have tested some lines.

I can use/calculate value variables in the windowdef.

I can also move the picture using transition and static values.

But none helped to move the image using variables.

 

Could somebody post some tested/working examples for moving the picture, using variables?

 

 

tested code:

 

 

 

Defining variables and showing and calculating them in windowdef works.

windowDef Desktop
{
	rect	0, 0, 640, 480
	visible	1
	menugui	1

#define mapposleft 1
#define mapposdown 29
#define mapposwitdh 384
#define mapposheight 311

windowDef MapViewerMap
{
rect (mapposleft + 50), mapposdown, mapposwitdh, mapposheight
}

}//end desktop-windowddef
Working transition code (without variables)

windowDef MapViewerMapRight
	{
		rect	452,186,40,40
		visible	1
		bordersize	1
		forecolor	0,0,1,1
		bordercolor	1,0,0,1
		text	">"
		textscale	0.8
		textalign	1
		
		onAction{
transition "MapViewerMap::rect" "1 29 384  311" "100 29 384  311" "1000";
}
several codelines that doesnt work:

transition "MapViewerMap::rect" "mapposleft mapposdown mapposwitdh mapposheight" "50 0 80 80" "10000";
transition "MapViewerMap::rect" "mapposleft mapposdown mapposwitdh mapposheight" "("gui::mapposleft" + 50) mapposdown mapposwitdh mapposheight" "400" "1" "33000";
transition "MapViewerMap::rect" "mapposleft mapposdown mapposwitdh mapposheight" "mapposleft mapposdown mapposwitdh mapposheight" "400" "1" "33000";
transition "MapViewerMap::rect" "1 29 384  311"  "100 29 384  311" "27000";
transition "MapViewerMap::rect" "("gui::mapposleft") ("gui::mapposdown") ("gui::mapposwitdh") ("gui::mapposheight")" "100 29 384  311" "27000";
transition( "MapViewerMap::rect", "1 29 384  311", "100 29 384  311", "27000" );
transition "MapViewerMap::rect" "1 29 384  311" "100 29 384  311" "27000";
set "MapViewerMap::rect" "(gui.mapposleft + 1), mapposdown, mapposwitdh, mapposheight";
set "MapViewerMap::rect" "mapposleft, mapposdown, mapposwitdh, mapposheight";
set "MapLabel::Text" "(mapposleft + 50), mapposdown, mapposwitdh, mapposheight";

 

Info: My portfolio and darkmod graphical installer
Amnesty for Bikerdude!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 6 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...