Skip to content

Instantly share code, notes, and snippets.

@se5a
Created April 29, 2020 02:29
Show Gist options
  • Save se5a/aa83958a981942e12121e5a36ea74fba to your computer and use it in GitHub Desktop.
Save se5a/aa83958a981942e12121e5a36ea74fba to your computer and use it in GitHub Desktop.
Using BorderGroup and BorderListOptions
private int _bloSelectedIndex = -1;
void BorderListOptionsWiget()
{
string[] items = new string[_listfoo.Count];
for (int i = 0; i < _listfoo.Count; i++)
{
items[i] = _listfoo[i].name;
}
BorderGroup.Begin("Border List Options: ");
BorderListOptions.Begin("blo", items, ref _bloSelectedIndex, 64);
if(_bloSelectedIndex >=0)
{
if (ImGui.Button("^"))
{
(string name, int count) item = _listfoo[_bloSelectedIndex];
_listfoo.RemoveAt(_bloSelectedIndex);
_listfoo.Insert(_bloSelectedIndex - 1, item);
_bloSelectedIndex--;
}
ImGui.SameLine();
if (ImGui.Button("v"))
{
(string name, int count) item = _listfoo[_bloSelectedIndex];
_listfoo.RemoveAt(_bloSelectedIndex);
_listfoo.Insert(_bloSelectedIndex + 1, item);
_bloSelectedIndex++;
}
ImGui.Text(_listfoo[_bloSelectedIndex].count.ToString());
ImGui.SameLine();
if (ImGui.Button("+"))
{
_listfoo[_bloSelectedIndex] = (_listfoo[_bloSelectedIndex].name, _listfoo[_bloSelectedIndex].count + 1);
}
ImGui.SameLine();
if (ImGui.Button("-"))
{
_listfoo[_bloSelectedIndex] = (_listfoo[_bloSelectedIndex].name, _listfoo[_bloSelectedIndex].count - 1);
}
}
BorderListOptions.End(64);
BorderGroup.End();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment