public void ModelTab() { ImGui.BeginChild("##tabinner"); if (ImGui.Button("Add")) { modelSelector = new FileSelector(context.FlDirectory); modelSelector.Filter = FileSelector.MakeFilter(".3db", ".cmp"); modelSelector.Open(); } string newfile; if ((newfile = modelSelector.Draw()) != null) { var name = Path.GetFileName(newfile); resources.Models.Add(new InterfaceModel() { Name = name, Path = newfile }); } ImGui.Columns(2); ImGui.BeginChild("##items"); for (int i = 0; i < resources.Models.Count; i++) { if (ImGui.Selectable(ImGuiExt.IDWithExtra(resources.Models[i].Name, i.ToString()), _selModelIndex == i)) { _selModelIndex = i; drawable = context.GetModel(resources.Models[i].Path); modelName.SetText(resources.Models[i].Name); } } ImGui.EndChild(); ImGui.NextColumn(); ImGui.BeginChild("##pane"); if (_selModelIndex >= 0 && _selModelIndex < resources.Models.Count) { var mdl = resources.Models[_selModelIndex]; ImGui.SameLine(ImGui.GetColumnWidth() - 65); if (ImGui.Button("Delete")) { resources.Models.RemoveAt(_selModelIndex); _selModelIndex = -1; } ImGui.AlignTextToFramePadding(); ImGui.Text("Name: "); ImGui.SameLine(); modelName.InputText("##Name", ImGuiInputTextFlags.None); mdl.Name = modelName.GetText(); ImGui.Text($"Path: {mdl.Path}"); ImGui.InputFloat("Offset X", ref mdl.X); ImGui.InputFloat("Offset Y", ref mdl.Y); ImGui.InputFloat("Scale X", ref mdl.XScale); ImGui.InputFloat("Scale Y", ref mdl.YScale); DoViewport(mdl); } ImGui.EndChild(); ImGui.EndChild(); }
public void ColorTab() { ImGui.BeginChild("##tabinner"); if (ImGui.Button("Add")) { resources.Colors.Add(new InterfaceColor() { Name = "Color" + resources.Colors.Count, Color = Color4.White }); } ImGui.Separator(); ImGui.Columns(2); ImGui.BeginChild("##items"); for (int i = 0; i < resources.Colors.Count; i++) { if (ImGui.Selectable(ImGuiExt.IDWithExtra(resources.Colors[i].Name, i.ToString()), _selColIndex == i)) { _selColIndex = i; colorName.SetText(resources.Colors[i].Name); } } ImGui.EndChild(); ImGui.NextColumn(); ImGui.BeginChild("##pane"); if (_selColIndex >= 0 && _selColIndex < resources.Colors.Count) { var clr = resources.Colors[_selColIndex]; ImGui.SameLine(ImGui.GetColumnWidth() - 65); if (ImGui.Button("Delete")) { resources.Colors.RemoveAt(_selColIndex); _selColIndex = -1; } ImGui.Separator(); ImGui.AlignTextToFramePadding(); ImGui.Text("Name: "); ImGui.SameLine(); colorName.InputText("##Name", ImGuiInputTextFlags.None); clr.Name = colorName.GetText(); if (clr.Animation == null) { ColorPickerSimple(clr); if (ImGui.Button("Make Animated")) { clr.Animation = new InterfaceColorAnimation() { Color1 = clr.Color }; } } else { ColorPickerAnimated(clr); if (ImGui.Button("Make Simple")) { clr.Color = clr.Animation.Color1; clr.Animation = null; } } } ImGui.EndChild(); ImGui.EndChild(); }
public void ImageTab() { ImGui.BeginChild("##tabinner"); if (ImGui.Button("Add Normal")) { resources.Images.Add(new InterfaceImage() { Name = "Image" + resources.Images.Count }); } ImGui.SameLine(); if (ImGui.Button("Add Triangle")) { resources.Images.Add(new InterfaceImage() { Name = "Image" + resources.Images.Count, Type = InterfaceImageKind.Triangle }); } ImGui.Separator(); ImGui.Columns(2); ImGui.BeginChild("##items"); for (int i = 0; i < resources.Images.Count; i++) { if (ImGui.Selectable(ImGuiExt.IDWithExtra(resources.Images[i].Name, i.ToString()), _selTexIndex == i)) { _selTexIndex = i; imageName.SetText(resources.Images[i].Name); imageId.SetText(resources.Images[i].TexName ?? ""); } } ImGui.EndChild(); ImGui.NextColumn(); ImGui.BeginChild("##pane"); if (_selTexIndex >= 0 && _selTexIndex < resources.Images.Count) { var img = resources.Images[_selTexIndex]; ImGui.SameLine(ImGui.GetColumnWidth() - 65); if (ImGui.Button("Delete")) { resources.Images.RemoveAt(_selTexIndex); _selTexIndex = -1; } ImGui.Separator(); var ft2 = context.ResourceManager.FindTexture(img.TexName) as Texture2D; if (foundTexture != ft2) { if (foundTexture != null) { ImGuiHelper.DeregisterTexture(foundTexture); } foundTexture = ft2; if (ft2 != null) { foundTextureId = ImGuiHelper.RegisterTexture(foundTexture); } } ImGui.AlignTextToFramePadding(); ImGui.Text("Name: "); ImGui.SameLine(); imageName.InputText("##Name", ImGuiInputTextFlags.None); img.Name = imageName.GetText(); ImGui.AlignTextToFramePadding(); ImGui.Text("Texture: "); ImGui.SameLine(); imageId.InputText("##Texture", ImGuiInputTextFlags.None); img.TexName = imageId.GetText(); if (img.Type != InterfaceImageKind.Triangle) { bool flip = img.Flip; ImGui.Checkbox("Flip", ref flip); img.Flip = flip; } //DRAW. No controls below here DoImagePreview(img); } ImGui.EndChild(); ImGui.EndChild(); }
public string Draw() { bool pOpen = true; ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver); if (ImGui.BeginPopupModal(ImGuiExt.IDWithExtra("File Selector", unique), ref pOpen)) { bool hasFilename = fileNameSelected >= 0 && fileNameSelected < fileNames.Length; string selected = hasFilename ? fileNames[fileNameSelected] : "None"; ImGui.Text($"Selected: {selected}"); ImGui.SameLine(); if (ImGuiExt.Button("Open", hasFilename)) { ImGui.CloseCurrentPopup(); return(BuildFullPath(fileNames[fileNameSelected])); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.Separator(); if (ImGui.Button("/")) { pathBar = new List <string>(); Populate(); } ImGui.SameLine(); for (int i = 0; i < pathBar.Count; i++) { if (ImGui.Button(ImGuiExt.IDWithExtra(pathBar[i], i))) { pathBar = pathBar.Take(i + 1).ToList(); Populate(); } ImGui.SameLine(); } ImGui.Dummy(new Vector2(1, 1)); ImGui.BeginChild("##currentDir", new Vector2(-1, -1), true); for (int i = 0; i < directoryNames.Length; i++) { IconSelectable( ImGuiExt.IDWithExtra(directoryNames[i], i), "folder", Color4.White, false, out bool doubleClicked ); if (doubleClicked) { pathBar.Add(directoryNames[i]); Populate(); } } for (int i = 0; i < fileNames.Length; i++) { if (IconSelectable( ImGuiExt.IDWithExtra(fileNames[i], -i), "file", Color4.White, fileNameSelected == i, out bool doubleClicked)) { fileNameSelected = i; } if (doubleClicked) { ImGui.CloseCurrentPopup(); return(BuildFullPath(fileNames[fileNameSelected])); } } ImGui.EndChild(); ImGui.EndPopup(); } return(null); }
public void Open() { Populate(); ImGui.OpenPopup(ImGuiExt.IDWithExtra("File Selector", unique)); }
protected override void Draw(double elapsed) { VertexBuffer.TotalDrawcalls = 0; EnableTextInput(); Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); // if (cutscene != null) { cutscene.Draw(); } Typewriter.Render(); // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); bool openLoad = false; bool openMultiple = false; isMultipleOpen = false; //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem("Load Game Data", "open", Color4.White, true)) { var folder = FileDialog.ChooseFolder(); if (folder != null) { if (GameConfig.CheckFLDirectory(folder)) { openLoad = true; LoadData(folder); } else { //Error dialog } } } if (Theme.IconMenuItem("Open Thn", "open", Color4.White, GameData != null)) { var file = FileDialog.Open(); if (file != null) { Open(file); } } if (Theme.IconMenuItem("Open Multiple", "open", Color4.White, GameData != null)) { openFiles = new List <string>(); openMultiple = true; } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("View")) { ImGui.MenuItem("Decompiled", "", ref decompiledOpen); ImGui.EndMenu(); } if (toReload != null && ImGui.MenuItem("Reload (F5)")) { Reload(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); bool popupopen = true; if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (loaded) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } popupopen = true; if (openMultiple) { ImGui.OpenPopup("Open Multiple"); } if (ImGui.BeginPopupModal("Open Multiple", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { isMultipleOpen = true; if (ImGui.Button("+")) { var file = FileDialog.Open(); if (file != null) { openFiles.Add(file); } } ImGui.BeginChild("##files", new Vector2(200, 200), true, ImGuiWindowFlags.HorizontalScrollbar); int j = 0; foreach (var f in openFiles) { ImGui.Selectable(ImGuiExt.IDWithExtra(f, j++)); } ImGui.EndChild(); if (ImGuiExt.Button("Open", openFiles.Count > 0)) { ImGui.CloseCurrentPopup(); Open(openFiles.ToArray()); } } if (decompiled != null) { if (decompiledOpen) { ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver); int j = 0; if (ImGui.Begin("Decompiled", ref decompiledOpen)) { ImGui.BeginTabBar("##tabs", ImGuiTabBarFlags.Reorderable); foreach (var file in decompiled) { var tab = ImGuiExt.IDWithExtra(file.Name, j++); if (ImGui.BeginTabItem(tab)) { if (ImGui.Button("Copy")) { SetClipboardText(file.Text); } ImGui.SetNextItemWidth(-1); var th = ImGui.GetWindowHeight() - 100; ImGui.PushFont(ImGuiHelper.SystemMonospace); ImGui.InputTextMultiline("##src", ref file.Text, uint.MaxValue, new Vector2(0, th), ImGuiInputTextFlags.ReadOnly); ImGui.PopFont(); ImGui.EndTabItem(); } } ImGui.EndTabBar(); } } } ImGui.PopFont(); guiHelper.Render(RenderState); }
public unsafe void Draw() { bool openNew = false; if (IsOpen) { ImGui.SetNextWindowSize(new Vector2(300, 350), ImGuiCond.FirstUseEver); ImGui.Begin("Project", ref IsOpen); if (ImGui.Button("New")) { openNew = true; newFileBuffer = new byte[48]; } ImGui.BeginChild("##files", Vector2.Zero, true); for (int i = 0; i < files.Length; i++) { ImGui.Selectable(ImGuiExt.IDWithExtra(files[i], i)); if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0)) { if (files[i].EndsWith(".lua", true, CultureInfo.InvariantCulture)) { window.OpenLua(Path.Combine(folder, files[i])); } else { window.OpenXml(Path.Combine(folder, files[i])); } } } ImGui.EndChild(); ImGui.End(); } if (openNew) { ImGui.OpenPopup("New File"); } if (ImGui.BeginPopupModal("New File")) { ImGui.InputText("##filename", newFileBuffer, 48, ImGuiInputTextFlags.CallbackCharFilter, Callback); if (ImGui.Button("Ok")) { int length = 0; for (length = 0; length < 48; length++) { if (newFileBuffer[length] == 0) { break; } } if (length == 0) { ImGui.CloseCurrentPopup(); } else { var str = Encoding.UTF8.GetString(newFileBuffer, 0, length); str = str.Trim(); if (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str)) { ImGui.CloseCurrentPopup(); } else { bool create = true; foreach (var f in files) { if (f.Equals(str, StringComparison.OrdinalIgnoreCase)) { create = false; break; } } if (create) { File.WriteAllText(Path.Combine(folder, str), ""); } ImGui.CloseCurrentPopup(); } } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } } }