Skip to content

Commit

Permalink
Aligned to changes in ImGui.NET
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Dec 1, 2023
1 parent 77669dc commit 3941d73
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 44 deletions.
4 changes: 2 additions & 2 deletions CentrED/Renderer/UIRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private unsafe void UpdateBuffers(ImDrawDataPtr drawData)

for (int n = 0; n < drawData.CmdListsCount; n++)
{
ImDrawListPtr cmdList = drawData.CmdListsRange[n];
ImDrawListPtr cmdList = drawData.CmdLists[n];

fixed (void* vtxDstPtr = &_vertexData[vtxOffset * DrawVertDeclaration.Size])
fixed (void* idxDstPtr = &_indexData[idxOffset * sizeof(ushort)])
Expand Down Expand Up @@ -267,7 +267,7 @@ private unsafe void RenderCommandLists(ImDrawDataPtr drawData)

for (int n = 0; n < drawData.CmdListsCount; n++)
{
ImDrawListPtr cmdList = drawData.CmdListsRange[n];
ImDrawListPtr cmdList = drawData.CmdLists[n];

for (int cmdi = 0; cmdi < cmdList.CmdBuffer.Size; cmdi++)
{
Expand Down
7 changes: 3 additions & 4 deletions CentrED/UI/FilePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public bool Draw()
ImGui.Text("Current Folder: " + Path.GetFileName(RootFolder) + CurrentFolder.Replace(RootFolder, ""));
bool result = false;

if (ImGui.BeginChildFrame(1, new Num.Vector2(400, 400)))
if (ImGui.BeginChild(1, new Num.Vector2(400, 400), ImGuiChildFlags.FrameStyle))
{
var di = new DirectoryInfo(CurrentFolder);
if (di.Exists)
Expand Down Expand Up @@ -105,9 +105,8 @@ public bool Draw()
}
}
}
ImGui.EndChildFrame();


ImGui.EndChild();

if (ImGui.Button("Cancel"))
{
result = false;
Expand Down
2 changes: 1 addition & 1 deletion CentrED/UI/Windows/HuesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void Draw()
FilterHues();
}
var huesPosY = ImGui.GetCursorPosY();
ImGui.BeginChild("Hues", new Vector2(), false, ImGuiWindowFlags.Modal);
ImGui.BeginChild("Hues", new Vector2(), ImGuiChildFlags.None, ImGuiWindowFlags.Modal);
if (ImGui.BeginTable("TilesTable", 2) && CEDClient.Initialized)
{
unsafe
Expand Down
53 changes: 17 additions & 36 deletions CentrED/UI/Windows/MinimapWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class MinimapWindow : Window
private string _inputFavoriteName = "";
private string _keyToDelete = "";
private string _coordsText = "";
private bool _showError = true;
private bool _showConfirmation = true;
public override void Draw()
{
if (!Show) return;
Expand All @@ -27,16 +29,14 @@ public override void Draw()

if (CEDGame.MapManager.Client.Initialized)
{

ImGui.InputText("Favorite Name", ref _inputFavoriteName, 64);
ImGui.SameLine();

if (ImGui.Button("Add Favorite"))
{

if (string.IsNullOrEmpty(_inputFavoriteName) || ProfileManager.ActiveProfile.RadarFavorites.ContainsKey(_inputFavoriteName))
{
ImGui.OpenPopup("Error");
_showError = true;
}
else
{
Expand All @@ -48,23 +48,16 @@ public override void Draw()
ProfileManager.Save(ProfileManager.ActiveProfile);
_inputFavoriteName = "";
}

}



if (ImGui.BeginChild("ButtonGroup", new Vector2(RadarMap.Instance.Texture.Width, 100), true))

if (ImGui.BeginChild("Favorites", new Vector2(RadarMap.Instance.Texture.Width, 100)))
{

foreach (var (key, value) in ProfileManager.ActiveProfile.RadarFavorites)
foreach (var (name, coords) in ProfileManager.ActiveProfile.RadarFavorites)
{

if (key != ProfileManager.ActiveProfile.RadarFavorites.First().Key)
if (name != ProfileManager.ActiveProfile.RadarFavorites.First().Key)
{
ImGui.SameLine();
}


if (ImGui.GetCursorPos().X + 75 >= RadarMap.Instance.Texture.Width)
{
ImGui.NewLine();
Expand All @@ -73,35 +66,27 @@ public override void Draw()
var cursorPosition = ImGui.GetCursorPos();

//tooltip for button what shows the key


if (ImGui.Button($"{key}", new Vector2(75, 19)))
if (ImGui.Button($"{name}", new Vector2(75, 19)))
{
CEDGame.MapManager.Position = new Point(value.X, value.Y);
CEDGame.MapManager.Position = new Point(coords.X, coords.Y);
}
UIManager.Tooltip($"{key}\nX:{value.X} Y:{value.Y}");
UIManager.Tooltip($"{name}\nX:{coords.X} Y:{coords.Y}");

ImGui.SetCursorPos(cursorPosition + new Vector2(ImGui.GetItemRectSize().X, 0));



ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(1, 0, 0, .2f));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(1, 0, 0, 1));
if (ImGui.Button($"x##{key}"))
if (ImGui.Button($"x##{name}"))
{

_keyToDelete = key;
_keyToDelete = name;
ImGui.OpenPopup("Confirmation");


_showConfirmation = true;
}
ImGui.PopStyleColor(2);


}
if (ImGui.BeginPopupModal("Confirmation", ref _show, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar))
if (ImGui.BeginPopupModal("Confirmation", ref _showConfirmation, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar))
{
ImGui.Text("Are you sure you want to delete this favorite?");

if (ImGui.Button("Yes"))
{
if (!string.IsNullOrEmpty(_keyToDelete))
Expand All @@ -112,21 +97,17 @@ public override void Draw()
}
ImGui.CloseCurrentPopup();
}

ImGui.SameLine();

if (ImGui.Button("No"))
{
ImGui.CloseCurrentPopup();
}

ImGui.EndPopup();
}
ImGui.EndChild();
}


if (ImGui.BeginPopupModal("Error", ref _show, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar))

if (ImGui.BeginPopupModal("Error", ref _showError, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar))
{
ImGui.TextColored(new Vector4(1.0f, .0f, .0f, 1.0f), "Name already exists or empty value!");

Expand Down
2 changes: 1 addition & 1 deletion CentrED/UI/Windows/TilesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override void Draw()
ImGui.SameLine();
ImGui.Checkbox("Static", ref _staticVisible);

ImGui.BeginChild("Tiles", new Vector2(), false, ImGuiWindowFlags.Modal);
ImGui.BeginChild("Tiles", new Vector2(), ImGuiChildFlags.None, ImGuiWindowFlags.Modal);
if (ImGui.IsKeyPressed(ImGuiKey.DownArrow))
{
ImGui.SetScrollY(ImGui.GetScrollY() + 10);
Expand Down

0 comments on commit 3941d73

Please sign in to comment.