Announcement

Collapse
No announcement yet.

Reassigning Object IDs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reassigning Object IDs

    Hello,

    Background: Our project has increased a bit and now it has to feature more languages than the three it shipped originally. All languages are shown as static images with the text already localized according to the user-defined language, and as of now they were shown using a simple if comparision like
    Code:
    if(language == 1)
        img_Show(handle, imgLang1);
    else if(language == 2)
        img_Show(handle, imgLang2);
    [...]
    which will get very messy when having more than three languages. So the idea was to access the ID of the 'first language image' then add to that ID to reach the desired ID, which would reduce the lines of code from 12+ to 1 per time a new image has to be shown. Sadly it seems that the object IDs are generated in the order they have been created, which means that the new language image IDs will not be contiguous to the older ones, even if they are named sequentially.

    Question: Is it possible to rearrange the object IDs in any way, other than deleting and re-adding them in order (if that even works)? Even if it were automatically sorted as it is shown in the Object Inspector tool / Object Locations tool that'd be enough, since the images are always named sequentially.

    Thank you for your time.

  • #2
    once your project is saved, close workshop entirely, edit the file in a notepad editor, but make sure you don’t duplicate the ids, set them to what you want save and exit, then reopen workshop, should be good

    Comment


    • #3
      Hello,

      Thanks for your reply. I've taken a look at the various files generated by Workshop, but I can't quite see which one would have to be edited.
      Opening the .dat file shows the names of the objects then some hex values in
      Code:
      "ImageName" 0000 0000 00 00
      format; I'm guessing the last two values represent the top and left alignment values, since fullscreen images have both values at 00, but I don't know what the first pair of values are (assuming the object ID, since the first object has 0000 0000 value).

      Is the idea to flip IDs around until they are ordered as I need them to? As in:
      Code:
      ORIGINAL STATE
      ________________________________________
      "ImageName1" 0000 0000 00 00
      "ImageName2" BA00 000B 00 00
      "ImageName5" 7A00 0016 00 00    // This should go two places down
      "ImageName4" 3A00 0021 00 00
      "ImageName3" 0C00 0025 2B 47    // This should go two places up
      "ImageName6" DE00 0028 00 00
      
      EDITED STATE
      ______________________________________________________
      "ImageName1" 0000 0000 00 00
      "ImageName2" BA00 000B 00 00
      "ImageName3" 7A00 0016 2B 47    // Correct place, keeping xy alignment
      "ImageName4" 3A00 0021 00 00
      "ImageName5" 0C00 0025 00 00    // Correct place, keeping xy alignment
      "ImageName6" DE00 0028 00 00
      or is it something completely different?

      Thank you for your time.

      Comment


      • #4
        Hello,

        You seem to be on the right track, please make sure that the '.dat' file that you've edited is copied to the uSD card.

        Best regards,
        Michael

        Comment


        • #5
          Hello,

          Thanks for your input. I ordered the objects in the .dat file, but with the new .dat file there was some odd behaviour; images showing in positions of others, etc. Also the .dat file would get rewritten as it was before when compiling the program, so it would have been a hassle to keep track of that.

          In the end I also edited the .ViSi file with notepad and ordered the object IDs there. After compiling, the .dat file was also in order and it's now possible to cycle properly through the images incrementing the ID.

          Thanks for your help.

          Comment


          • #6
            Hello,

            You could also try using an array for your images.

            For example:

            Code:
            var Images[] := [ImageName1, ImageName2, ImageName3, ImageName4,ImageName5, ImageName6];
            That way you wouldn't have to rearrange the object IDs and you can call them by the array.

            Best regards,
            Michael

            Comment

            Working...
            X