project-navigation
Personal tools

Author Topic: Get to Market menu from Equipment Menu  (Read 4502 times)

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Get to Market menu from Equipment Menu
« on: February 12, 2010, 05:00:14 am »
I would like to be able to push the market menu from the equipment menu so that I can request weapons, armour, equipment, etc. for my units instead of having to back all the way out.  I guess while I am requesting it, being able to push production menu from equipment menu may also make sense.

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #1 on: February 13, 2010, 05:53:55 pm »
Also thought it might be nice to have the transfer menu available as well.  

Made a user modification, but since this version is still in development and can change from current revision, thought I would place the code here:

Code: [Select]
button buysell
{
string "_Buy/Sell"
tooltip "_Buy/Sell equipment"
image ui/button_background
pos "387 127"
size "100 25" 
selectcolor "0 0.8 0 1"
color "1 1 1 1"
font f_small
onClick { cmd "mn_push market;" }
}

button production
{
string "_Production"
tooltip "_Produce new equipment"
image ui/button_background
pos "387 160"
size "100 25"
color "1 1 1 1"
selectcolor "0 0.8 0 1"
font f_small
onClick { cmd "mn_push production;" }
}

button transfer
{
string "_Transfer"
tooltip "_Transfer equipment or personnel"
image ui/button_background
pos "387 193"
size "100 25"
color "1 1 1 1"
selectcolor "0 0.8 0 1"
font f_small
onClick { cmd "mn_push transfer;" }
}

This was modified code taken from bases.ufo, why reinvent the wheel.  I placed this code at the end of equipment.ufo right above this code:
Code: [Select]
// ==================
// additional stuff
// ==================


As you can see I used a background image already there, though I am not sure if I like the onover event of that background image.

This enables access to the market, production, and transfer menus from the equipment menu, if I need it.  
« Last Edit: February 13, 2010, 06:03:27 pm by joe davis »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #2 on: February 13, 2010, 07:56:59 pm »
Have you tested it? The problem is not scripting the buttons, but updating the equipment menu on return.

-geever

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #3 on: February 13, 2010, 10:11:37 pm »
Ouch.  I apologize for posting it without testing it.  Like I said, I can be slow at times.  Thank you for catching that. 

Ok, so I checked it again and everything works except, like you said, the equipment that I bought or sold is not updated so it doesn't look like I did anything, but when I back out of it one level and click back in it is updated and it shows that it worked correctly. 

So how does one refresh that information without having to back out and reenter?  Is there a way of doing a callback?  Is there an onEvent event that fires that can be used?  I am stumped here.  Through me a friggin bone.  lol.

ok, so since I am not a dev, and this is a user modification, and I dont have to be proper with my methods, only functional, I add this at the end of my previous code:
Code: [Select]
button refresh
{
string "_Refresh"
tooltip "_Refresh Inventory"
image ui/button_background
pos "387 293"
size "100 25"
color "1 1 1 1"
selectcolor "0 0.8 0 1"
font f_small
onClick { cmd "team_updateequip;update_item_list;" }
}

my screen looks like the picture attached below.  It's functional.  It does the job, but I aint happy about it.  Sure, for my purposes it works, and I don't have to back out of the screen 2 levels to buy something I forgot to buy and then click in 2 levels to equip it, but it aint right. 

How do I fix it please?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #4 on: February 14, 2010, 01:15:17 am »
Event listeners can solve this problem:

Code: [Select]
confunc equipment_buysell_listener
{
    cmd "team_updateequip; update_item_list;"
    cmd "mn_removelistener market@onClose <path:this> ;"
}

button buysell
{
string "_Buy/Sell"
tooltip "_Buy/Sell equipment"
image ui/button_background
pos "387 127"
size "100 25" 
selectcolor "0 0.8 0 1"
color "1 1 1 1"
font f_small
onClick {
                     cmd "mn_addlistener market@onClose <path:root>.equipment_buysell_listener"
                     cmd "mn_push market;"
               }
}


I hope it's clear how this works. ;)

-geever

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #5 on: February 14, 2010, 09:13:37 pm »
That is pretty cool.  So I can place an onclick event in the buy\sell button which will add an event listener for a different node.  When the event occurs the code in the confunc will be triggered to update the information and remove the listener, (in this example). 

The mn_addlistener command requires 2 parameters: event to listen for and the confunc script to perform when the event is triggered.

we want to remove the listener when we are done with it.

The mn_removelistener command requires 2 parameters: event to stop listening for and a path.  What is the path to?  Will it always be <path:this> and if so, why require it?

Sweet, now I can remove the refresh button and it's code from my second posting and replace my buy\sell button with the code you disclosed in your latest posting, giving me the ability to navigate to the market (buy\sell) menu, the production menu, or the transfer menu directly from the equipment menu.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Get to Market menu from Equipment Menu
« Reply #6 on: February 14, 2010, 09:21:05 pm »
The mn_removelistener command requires 2 parameters: event to stop listening for and a path.  What is the path to?  Will it always be <path:this> and if so, why require it?

It's the path to the confunc to remove.

-geever