Jump to content


Photo

Conditions And Total Number Of Menu Items


  • Please log in to reply
7 replies to this topic

#1 diffident

diffident

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 06 February 2004 - 12:14 PM

I'm thinking about a new skin, and there are two questions I can't answer:

First, is it possible to nest conditions to get the equivalent of

IF x AND y THEN z
or
IF x OR y THEN z

I could probably get a similar effect by clever layering of items, but I'd love there to be an easier way.

Second, I'm wondering whether a skin can discover and use the total number of items in a menu, so you could show, for instance, the string 'There are 9 games in this list'?

Thanks for any advice.



#2 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 06 February 2004 - 02:54 PM

Well, the first question will really be: Are you writing a script or skin? Because as of now, skins don't support scripting features.

As for nesting (it's not elegant, but it works)

IF x AND y THEN z
CODE
IF x THEN
IF y THEN
z
ENDIF
ENDIF


IF x OR y THEN z
CODE
IF x THEN
z
ENDIF
IF y THEN
z
ENDIF

Or you could use GOTO's
CODE
IF x GOTO trueCondition
IF y GOTO trueCondition
GOTO falseCondition
:trueCondition
z
:falseCondition


This is better in the sense that it doesn't require writing z twice.



Don't think as skin can do that for now.

#3 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 06 February 2004 - 03:22 PM

I think he's referring to the use of conditionals in skin elements.

All skin conditionals also have "not" equivalents; which ones are you looking to use, and for what effect?

#4 diffident

diffident

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 07 February 2004 - 07:01 AM

Yes, I'm thinking of conditionals in skin elements. I'm muddling some ideas around in my head, and in this case what I wanted to be able to do was (uninteresting in itself) to pick out all the odd (and later all the even) numbered items in a short (root) menu, ie

IF this is the MainMenu AND ItemSelected is number 1 OR 3 OR 5 THEN show this element
otherwise
IF this is the MainMenu AND ItemSelected is number 2 OR 4 THEN show this element

I could do the numerical OR bit with a list of individual elements

<LayoutElement Type="Image" Source="Whatever">
<Condition Arg1="1">ItemSelected</Condition>
</LayoutElement>

<LayoutElement Type="Image" Source="Whatever">
<Condition Arg1="3">ItemSelected</Condition>
</LayoutElement>

and so on, but as far as I can see to do the AND starts to require clever element layering (a layer to hide all this stuff if it's NOT the MainMenu or something like that), so I wondered if there was an easier more general way available to skinners, that would make this kind of IF/THEN/AND/OR stuff easy:

<Condition>MainMenu</Condition> AND <Condition arg="1">ItemSelected</Condition> OR <Condition arg="3">ItemSelected</Condition>

or something...

For this trivial application it would also be interesting to be able count the number of items in a menu, although I'm racing on to something like 'for ItemSelected is ODD from 1 to Count of Menu items' which is unlikely to happen smile.gif

I was just thinking last night what a great thing it is to have a community where you can toss out questions like this and know someone's going to try to help.

Thanks all.

#5 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 07 February 2004 - 12:10 PM

Well, the conditionals are "AND" only, but through clever usage of the NOT, you could simulate the OR operation.

#6 diffident

diffident

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 15 February 2004 - 03:53 PM

QUOTE
conditionals are "AND" only


BJ, this doesn't mean I could use several conditionals for one element to get a logical AND does it? I mean like this:

<LayoutElement Type="Image" Source="Whatever">
<Condition>ItemEntry</Condition>
<Condition Arg1="0">ItemSelected</Condition>
</LayoutElement>

(ie IF the currently selected item isn't a submenu AND it's the first item in the list THEN show this image)

I've had a fairly thorough go at making this work, but I can only get the first conditional to have any effect (I'm testing using the WIP, so the <Condition Arg1="0">ItemSelected</Condition> does work on its own, or if I put it first).

Have I misinterpreted what you meant?


#7 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 15 February 2004 - 05:31 PM

QUOTE (diffident @ Feb 15 2004, 12:53 PM)
QUOTE
conditionals are "AND" only


BJ, this doesn't mean I could use several conditionals for one element to get a logical AND does it? I mean like this:

<LayoutElement Type="Image" Source="Whatever">
<Condition>ItemEntry</Condition>
<Condition Arg1="0">ItemSelected</Condition>
</LayoutElement>

(ie IF the currently selected item isn't a submenu AND it's the first item in the list THEN show this image)

I've had a fairly thorough go at making this work, but I can only get the first conditional to have any effect (I'm testing using the WIP, so the <Condition Arg1="0">ItemSelected</Condition> does work on its own, or if I put it first).

Have I misinterpreted what you meant?

I believe all conditionals need to pass in order for the item to be displayed. It should work... but I haven't tested it much.

#8 diffident

diffident

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 16 February 2004 - 11:34 AM

QUOTE (BenJeremy @ Feb 15 2004, 07:31 PM)
I believe all conditionals need to pass in order for the item to be displayed.  It should work... but I haven't tested it much.

I'll give it another go - that's what I thought you meant.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users