HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ItemMenu v2

12-11-2007, 06:34 PM#1
weaaddar
Well I've tweaked my itemMenu interface to make it a bit more friendly and to use the better vJass support for inheritance.
The goal is same as before make easier to develop item menus and to stop having to worry about interoperability (i.e. what happens if I'm exiting from nuetralMenu vs exiting from menu2 vs exiting from menu3).

Essientially there are 2 methods that every menu must implement onOpen & onInterupt, the interupt method fires when another menu B wants to take control of the item paine from menu A. Once A finishes closing the menu, B executes its onOpen method, which is like a setup variables method, and then B's menu is open.
In more generic terms: B makes a request for A's resource (The item paine) and sleeps until it recieves the lock. A is notified, and executes whatever code it needs to do to give up the lock, and then gives up the resource to B. B is awoken and does all set up before recieving the resource. B then recieves the resource and set up events and code accordingly.

Since warcraft 3 only has one thread execute at once, there is only one process wanting a held resource at any given time.

The itemMenu also includes standard event responses that are commonly used in menu implementations including onItemUse,onItemDrop & onItemDrag. Which corresponds to using an item, dropping an item, or drag and dropping an item. If an item is used to completion use then drop are fired. These are all optional event responses.

Built in, the following actions are taken:
onItemUse
Hitting Cancel will return to the Menu's exitmenu.
Hitting NextPage will show the next page of the menu's content.

onItemDrop
will remove the item from the vector & redisplay the current page after a delay of 0

onItemDrag
Will change the position of the dragged and droped item in the internal item vector.


I have included in this demo a stat attributer to show a nontrivial example.


I'm actually still abit annoyed as I want a real abstract class, as currently we get this wierdness.
Collapse JASS:
Interface IClass
 method mustbeImplementedByAllChildren takes nothing returns nothing
endinterface
struct AClass extends IClass 
  method mustbeImplementedByAllChildren takes nothing returns nothing
   //I have to implement this otherwise this won't compile!
  endmethod
  method usefulMethodForAllChildren takes nothing returns nothing
  //blah blah
  endmethod
endstruct

struct myClass extends AClass
 static string what="Oh, I guess I ddin't really need to implement mustbeImplemented!"
endstruct

Another annoying thing is the following
Collapse JASS:
interface Ibase
 method initStuff takes nothing returns nothing
interface
struct base extends Ibase
     method initStuff takes nothing returns nothing
           call BJDebugMsg("1")
     endmethod
     static method create takes nothing returns base
         local base b=base.allocate()
         call b.initStuff()
         return b
     endmethod
endstruct

struct child extends base
       method initStuff takes nothing returns nothing
           call BJDebugMsg("2")
       endmethod
endstruct
...
child.create()
The above should print 2, but will print 1 as the child does not actually know his own type until after the constructor of the base finishes.
Attached Files
File type: w3xitemMenu.w3x (38.4 KB)
12-11-2007, 08:21 PM#2
WNxCryptic
I've been looking for a leaner bag type system, but I'm curious.

Is this release / system designed to only be a collection of triggers and functions that must be built upon to be useful, or is that a system that is technically ready for use in a map?
12-11-2007, 08:37 PM#3
weaaddar
its a basis. It should allow the development of a bag to be relatively simple.

I'm going to write new pItems and then I'll probably whip up a demo bag. Since arrays are static theres a fixed limit of 12, but I don't really think thats a big deal.
12-11-2007, 08:51 PM#4
PipeDream
Nice job, absurdly comprehensible compared to your previous work.

Abstract stuff: It's not weird, it's an idiom =)
01-12-2008, 01:00 AM#5
Malf
Yes, I'm officially a threadromancer, but..

When I exit the first menu, the one which contains the two keys, the items I previously had vanish. I tested the first version, and the items I had weren't removed.

There's something wrong around the OnInterrupt part, I believe it to be the cause of why my items(items i had before opening the menu) vanish after I close the menu. This happens with all menus, also attributer.
01-13-2008, 12:49 AM#6
Malf
Bump you niggers, I need it badly.
01-19-2008, 08:45 PM#7
weaaddar
Quote:
Originally Posted by Malf
Yes, I'm officially a threadromancer, but..

When I exit the first menu, the one which contains the two keys, the items I previously had vanish. I tested the first version, and the items I had weren't removed.

There's something wrong around the OnInterrupt part, I believe it to be the cause of why my items(items i had before opening the menu) vanish after I close the menu. This happens with all menus, also attributer.
It might be a vjass dependency thing. I know in the demo map it works fine (I just tested it).
01-19-2008, 09:10 PM#8
Vexorian
That would be a very odd thing.

Now, if it was a simple bug then it is possible, but without looking at scripts I have no idea.

Couldn't it just be some rogue trigger you have, Malf?
01-19-2008, 11:44 PM#9
Malf
I tested the demo map itself.

weaaddar, what version of JNGP do you have? I have 4a right now and I remember I updated JASSHelper to 0.9.9.7

I'll try to update to the latest version and test it again.
01-20-2008, 03:02 AM#10
Malf
Ohhhhh you sneaky little nimja, it works well when I upgraded to the latest version. So, what could've possibly done this in 4a and what fixed this in 4c?

Oh and btw, are you updating this weaaddar? If you are, can you possibly add support for saving/loading the hero with all his items, bags, stats, statpoints, etc,.?

Sorry for the double, but this is important.