Hey all,
I've searched this and seems to be a few threads, but all are over my head. They seem a little more complex than what I'm looking to achieve.
I'm using a Sierra based UI. However, I've decided to make this a persistent bar in the bottom of the screen (which works for the most part).
I wanted to 'do away' with the inventory button/ui completely and simply use the inventory window contained within the gIconbar GUI for all of my inventory shenanigans.
I have posted an image below to explain fully what I'm trying to achieve.
(http://i58.tinypic.com/2uievtc.jpg)
I'm starting to feel sheepish about asking such rudimentary questions on the forums. I'm honestly happy to donate or contribute a couple of bucks if needed.
Many thanks in advance.
this is what I would do....
In the Global Script,
bool overmenubar; //declare at top of script
function repeatedly_execute()
{
if (GUI.GetAtScreenXY(mouse.x, mouse.y) == gInventory)
{
if (overmenubar == false)
{
mouse.Mode = eModePointer;
overmenubar = true;
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeTalkto);
//etc...
}
}
else
{
if (overmenubar == true)
{
overmenubar = false;
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeLookat);
//etc...
}
}
}
If you want this behaviour regardless of cutscenes, or any other blocking scripts use: function repeatedly_execute_always()
but I don't think you'll really want that...
Give it a try :)
Here there's an error :
if (overmenubar= false) //here
{
}
else
{
if (overmenubar= true) //and here too
{
}
}
Thank guys, I will apply this tonight.
Is there a particular spot in the Global script that this should go?
Never be afraid to ask questions, that's what the AGS community is all about!
Quote from: Vincent on Tue 20/10/2015 18:20:18
Here there's an error :
if (overmenubar= false) //here
{
}
else
{
if (overmenubar= true) //and here too
{
}
}
-sorry. See fix above
-put it in your global script, the repeatedly_execute function should already exist, just place it inside there as in the example. Just make sure you declare the Bool at the top of the global script.
Quote from: MiteWiseacreLives! on Wed 21/10/2015 07:27:25
-sorry. See fix above
I Think that's okay :)
Quote from: Nixxon on Tue 20/10/2015 12:12:10
I wanted to 'do away' with the inventory button/ui completely and simply use the inventory window
I think it can be useful to have a look at this section too in the manual.
GetAtScreenXY (GUI control)Checks whether there is a GUI control at screen co-ordinates(X,Y). Returns the control object if there is, or null if there is not.
You probably want to use this in conjunction with GUI.GetAtScreenXY(mouse.x, mouse.y);
GuiControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == invCustomInv)
{
Display("The mouse is over the Inventory window.");
}
else if (theControl == null)
{
Display("The mouse is not over a control.");
}
else
{
GUI *onGui = theControl.OwningGUI;
Display("The mouse is over control %d on GUI %d", theControl.ID, onGui.ID);
}
Sorry guys,
Is there a specific place to paste the bool line of code?
Quote from: MiteWiseacreLives! on Wed 21/10/2015 07:27:25
Quote from: Vincent on Tue 20/10/2015 18:20:18
-put it in your global script, the repeatedly_execute function should already exist, just place it inside there as in the example. Just make sure you declare the Bool at the top of the global script.
Think I've cracked this....
Works OK so far. However, is there a way to make the mouse resume the previous mouse mode if nothing is clicked or selected?
This would be GOLD.
For this, declare
int old_mouse_mode;
Again at the top of the global script.
Then just before we set the cursor to pointer:
old_mouse_mode = mouse.Mode;
Then just after enabling all the mouse modes again do:
mouse.Mode = old_mouse_mode;
I'm not able to test this right now, but you should be able to get it to work. If not maybe one of the über_scripters can chime in here... :)
Yes,
Something along these lines (old code using int old_mode):
function repeatedly_execute_always() {
GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
if (theGui == gRestoreGame && mouse.Mode != eModePointer){
old_mode=mouse.Mode;
mouse.ChangeModeGraphic (eModePointer, 6);//2061
mouse.Mode = eModeInteract;
}
if (theGui == gInventory){
old_mode=mouse.Mode;
mouse.GetModeGraphic(eModeUseinv);
}
if (theGui != gRestoreGame && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 6)
if (theGui != gPanel && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 6)
{
mouse.Mode=old_mode; // Reverts to previous mode
}
}
Hey guys,
Works with the below code. However it works over the whole GUI (which makes it impossible to select any modes to use on the screen walk/look etc.), is there a way to make the return function work only on the inventory window, not the whole GUI?
EDIT - I could probably make a single UI just for the inventory window and put it on top of the menu bar, this might be the best option?
(http://i58.tinypic.com/2uievtc.jpg)
function repeatedly_execute() {
// Put here anything you want to happen every game cycle, even when
// the game is paused. This will not run when the game is blocked
// inside a command like a blocking Walk()
if (GUI.GetAtScreenXY(mouse.x, mouse.y) == gIconbar)
{
if (overmenubar == false)
{
old_mouse_mode = mouse.Mode;
mouse.Mode = eModeInteract;
overmenubar = true;
mouse.DisableMode(eModeTalkto);
//etc...
}
}
else
{
if (overmenubar == true)
{
mouse.Mode = eModeInteract;
overmenubar = false;
mouse.Mode = old_mouse_mode;
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeTalkto);
//etc...
}
}
}
Maybe try
GUIControl.GetAtScreenXY() == [insert name of your inventory window]
Instead of checking for the entire GUI
Tried that one initially but it posted an error, something about not a valid GUI.
EDIT - I've made a new GUI with an inventory window using the above code. Now when I select and inventory item, as soon as I leave the GUI it goes back to the previous mode mode. Is there a way I can make it not return to previous mouse mode If I've selected an inventory item?
This is because of the mouse.Mode = old_mouse_mode
You want to add an if statement before this:
If(mouse.Mode != eModeUseInv) {
mouse.Mode = old_mouse_mode;
}
Check my syntax, type it in instead of copy paste.. It will make more sense to you and AGS' nice auto correct will take care of any typos and show you a list of options.
I get that you're not the most experienced coder, but doesn't this question sort of answer itself?
Yes, you just write a line of code to check whether there's an inventory item selected, and if so you skip the chunk of code that returns to previous mouse mode.
It's complete hieroglyphs at this point. I already have an if statement, am I able to have two following each other?
Error - undefined token 'IF".
If I could just see where to put the code, I know it would make sense. (Invention via necessity).
function repeatedly_execute() {
// Put here anything you want to happen every game cycle, even when
// the game is paused. This will not run when the game is blocked
// inside a command like a blocking Walk()
if (GUI.GetAtScreenXY(mouse.x, mouse.y) == ginvwindow)
{
if (overmenubar == false)
{
old_mouse_mode = mouse.Mode;
mouse.Mode = eModeInteract;
overmenubar = true;
mouse.DisableMode(eModeTalkto);
//etc...
}
}
else
{
if (overmenubar == true)
{
mouse.Mode = eModeInteract;
overmenubar = false;
mouse.Mode = old_mouse_mode;
mouse.EnableMode(eModeLookat);
//etc...
}
}
}
Yes you can have if statement inside of another.
Not to be insulting, but are you actually reading my replies?
The code goes where I indicated, inside of the (overmenubar == true) block of code, you want to intercept the mouse.Mode = old_mouse_mode
If this is still not clicking for you I can get on my computer and type up the code for you later.
Quote from: MiteWiseacreLives! on Wed 28/10/2015 02:16:52
Yes you can have if statement inside of another.
Not to be insulting, but are you actually reading my replies?
The code goes where I indicated, inside of the (overmenubar == true) block of code, you want to intercept the mouse.Mode = old_mouse_mode
If this is still not clicking for you I can get on my computer and type up the code for you later.
No insult taken at all, I did try the code provided 5-6 different which ways before resorting to the boards, I always do.
I'll give it a go when I get home, thanks again for the patience and assistance.
Quote from: Nixxon on Wed 28/10/2015 03:30:09
Quote from: MiteWiseacreLives! on Wed 28/10/2015 02:16:52
Yes you can have if statement inside of another.
Not to be insulting, but are you actually reading my replies?
The code goes where I indicated, inside of the (overmenubar == true) block of code, you want to intercept the mouse.Mode = old_mouse_mode
If this is still not clicking for you I can get on my computer and type up the code for you later.
No insult taken at all, I did try the code provided 5-6 different which ways before resorting to the boards, I always do.
I'll give it a go when I get home, thanks again for the patience and assistance.
ok so if your actually trying to learn here...
function repeatedly_execute() {
// Put here anything you want to happen every game cycle, even when
// the game is paused. This will not run when the game is blocked
// inside a command like a blocking Walk()
if (GUI.GetAtScreenXY(mouse.x, mouse.y) == ginvwindow) //every game cycle we check if the mouse is over the inventory window
{
if (overmenubar == false) // checks if we are already over the inventory window, if so skip this code we only need do it once.
{
old_mouse_mode = mouse.Mode; //store the current mouse mode
mouse.Mode = eModeInteract; // change mode to the interact/pointer cursor
overmenubar = true; // set to true so this block of code doesn't run endlessly
mouse.DisableMode(eModeTalkto); // start disabling all the mouse modes so player doesn't cycle through them
//etc here insert the rest of the mouse.DisableMode(eMode...); lines you need dependant on the mouse modes in your game.
}
}
else // if the mouse is not over the inventory window
{
if (overmenubar == true) // if this is true, the mouse must have just been over the inventory window
{
// mouse.Mode = eModeInteract; <----- remove this line! it will simply change cursor to the interact mode!!
overmenubar = false;
if (mouse.Mode != eModeUseinv) { //so if the mouse mode is anything other than Use Inventory Mode
mouse.Mode = old_mouse_mode; // set it to the mouse mode the player had before entering the area of the inventory window,
}
// otherwise it will leave the cursor as a selected inventory item.
mouse.EnableMode(eModeLookat); // now Look At is available to the player again.
//etc... insert all the mouse modes you want to re-enable like: mouse.EnableMode(eModeInteract);
}
}
}
Study this and you should understand what we are coding here and be able to carry on from this point (not that you shouldn't continue to ask for help if needed...)
Remember that repeatedly_execute runs 40 times / second, unless the game is paused.
Wow, haven't tried this yet, but that's truly amazing thank you.
I will leave the eModeInteract line of code, as for some reason the pointer doesn't seem to select inventory items.
EDIT, still no cigar :( Whilst the code doesn't run any errors, the cursor still returns to the previous mode when the cursor leaves the ginvwindow GUI. Ultra poop.
EDIT 2 - NEVERMIND, I see why I had to remove the Modeinteract in the second part of the code!!! Works brilliantly now. Thank you so much.