• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

UI - Listbox help

Status
Not open for further replies.
Level 5
Joined
Apr 8, 2008
Messages
88
Can i in any way define a "locked place" for a text in a listbox?
I have created one now, but the text strings mix and are according to me on wrong positions.

attachment.php
 

Attachments

  • UI.png
    UI.png
    31.3 KB · Views: 280
Level 6
Joined
Sep 28, 2009
Messages
222
had exactly the same problem.
this listbox item order seems a bit strange. e.g. if you have a loop and you add the integer as item it wont be

0
1
2
3
4
5
...

but

1
10
2
3
...
really strange and annoying, seems like its sorting like some sort of alphabetical order or smth.
 
Level 5
Joined
Apr 8, 2008
Messages
88
Sorry to tell you :p but mine don't follow that exact pattern... :/

  • Set "Strings"
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Variable - Set String[1] = "1024 x 768"
      • Variable - Set String[2] = "1152 x 864"
      • Variable - Set String[3] = "1280 x 720"
      • Variable - Set String[4] = "1280 x 768"
      • Variable - Set String[5] = "1280 x 800"
      • Variable - Set String[6] = "1280 x 960"
      • Variable - Set String[7] = "1280 x 1024"
      • Variable - Set String[8] = "1360 x 768"
      • Variable - Set String[9] = "1440 x 900"
      • Variable - Set String[10] = "1680 x 1050"
Mine goes
1
10
9
8
7
6
5
4
3
2
 
Level 11
Joined
Aug 1, 2009
Messages
963
I actually had a function designed for just this purpose, however, I can't seem to find it now.

Basically though, what you would do is this:

For Each Integer n from 1 to (#ofitems)
If n = 1, then create array[n]
Else, create array[(#ofitems)-(n-2)]

Considering that n is the key for your array, and that your array is the strings for the thing.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've encountered the same problem. I also need it in a specific order, otherwise when I have a condition for which list item is selected, it won't select the one I want.

So is there anything I can do besides yell at Blizzard to fix it? I don't really understand that function you described, mrzwach. It's probably just me though. If that function solves this problem, could you clarify it please?
 
Level 11
Joined
Aug 1, 2009
Messages
963
Heres a quick function I made a while back for personal use.

Too lazy to comment it, so heres basically how it works.

First, lets say you have a string array with a certain number of strings. The way this function works, each string in the array needs to be put in a single string seperated by spaces (the spaces within each individual string should be replaced with underscores). The "word position" of each substring is the position that it will appear in the dialog list item box, and should correspond to its position in your array. Also, you can then get what the index of the string is of a selected item, ie if a player selects something you can use that function to figure out what that something is in your array.
JASS:
void AddListItems(int listbox, string items){
    int i = 1;
    string s = StringWord(items, 1);
    while(s != null){
    i++;
    s = StringWord(items, i); //Counts the number of strings in the megastring.
    }
    if(i != 0){
        s = StringWord(items, 1);
        s = StringReplaceWord(s, "_", " ", c_stringReplaceAll, c_stringCase);
        //This replaces all underscores with spaces.
        DialogControlAddItem(listbox, PlayerGroupAll(), s);
        while(i > 1){
            s = StringWord(items, i);
            s = StringReplaceWord(s, "_", " ", c_stringReplaceAll, c_stringCase);
            DialogControlAddItem(listbox, PlayerGroupAll(), s);
        ;}
    ;}
;}

int GetListIndex(int listbox, int key, int player){
    int i = DialogControlGetItemCount(listbox, player);
    if (key==1){return 1;}
        else{return (i-key+2);}
}
Also, this was like my first or second function written in Galaxy scripting so its probably inefficient in some way or something. Also, if you don't have Andromeda/Moonlite/whatever you might need to replace the i++ and i-- with i=i+1 and i=i-1 respectively. I'm not sure if the normal Galaxy scripting language supports those.
 
Status
Not open for further replies.
Top