Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] Rage Native UI Refresh Menu Item List

Featured Replies

Is there a way to make rnui really refresh a list item? After i alter the list and do a mainmenu.reset and mainmenu.refresh it still stays the same. (Except for mainMenu.Clear and re-adding all the items)

Edited by khorio

  • Author
Just now, ainesophaur said:

Are you making the list a List<dynamic>? I believe the only way I got it to work was to remove the uimenu item and put it back in the previous index position

Well, right now i just clear the entire menu and re-add it. Seems like there's no easy way

In "Transportation" I remove the MenuListItem, add a new one at the end and move it up the menu to it's initial position. Here's the code:

public static class ListExtensions
{
    public static void Move<T>(this IList<T> list, int iIndexToMove,
        MoveDirection direction)
    {

        if (direction == MoveDirection.Up)
        {
            var old = list[iIndexToMove - 1];
            list[iIndexToMove - 1] = list[iIndexToMove];
            list[iIndexToMove] = old;
        }
        else
        {
            var old = list[iIndexToMove + 1];
            list[iIndexToMove + 1] = list[iIndexToMove];
            list[iIndexToMove] = old;
        }
    }
}

public enum MoveDirection
{
    Up,
    Down
}
while (MenuItems.IndexOf(_menuListSources) > MenuItems.IndexOf(_menuListLoads) + 1)
{
    MenuItems.Move(MenuItems.IndexOf(_menuListSources), MoveDirection.Up);
}

while (MenuItems.IndexOf(_menuListDestinations) > MenuItems.IndexOf(_menuListLoads) + 2)
{
    MenuItems.Move(MenuItems.IndexOf(_menuListDestinations), MoveDirection.Up);
}

_menuListLoads is the 1st item on the list and it's position doesn't change. Here's how the menu looks like: e3c7e3-GTA5%202016-02-11%2016-03-43-77.j

Edited by LtFlash

  • Author
1 minute ago, alexguirre said:

What do you mean with "refresh a list item"? In the latest version of RNUI UIMenu.Reset() has been added, it sets all list items indexes to 0 and unchecks all the checkboxes.

i mean after you change the contents of a List<>, it doesn't update in the menu.

4 minutes ago, khorio said:

i mean after you change the contents of a List<>, it doesn't update in the menu.

Ah ok, the only way possible currently would to delete and create it again as explained above.

The reason for it is that RNUI creates a copy of the list you passed to the item so any changes  you made to it won't be reflected in the item.

Probably, I'll add some way to update the list in the item in the next version, if you have any other request you can create an issue in the Github repo.

18 minutes ago, alexguirre said:

Ah ok, the only way possible currently would to delete and create it again as explained above.

The reason for it is that RNUI creates a copy of the list you passed to the item so any changes  you made to it won't be reflected in the item.

Probably, I'll add some way to update the list in the item in the next version, if you have any other request you can create an issue in the Github repo.

Just out of curiosity.. Why not just pass the reference to the list vs copying the elements?

13 minutes ago, ainesophaur said:

Just out of curiosity.. Why not just pass the reference to the list vs copying the elements?

Not sure(I didn't write that part of the code, was Guadmaz who wrote it originally), this is what's done in the constructor:
 

_items = new List<dynamic>(items);

 

6 minutes ago, khorio said:

Well I'm just glad it wasn't something i was doing wrong and if it can be fixed in the next version that would be great :)

*It won't be fixed, it will be a new feature :tongue: That was intentionally made that way for some reason.

  • Author
1 minute ago, alexguirre said:

*It won't be fixed, it will be a new feature :tongue: That was intentionally made that way for some reason.

If it was intentionally made like this maybe just a flag to change the behavior of it or a different menu item type

Edited by khorio

7 minutes ago, alexguirre said:

*It won't be fixed, it will be a new feature :tongue: That was intentionally made that way for some reason.

[Deleted, will reopen my github issue one day]

Edited by ainesophaur

  • Author
2 minutes ago, alexguirre said:

Yes, use the Text property.

Heh..the reason i asked is because i tried that and it doesn't change.

Spoiler

private void LoadBar()
        {
            Game.FrameRender += RNUIProcess;
            timerBarPool = new TimerBarPool();
            barTimerBar = new BarTimerBar("");
            textTimerBar = new TextTimerBar("Remaining", "00:00");
            timerBarPool.Add(barTimerBar);
            timerBarPool.Add(textTimerBar);

        }

public void SearchValues()
        {
            barTimerBar.Text = "Scanning...";

 

Text stays empty

Edited by khorio

  • Author
Spoiler

private void LoadBar()
        {
            Game.FrameRender += RNUIProcess;
            timerBarPool = new TimerBarPool();
            barTimerBar = new BarTimerBar("");
            textTimerBar = new TextTimerBar("Remaining", "00:00");
            timerBarPool.Add(barTimerBar);
            timerBarPool.Add(textTimerBar);
        }
private void RNUIProcess(object sender, GraphicsEventArgs e)
        {
            GameFiber.StartNew(delegate
            {                
                    if(timer == 0) { Game.FrameRender -= RNUIProcess; }
                    GameFiber.Yield();
                    timerBarPool.Draw();
                    barTimerBar.ForegroundColor = c.GetColor(c.eColor.Blue);
                    barTimerBar.BackgroundColor = ControlPaint.Dark(barTimerBar.ForegroundColor);
                    textTimerBar.Text = timer.ToString("00:00");
                    barTimerBar.Text = TaskText;
            });
        }

 

Just tried it this way, i can change TaskText to whatever i want it won't display for some reason

Ah, you were talking about the BarTimerBar, in your first post you said it was the TextTimerBar. 

The Text property in BarTimerBar doesn't have any use, I don't know how that ended up there if it happened while I was porting that code or if it was the original author. Use the Label property instead, the Label is the text at the left and the Text(in TextTimerBar) is the text at the right.

BarTimerBar.Text will be removed in the next version.

  • Author
1 minute ago, alexguirre said:

Ah, you were talking about the BarTimerBar, in your first post you said it was the TextTimerBar. 

The Text property in BarTimerBar doesn't have any use, I don't know how that ended up there if it happened while I was porting that code or if it was the original author. Use the Label property instead, the Label is the text at the left and the Text(in TextTimerBar) is the text at the right.

BarTimerBar.Text will be removed in the next version.

No wonder it didn't work then :) yeah BartTimerBar and TexTimerBar are confusing names :p

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Similar Content

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.