I'm trying to develop a GUI for a game. The idea in my mind is something around the line of the "7 Days a Stranger" GUI (left click walk, right click pops up a menu with inventory/actions).
I hoped to find a template or some similar resource to study the code of a similar GUI. Searching the forum I've found the GUI of Larry 7; unfortunately the template is very buggy on the lastest version of AGS.
Is there any reliable template/code of a similar GUI to study from?
Thank you in avance
The AGS resources page has two templates that seem to have what you need: Beneth A Steel Sky template and the ALARCOST one. I suggest you try them out, they are simple and easy to modify. BASS incudes a small demo too, so that should get you started well enough.
On the other hand, maybe it would be enough to edit the on_mouse_click section like this:
function on_mouse_click(MouseButton button) {
if (IsGamePaused() == 1) { } // Game paused, do nothing
else if (button == eMouseLeft)
{
ProcessClick(mouse.x,mouse.y, eModeWalkTo);
}
else {
gCustomInv.Visible = true;
}
}
All you would need to do then is to include a gCustomInv inventory window that will stay on-screen, which can be easily done by adding a "close" button. You can just
use the Inventory GUI that is part of the Default Game template.
Hope that was helpful.
Quote from: Ghost on Sat 03/11/2007 15:01:29
All you would need to do then is to include a gCustomInv inventory window that will stay on-screen, which can be easily done by adding a "close" button. You can just
use the Inventory GUI that is part of the Default Game template.
Hope that was helpful.
Sounds effective and deliciously simple, I'll try it out. Thank you!
Always a pleasure, and should you run into any troubles, just say the word.
From there, I'd go like this:
Store the coordinates of the right click, wait for a click on an inv item and call ProcessClick.
In General Settings, check "Handle inv clicks in script".
int ax, ay;
function on_mouse_click(MouseButton button) {
...
else if (button==eMouseRight) {
ax=mouse.x;
ay=mouse.y;
gCustomInv.SetPosition(ax-10, ay-10);
gCustomInv.Visible=true;
}
else if (button==eMouseLeftInv) {
InventoryItem*ia=inventory[game.inv_activated];
int mode;
if (ia=iEye) mode=eModeLook;
else if (ia=iHand) mode=eModeInteract;
else if (ia=iMouth) mode=eModeTalkto;
else {
mode=eModeUseInv;
player.ActiveInventory=ia;
}
gCustomInv.Visible=false;
ProcessClick(ax, ay, mode);
}
else if (button==eModeRightInv) {
inventory[game.inv_activated].RunInteraction(eModeLook);
}
}
function repeatedly_execute() {
// turn off inv GUI if mouse leaves it
if (gCustomInv.Visible && GUI.GetAtScreenXY(mouse.x, mouse.y)!=gCustomInv)
gCustomInv.Visible=false;
}
}
Instead of putting a Display command in every inv item's look at event, you can put the description in a custom property (type: String, name: "desc", default value "I don't see anything interesting.").
If you want to do more than display a sentence, enter "process" as description, then use this:
else if (button==eModeRightInv) {
String s=inventory[game.inv_activated].GetTextProperty("desc");
if (s=="process") inventory[game.inv_activated].RunInteraction(eModeLook);
else Display(s);
}
The code was written off the top of my head so it might not work as-is.
Awesome, I was developing something similar but this seems a simpler and more sound path. Thank you!
Quote from: KhrisMUC
The code was written off the top of my head
I'm seriously starting to suspect that you're a replicant.
Glad to be of help.
It's 5 Days a Stranger and 7 Days a Skeptic, btw. ;)
Quote from: KhrisMUC on Sat 03/11/2007 20:02:23
Glad to be of help.
It's 5 Days a Stranger and 7 Days a Skeptic, btw. ;)
:o zomg Glucose deficit! I'll correct the mistake in the main subject to help future forum searches
Khris's not a replicant. He's the Neo of the AGS matrix.
Seriously, solid code there, Khris. I never got the hang of writing that stuff by heart.
I've fleshed out the gui the way I wanted and everyting works perfectly but still there is a bit of code I cannot make run the way I want
// Inventory: Left click examine
if (button == eMouseRightInv) inventory[game.inv_activated].RunInteraction(eModeLookat); //KhrisMUC dixit
// Inventory: R click use with underlying object
if (button == eMouseLeftInv) inventory[game.inv_activated].RunInteraction(eModeUseinv);
the first half works fine (i.e. if I rightclick on the object it LOOKS AT
I desire , with a left click, an USE WITH (inventory item on hotspot clicked) (use inventory) action.
I did set up I simple trigger in the interaction editor of a sample room (use inventory on hotspot / if inventory item was used...).
Unfortunately that does not work. Wrong function in the script or wrong use of the interaction editor?
That's why I've used ProcessClick, to avoid going through the trouble of getting the hotspot.
You aren't calling "Use inv on hotspot", you're calling "Use inv on inv" (Since you're running the use inv-interaction of inventory[game.inv_activated], not the hotspot's under the mouse).
Did you try my code? Did it fail to work?
To make your method work, you'd need something like
if (button==eMouseLeftInv) {
Hotspot*h=Hotspot.GetAtScreen(mouse.x, mouse.y);
if (h!=null) h.RunInteraction(eModeUseinv);
}
The thing is, this won't cover Objects or Characters. If you simply use ProcessClick instead (like I did in my example code), you'll get exactly what you want.
Quote from: KhrisMUC on Mon 05/11/2007 00:13:20
That's why I've used ProcessClick, to avoid going through the trouble of getting the hotspot.
Did you try my code? Did it fail to work?
I had cannibalized the old code enough to mess it up. The explanation brought knowledge and awareness and made me a wiser fellow. Again thank you