is there a way to point CMlControl by Ident on a CMlPage ?

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
reaby
Posts: 1026
Joined: 29 Dec 2010, 23:26
Location: Eastern Finland
Contact:

is there a way to point CMlControl by Ident on a CMlPage ?

Post by reaby » 09 Dec 2017, 18:11

Hi,

I would like to find CMlControl in CMlPage by Ident... is it posssible a fast way ?

reaby
Posts: 1026
Joined: 29 Dec 2010, 23:26
Location: Eastern Finland
Contact:

Re: is there a way to point CMlControl by Ident on a CMlPage ?

Post by reaby » 09 Dec 2017, 18:16

I think using Classes as indexes doesn't work out good...

declare Integer[CMlLabel] for Page = Integer[CMlLabel];

Code: Select all

 Void TriggerConfirmButtonClick(CMlLabel Control) {
                   
                   log(Control);    // Control  = CMlLabel#1234    
              
                   if (Control.Parent.HasClass("uiButton")) {                  
                          if (pendingConfirmIds.existskey(Control.Id) == False) {
                                pendingConfirmIds[Control.Id] = Control.Value;
                                pendingConfirms[Control] = Now;     // Control = CMlLabel#Null
                        }
                  }
....
So best way to fix this would be to point control by ident :)

reaby
Posts: 1026
Joined: 29 Dec 2010, 23:26
Location: Eastern Finland
Contact:

Re: is there a way to point CMlControl by Ident on a CMlPage ?

Post by reaby » 09 Dec 2017, 19:01

ok Answering myself, fixed by adding

Code: Select all

   declare CMlLabel[Ident] pendingConfirmControls for Page = CMlLabel[Ident];
   pendingConfirmControls[Control.Id] = Control;
It kinda looks stupid on code side when there's 3 variables doing "same" thingy... but it works.

zocka
Posts: 205
Joined: 15 Jun 2010, 17:56

Re: is there a way to point CMlControl by Ident on a CMlPage ?

Post by zocka » 10 Dec 2017, 11:10

(You are not trying to use classes as index values but objects (= instances of classes).)
Using objects as index values should work (as the array-key hashing probably already works on the idents).

I can't reconstruct and don't understand your problem from what you are providing.

As you probably are only concerned for a certain set of controls to find by ident (say elements with a certain class), you could initially build yourself a map with ident=>control. Keep in mind that you would probably want each element from your GetClassChildren_Result in a temporary variable to not accidently lose track of it along the way.

From the snippets you provided I don't see why you would need so many arrays. If you keep track of the controls themselves, you don't need to store e.g. the Label's text alongside as you can access it from the control anyway. In the same way you can declare additional variables like this Now-value for the control.
manialink minigame shatter
my manialink: zockaml
my maniaflash: maniaflash?zocka

reaby
Posts: 1026
Joined: 29 Dec 2010, 23:26
Location: Eastern Finland
Contact:

Re: is there a way to point CMlControl by Ident on a CMlPage ?

Post by reaby » 11 Dec 2017, 20:11

thanks!

Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest