Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)

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!

Posted

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.

Posted

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.

Posted (edited)

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
Posted (edited)

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!

Posted (edited)

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
Posted (edited)

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!

Posted

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.

Posted (edited)

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
Posted (edited)

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!

Posted

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!

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

    • JackFarmer

      "Hidden Hands: Vitalic Fever" - new update available including subtitles & compressed briefing video (thanks to @datiswous) and several fixes.
      · 0 replies
    • Wolfmond

      🇬🇧

      2025-04-20
      I'd like to track my level design progress a bit more often now, so I'm using the feed in my profile here.
      I've been working intensively on Springheel's YouTube course over the past few days. I'm currently up to lesson 8. There is so much information that needs to be processed and practiced. 
      I have started to create my own house. As I don't have the imagination to create a good floor plan, I grabbed a floor plan generator from Watabou and experimented with it. I chose a floor plan that I will modify slightly, but at least I now have an initial idea. 
      I used two guards as a measuring tape: The rooms are two guards high. It turned out that I can simply double the number of boxes in DarkRadiant in grid size 8 that are drawn in the floor plan. 
      I practiced the simplest things on the floor plan first. Drawing walls, cutting walls, inserting doors, cutting out frames, creating VisPortals, furnishing rooms.
      I have had my first success in creating a book. Creating a book was easier than I thought. I have a few ideas with books. The level I'm creating will be more or less a chill level, just for me, where I'll try out a few things. I don't have an idea for my own mission yet. I want to start small first.
      For the cellar, I wanted to have a second entrance, which should be on the outside. I'm fascinated by these basement doors from the USA, I think they're called Bilco basement doors. They are very unusual in Germany, but this type of access is sometimes used for deliveries to restaurants etc., where barrels can be rolled or lifted into the cellar. 
      I used two Hatch Doors, but they got completely disoriented after turning. I have since got them reasonably tamed. It's not perfect, but it's acceptable. 
      In the cellar today I experimented with a trap door that leads to a shaft system. The rooms aren't practically finished yet, but I want to continue working on the floor plan for now. I'll be starting on the upper floor very soon.

      __________________________________________________________________________________
      🇩🇪

      2025-04-20

      Ich möchte nun mal öfters ein bisschen meinen Werdegang beim Leveldesign tracken, dazu nutze ich hier den Feed in meinem Profil.
      Ich habe mich in den vergangenen Tagen intensiv mit dem Youtube-Kurs von Springheel beschäftigt. Aktuell bin ich bis zu Lektion 8 gekommen. Das sind so viele Informationen, die erstmal verarbeitet werden wollen und trainiert werden wollen. 

      Ich habe mich daran gemacht, ein eigenes Haus zu erstellen. Da mir die Fantasie fehlt, einen guten Raumplan zu erstellen, habe ich mir einen Grundrissgenerator von Watabou geschnappt und damit experimentiert. Ich habe mich für einen Grundriss entschieden, den ich noch leicht abwandeln werde, aber zumindest habe ich nun eine erste Idee. 

      Als Maßband habe ich zwei Wächter genommen: Die Räume sind zwei Wächter hoch. Es hat sich herausgestellt, dass ich in DarkRadiant in Gittergröße 8 einfach die doppelte Anzahl an Kästchen übernehmen kann, die im Grundriss eingezeichnet sind. 

      Ich habe bei dem Grundriss erstmal die einfachsten Sachen geübt. Wände ziehen, Wände zerschneiden, Türen einsetzen, Zargen herausschneiden, VisPortals erstellen, Räume einrichten.

      Ich habe erste Erfolge mit einem Buch gehabt. Das Erstellen eines Buchs ging leichter als gedacht. Ich habe ein paar Ideen mit Bücher. Das Level, das ich gerade erstelle, wird mehr oder weniger ein Chill-Level, einfach nur für mich, bei dem ich ein paar Sachen ausprobieren werde. Ich habe noch keine Idee für eine eigene Mission. Ich möchte erst einmal klein anfangen.

      Beim Keller wollte ich gerne einen zweiten Zugang haben, der sich außen befinden soll. Mich faszinieren diese Kellertüren aus den USA, Bilco basement doors heißen die, glaube ich. Diese sind in Deutschland sehr unüblich, diese Art von Zugängen gibt es aber manchmal zur Anlieferung bei Restaurants etc., wo Fässer dann in den Keller gerollt oder gehoben werden können. 
      Ich habe zwei Hatch Doors verwendet, die allerdings nach dem Drehen vollkommen aus dem Ruder liefen. Inzwischen habe ich sie einigermaßen gebändigt bekommen. Es ist nicht perfekt, aber annehmbar. 
      Im Keller habe ich heute mit einer Falltür experimentiert, die zu einem Schachtsystem führt. Die Räume sind noch quasi nicht eingerichtet, aber ich möchte erstmal am Grundriss weiterarbeiten. In Kürze fange ich das Obergeschoss an.



      · 2 replies
    • JackFarmer

      On a lighter note, thanks to my cat-like reflexes, my superior puzzle skills and my perfect memory, I was able to beat the remastered version of "Tomb Raider: The Last Revelation" in a new superhuman record time of 23 h : 35 m, worship me!
      · 3 replies
    • Goblin of Akenash

      My mapping discord if anyone is interested, its more of a general modding thing rather than just for TDM 
      https://discord.gg/T4Jt4DdmUb

       
      · 0 replies
    • nbohr1more

      2.13 Moddb Article is up: https://www.moddb.com/mods/the-dark-mod/news/the-dark-mod-213-is-here
      · 1 reply
×
×
  • Create New...