problem with positioning/re-sizing a gui.

Started by markbilly, Mon 19/07/2010 13:53:06

Previous topic - Next topic

markbilly

I've got a GUI (gdialog_backgro) that I want to appear behind my custom text-window GUI (gdialog) that I am using for dialog options.

This obviously means I want gdialog_backgro to re-position and re-size when the dialog options (gdialog) appear, so it appears behind it nicely.

So, I have this in repeatedly_execute_always:
Code: ags

if (gdialog.Visible == true) {
  gdialog_backgro.Visible = true;
}
else if (gdialog.Visible == false) {
  gdialog_backgro.Visible = false;
}
 
gdialog_backgro.X = dialog_topleft.X;
gdialog_backgro.Y = dialog_topleft.Y;
gdialog_backgro.Height = gdialog.Height;
gdialog_backgro.Width = gdialog.Width;


Where dialog_topleft is the top-left corner graphic used in the text-window GUI (gdialog).

The first problem: With this code, gdialog_backgro NEVER appears.

The second problem: If I just set gdialog_backgro to always be shown, the re-sizing and re-positioning doesn't work either. It just stays in same place on the screen, at the same size regardless of dialog options appearing.

i.e. like this (where the GUI in question is the semi-transparent rectangle thing):



This is a long and annoying issue, so I hope I've put it clearly.

Thanks in advance,
Mark
 

Calin Leafshade

where do you get dialog_topleft from?

something like this?

Code: ags


DialogOptionsRenderingInfo *dialog_topleft;


markbilly

You can name the text window edges, so that is just the name of the top-left edge.
 

Vince Twelve

The top-left edge would have an x and y of zero.  You'll want to grab the x and y coordinates from the parent gui (and then, if necessary, add the x and y vals of the edge components)

As far as it not showing up at all, check the General Settings panel under "Run game loops while dialog options are displayed".  I think dialogs by default block even rep_ex_always. (IIRC)

markbilly

Thanks Vince. Tried both those things:

1. re: appearing: it still doesn't appear.

2. re: positioning: it still doesn't change at all. It is now fixed in the middle though and it slightly wider and less tall.

:-\
 

Vince Twelve

#5
Yeah, I just ran a test and the dialog GUI is still set to visible=false, x=0, y=0, width=200, height=100 whether it's currently on screen showing dialog options or not.  So, my suggestion won't work.

I've never used Text Window GUIs before (Resonance doesn't use AGS' dialog system, instead using a custom module and custom GUIs), so I didn't know this before, but you'll need to use DialogOptionsRenderingInfo functions to get at this info.

Edit: I'm messing with this and it looks like you may not be able to get the auto-generated values for the dialog out of this, rather it's used for setting it up yourself.  So, the only solution might be to custom render your dialog boxes and set the transparent background that way.  A lot of work.

Any one else played with this before and know of a better way?

Dualnames

I know one thing out of a personal experience (that doesn't mean its true or shit)

I'd put this code BEFORE displaying the dialog. It only needs to run once anyhow(in your case it doesn't even run that much). Adding a wait in the end would help things up.
Code: ags

gdialog_backgro.Visible = gdialog.Visible;
gdialog_backgro.X = dialog_topleft.X;
gdialog_backgro.Y = dialog_topleft.Y;
gdialog_backgro.Height = gdialog.Height;
gdialog_backgro.Width = gdialog.Width;
Wait(1);


Additionally if this shit doesn't start again, try AnimationRunScript module. It runs a code at a specific animation frame. So if all your dialogs have a @S, it'd be the best out of you, to place that code (without the wait) on that module. This is the only thing I managed to do something equivalent, so you may go  like "Damn, dualnames is stupid".
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

markbilly

#7
So I need to put that before EVERY dialog in the game shows? I have dozens of them! :D

Nevermind. If it works, it works. I'll go and have a try now.


EDIT: No luck. I'll have to try that module next...
 

Calin Leafshade

With regards to your "do i have to do it at ever @#": Yes I'm afraid so.

Rep_ex doesnt seem to run normally when dialogs are displayed and I cant find a way of testing whether or not they are being displayed.

so, yea... sorry bout that.

monkey0506

This might be a stupid question, but do you have "Run game loops while dialog options are displayed" (General Settings -> Dialog) set to True? This is not the default setting..and if it's set to the default of false then your code would never be run.

Beyond that, if you opt to use the custom dialog rendering functions instead of the built-in renderer, then you could check to see if a dialog is running by writing a custom wrapper function for StopDialog and using a DialogOptionsRenderingInfo* to store the last running dialog.

dialog_options_get_dimensions indicates a dialog being started, so you could store that DialogOptionsRenderingInfo. In your custom StopDialog function you would simply clear the pointer by setting it to null.

You would test if there was a dialog running by checking if the pointer was null or not.

markbilly

@monkey_05_06 I have that option set to true, yes.

As for this general problem with gui transparency, I got Mr Names on the case and he says it can't be done.
 

Dualnames

#11
I'm not aware of the dialog rendering info crap, but with the rest of the commands, its not doable, at least not unless a workaround ensues. I can give you what I used for Cat Lady, long before custom dialog GUI module could exist (and therefore the functions). Which is a very customizable gui, that you can put transparency GUI behind. But if you're gonna do that you might as well use custom dialog GUI.

EDIT:
  gdialog_backgro.Visible = true;
  String large=dDialog1.GetOptionText(1);
  //gdialog_backgro.X =(gdialog.Width/2)+(large.Length)-(31);
//-(dialog_topright.X);
// Display("%d %d",gdialog.Width,dialog_topleft.X);
  //gdialog_backgro.Y = 100-(gdialog.Height/2);
gdialog_backgro.Height = (gdialog.Height/2)+(dDialog1.OptionCount*4);
gdialog_backgro.Width = (gdialog.Width/2)+(large.Length);
gdialog_backgro.Centre();
gdialog_backgro.Y=gdialog_backgro.Y+5;

The things get easier with the centering cause that's what AGS does. It actually probably centers the controls on a GUI, but anyhow. Here'smy best effort, it won't work, but perhaps someone can find an algorithm.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

I was thinking about this, and using a text window GUI it probably won't be technically feasible to do this because of the delayed updating of the GUI's visibility (i.e., actually being rendered as visible on-screen). However, you can accomplish this by using the custom dialog rendering functions (as I mentioned before).

For that I would actually recommend checking out the CustomDialogGUI module, which simplifies the setup for you.

I just wanted to reiterate for you that this is technically possible, just not how you're approaching it right now.

SMF spam blocked by CleanTalk