Jump to content


Photo

Moving gui images


10 replies to this topic

#1 freyk

freyk

    Member

  • Member
  • PipPip
  • 463 posts

Posted 01 March 2017 - 04:53 PM

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:
Spoiler

Attached Files


Edited by freyk, 01 March 2017 - 04:56 PM.

  • Moonbo likes this

#2 jaredmitchell

jaredmitchell

    Member

  • Member
  • PipPip
  • 35 posts

Posted 01 March 2017 - 06:15 PM

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.



#3 stumpy

stumpy

    Advanced Member

  • Member
  • PipPipPip
  • 1664 posts

Posted 01 March 2017 - 07:37 PM

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.



#4 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 539 posts

Posted 01 March 2017 - 09:19 PM

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....picseen#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...uake4/GUIEditor


Edited by HMart, 01 March 2017 - 09:19 PM.


#5 freyk

freyk

    Member

  • Member
  • PipPip
  • 463 posts

Posted 02 March 2017 - 04:23 PM

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?

Spoiler

Attached Files


Edited by freyk, 02 March 2017 - 04:56 PM.


#6 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 539 posts

Posted 03 March 2017 - 02:01 PM

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, 03 March 2017 - 02:06 PM.


#7 freyk

freyk

    Member

  • Member
  • PipPip
  • 463 posts

Posted 04 March 2017 - 06:39 AM

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, 04 March 2017 - 08:29 AM.


#8 Destined

Destined

    Advanced Member

  • Member
  • PipPipPip
  • 1253 posts

Posted 04 March 2017 - 06:54 AM

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.



#9 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 539 posts

Posted 04 March 2017 - 08:49 PM


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....opic.php?t=3504


Edited by HMart, 04 March 2017 - 08:50 PM.


#10 freyk

freyk

    Member

  • Member
  • PipPip
  • 463 posts

Posted 09 March 2017 - 08:30 AM

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, 09 March 2017 - 08:34 AM.


#11 freyk

freyk

    Member

  • Member
  • PipPip
  • 463 posts

Posted 12 March 2017 - 10:35 AM

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:
Spoiler




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users