void ChangeSystem() { if (sysIndex != sysIndexLoaded) { camera.UpdateProjection(); camera.Free = false; camera.Zoom = 5000; Resources.ClearTextures(); if (universeBackgroundTex != null) { ImGuiHelper.DeregisterTexture(universeBackgroundTex); } universeBackgroundTex = (Resources.FindTexture("fancymap.tga") as Texture2D); if (universeBackgroundTex != null) { universeBackgroundRegistered = ImGuiHelper.RegisterTexture(universeBackgroundTex); } else { universeBackgroundRegistered = -1; } curSystem = GameData.GetSystem(systems[sysIndex]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); if (icard != null) { icard.SetInfocard(systemInfocard); } GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources); systemMap.SetObjects(curSystem); sysIndexLoaded = sysIndex; } }
void OnLoadComplete() { systemMap.CreateContext(this); fontMan.LoadFontsFromGameData(GameData); camera = new DebugCamera(new Rectangle(0, 0, Width, Height)); camera.Zoom = 5000; camera.UpdateProjection(); var renderer = new SystemRenderer(camera, GameData, Resources, this); world = new GameWorld(renderer); systems = GameData.ListSystems().OrderBy(x => x).ToArray(); Resources.ClearTextures(); string navPrettyMap; if ((navPrettyMap = GameData.VFS.Resolve(GameData.Ini.Freelancer.DataPath + "INTERFACE/NEURONET/NAVMAP/NEWNAVMAP/nav_prettymap.3db", false)) != null) { Resources.LoadResourceFile(navPrettyMap); } universeBackgroundTex = (Resources.FindTexture("fancymap.tga") as Texture2D); if (universeBackgroundTex != null) { universeBackgroundRegistered = ImGuiHelper.RegisterTexture(universeBackgroundTex); } else { universeBackgroundRegistered = -1; } curSystem = GameData.GetSystem(systems[0]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources, false); systemMap.SetObjects(curSystem); }
void ServerList_Disconnected(string reason) { var dlg = new List <UIElement>(); dlg.Add(new UIBackgroundElement(manager) { FillColor = new Color4(0, 0, 0, 0.25f) }); var ifc = new Infocard(); ifc.Nodes = new List <InfocardNode>(); ifc.Nodes.Add(new InfocardTextNode() { Bold = true, Contents = "Disconnected" }); ifc.Nodes.Add(new InfocardParagraphNode()); ifc.Nodes.Add(new InfocardTextNode() { Contents = reason }); dlg.Add(new UIMessageBox(manager, ifc)); var x = new UIXButton(manager, 0.64f, 0.26f, 2, 2.9f); x.Clicked += () => { manager.Dialog = null; connectButton.Action = null; }; dlg.Add(x); manager.Dialog = dlg; }
public static List<Infocard> Load(string path) { var Infocards = new List<Infocard>(); var file = File.OpenRead(path); using (var sr = new StreamReader(file)) { while (sr.EndOfStream == false) { var line = sr.ReadLine(); if (!string.IsNullOrEmpty(line.Replace(" ", String.Empty))) { var inf = new Infocard(); //Infocards file work as blocks of three lines separated by empty lines inf.id = int.Parse(line); line = sr.ReadLine(); inf.type = line == "NAME" ? false : true; line = sr.ReadLine(); inf.content = line; Infocards.Add(inf); } } } return Infocards; }
public InfocardControl(MainWindow win, Infocard infocard, float initWidth) { window = win; icard = win.RichText.BuildText(infocard.Nodes, (int)initWidth, 0.8f); //icard = new InfocardDisplay(win, new Rectangle(0, 0, (int)initWidth, int.MaxValue), infocard); //icard.FontScale = 0.8f; }
void OnLoadComplete() { fontMan.LoadFontsFromGameData(GameData); camera = new DebugCamera(new Viewport(0, 0, Width, Height)); camera.Zoom = 5000; camera.UpdateProjection(); var renderer = new SystemRenderer(camera, GameData, Resources, this); world = new GameWorld(renderer); systems = GameData.ListSystems().OrderBy(x => x).ToArray(); Resources.ClearTextures(); Resources.LoadResourceFile(GameData.ResolveDataPath("INTERFACE/NEURONET/NAVMAP/NEWNAVMAP/nav_prettymap.3db")); universeBackgroundTex = (Resources.FindTexture("fancymap.tga") as Texture2D); if (universeBackgroundTex != null) { universeBackgroundRegistered = ImGuiHelper.RegisterTexture(universeBackgroundTex); } else { universeBackgroundRegistered = -1; } curSystem = GameData.GetSystem(systems[0]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources); }
void DisplayInfoString() { if (currentString == -1) { display.SetInfocard(blankInfocard); return; } var str = manager.GetStringResource(stringsIds[currentString]); if (string.IsNullOrWhiteSpace(str)) { display.SetInfocard(blankInfocard); return; } var infocard = new Infocard() { Nodes = new List <RichTextNode>() }; foreach (var ln in str.Split('\n')) { if (!string.IsNullOrWhiteSpace(ln)) { infocard.Nodes.Add(new RichTextTextNode() { Contents = ln, FontName = "Arial", FontSize = 22 }); } infocard.Nodes.Add(new RichTextParagraphNode()); } display.SetInfocard(infocard); }
void AddInfocard(int ids, bool is_string_name, string text, bool has_error) { Infocard info = new Infocard(); info.is_string_name = is_string_name; info.text = text; info.has_error = has_error; infocards[ids] = info; }
public RoomGameplay(FreelancerGame g, CGameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g) { //Load room data this.session = session; baseId = newBase; currentBase = g.GameData.GetBase(newBase); currentRoom = room ?? currentBase.StartRoom; currentRoom.InitForDisplay(); var rm = virtualRoom ?? currentRoom.Nickname; this.virtualRoom = virtualRoom; //Find infocard sys = g.GameData.GetSystem(currentBase.System); var obj = sys.Objects.FirstOrDefault((o) => { return(o.Base?.Equals(newBase, StringComparison.OrdinalIgnoreCase) ?? false); }); int ids = 0; if (obj?.IdsInfo.Length > 0) { ids = obj.IdsInfo[0]; } roomInfocard = g.GameData.GetInfocard(ids, g.Fonts); if (g.GameData.GetRelatedInfocard(ids, g.Fonts, out var ic2)) { roomInfocard.Nodes.Add(new RichTextParagraphNode()); roomInfocard.Nodes.AddRange(ic2.Nodes); } //Create user interface tophotspots = new List <BaseHotspot>(); foreach (var hp in currentRoom.Hotspots) { if (TOP_IDS.Contains(hp.Name)) { tophotspots.Add(hp); } } SetActiveHotspot(rm); Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; Game.Mouse.MouseDown += MouseOnMouseDown; cursor = Game.ResourceManager.GetCursor("arrow"); talk_story = Game.ResourceManager.GetCursor("talk_story"); ui = Game.Ui; ui.GameApi = new BaseUiApi(this); ui.OpenScene("baseside"); //Set up THN SwitchToRoom(room == null); FadeIn(0.8, 1.7); }
void OnLoadComplete() { fontMan.LoadFontsFromGameData(GameData); camera = new DebugCamera(new Viewport(0, 0, Width, Height)); camera.Zoom = 5000; camera.UpdateProjection(); var renderer = new SystemRenderer(camera, GameData, Resources, this); world = new GameWorld(renderer); systems = GameData.ListSystems().OrderBy(x => x).ToArray(); Resources.ClearTextures(); curSystem = GameData.GetSystem(systems[0]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources); }
public UIMessageBox(UIManager m, int infocard) : base(m, "../NEURONET/errorexplanation.cmp", 0, 0, 1.25f, 1.65f) { ifc = m.Game.GameData.GetInfocard(infocard); foreach (var n in ifc.Nodes) { if (n is InfocardTextNode) { //TODO: FL probably just alters the defaults when parsing, but this works for all the vanilla //GUI infocards anyway var t = (InfocardTextNode)n; t.Alignment = TextAlignment.Center; t.Color = Manager.TextColor; t.FontIndex = -1; } } }
public void SetInfocard(Infocard infocard) { icard.Dispose(); icard = window.RichText.BuildText(infocard.Nodes, renderWidth > 0 ? renderWidth : 400, 0.8f); }
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 (world != null) { if (wireFrame) { RenderState.Wireframe = true; } world.Renderer.Draw(); RenderState.Wireframe = false; } // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem("Open", "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("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } if (world != null) { if (ImGui.MenuItem("Change System (F6)")) { sysIndex = sysIndexLoaded; openChangeSystem = true; } } if (ImGui.BeginMenu("View")) { if (ImGui.MenuItem("Debug Text", "", showDebug, true)) { showDebug = !showDebug; } if (ImGui.MenuItem("Wireframe", "", wireFrame, true)) { wireFrame = !wireFrame; } if (ImGui.MenuItem("Infocard", "", infocardOpen, true)) { infocardOpen = !infocardOpen; } if (ImGui.MenuItem("VSync", "", vSync, true)) { vSync = !vSync; SetVSync(vSync); } ImGui.EndMenu(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); //Other Windows if (world != null) { if (showDebug) { ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero); ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus); ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname, camera.Position.X, camera.Position.Y, camera.Position.Z, DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers)); ImGui.End(); } ImGui.SetNextWindowSize(new Vector2(100, 100), ImGuiCond.FirstUseEver); if (infocardOpen) { if (ImGui.Begin("Infocard", ref infocardOpen)) { var szX = Math.Max(20, ImGui.GetWindowWidth()); var szY = Math.Max(20, ImGui.GetWindowHeight()); if (icard == null) { icard = new InfocardControl(this, systemInfocard, szX); } icard.Draw(szX); } ImGui.End(); } } //dialogs must be children of window or ImGui default "Debug" window appears if (openChangeSystem) { ImGui.OpenPopup("Change System"); openChangeSystem = false; } bool popupopen = true; if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.Combo("System", ref sysIndex, systems, systems.Length); if (ImGui.Button("Ok")) { if (sysIndex != sysIndexLoaded) { camera.UpdateProjection(); camera.Free = false; camera.Zoom = 5000; Resources.ClearTextures(); curSystem = GameData.GetSystem(systems[sysIndex]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); if (icard != null) { icard.SetInfocard(systemInfocard); } GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources); sysIndexLoaded = sysIndex; } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (world != null) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } ImGui.PopFont(); guiHelper.Render(RenderState); }
public InfocardControl(MainWindow win, Infocard infocard, float initWidth) { window = win; icard = new InfocardDisplay(win, new Rectangle(0, 0, (int)initWidth, int.MaxValue), infocard); icard.FontScale = 0.8f; }
public InfocardControl(MainWindow win, Infocard infocard, float initWidth) { window = win; icard = win.RichText.BuildText(infocard.Nodes, (int)initWidth, 0.7f * ImGuiHelper.Scale); }
public override void Render(UiContext context, RectangleF parentRectangle) { //TODO: fix up if (setString != null) { Infocard = new Infocard() { Nodes = new List <RichTextNode>() }; string fontName = setFont ?? "$ListText"; if (fontName[0] == '$') { fontName = context.Data.Fonts.ResolveNickname(fontName.Substring(1)); } foreach (var s in setString.Split('\n')) { Infocard.Nodes.Add(new RichTextTextNode() { Contents = s, FontName = fontName, FontSize = setSize < 1 ? 22 : setSize, Alignment = TextAlignment.Left, Color = context.Data.GetColor("text").Color, Shadow = new TextShadow(context.Data.GetColor("black").Color) }); Infocard.Nodes.Add(new RichTextParagraphNode()); } setString = null; setFont = null; setSize = 0; } if (!Visible) { return; } var myRectangle = GetMyRectangle(context, parentRectangle); Background?.Draw(context, myRectangle); myRectangle.Width -= scrollbar.Style.Width; if (Infocard != null) { var rte = context.RenderContext.Renderer2D.CreateRichTextEngine(); var myRect = context.PointsToPixels(myRectangle); if (currInfocard != Infocard || mW != myRect.Width) { richText?.Dispose(); currInfocard = Infocard; mW = myRect.Width; richText = rte.BuildText(Infocard.Nodes, mW, (context.ViewportHeight / 480) * 0.5f); var h = richText.Height; if ((int)h > myRect.Height + 2) { scrollbar.ScrollOffset = 0; scrollbar.ThumbSize = myRect.Height / h; const float TICK_MAGIC = 0.2627986f; scrollbar.Tick = 0.01f * (scrollbar.ThumbSize / TICK_MAGIC); scrollbarVisible = true; } else { scrollbarVisible = false; } } if (scrollbarVisible) { scrollbar.Render(context, new RectangleF(myRectangle.X + myRectangle.Width, myRectangle.Y, scrollbar.Style.Width, myRectangle.Height)); } context.RenderContext.ScissorEnabled = true; context.RenderContext.ScissorRectangle = myRect; int y = myRect.Y; if (scrollbarVisible) { y -= (int)(scrollbar.ScrollOffset * (richText.Height - myRect.Height)); } rte.RenderText(richText, myRect.X, y); context.RenderContext.ScissorEnabled = false; } Border?.Draw(context, myRectangle); }
void Load() { UiData.FlDirectory = FlFolder; UiData.ResourceManager = new GameResourceManager(window); UiData.FileSystem = FileSystem.FromFolder(FlFolder); UiData.Fonts = window.Fonts; var flIni = new FreelancerIni(UiData.FileSystem); var dataPath = UiData.FileSystem.Resolve(flIni.DataPath) + "/"; ResolvedDataDir = dataPath; UiData.DataPath = flIni.DataPath; //TODO: Fix to work with custom game UiData.NavmapIcons = new NavmapIcons(); UiData.OpenFolder(XmlFolder); try { var navbarIni = new LibreLancer.Data.BaseNavBarIni(dataPath, UiData.FileSystem); UiData.NavbarIcons = navbarIni.Navbar; } catch (Exception) { UiData.NavbarIcons = null; } try { var hud = new HudIni(); hud.AddIni(flIni.HudPath, UiData.FileSystem); var maneuvers = new List <Maneuver>(); var p = flIni.DataPath.Replace('\\', Path.DirectorySeparatorChar); foreach (var m in hud.Maneuvers) { maneuvers.Add(new Maneuver() { Action = m.Action, ActiveModel = Path.Combine(p, m.ActiveModel), InactiveModel = Path.Combine(p, m.InactiveModel) }); } window.TestApi.ManeuverData = maneuvers.ToArray(); } catch (Exception) { window.TestApi.ManeuverData = null; } if (flIni.JsonResources != null) { UiData.Infocards = new InfocardManager(flIni.JsonResources, UiData.FileSystem); } else if (flIni.Resources != null) { UiData.Infocards = new InfocardManager(flIni.Resources); } XmlLoader = new UiXmlLoader(UiData.Resources); try { UiData.Stylesheet = (Stylesheet)XmlLoader.FromString(UiData.ReadAllText("stylesheet.xml"), null); } catch (Exception) { } window.Fonts.LoadFontsFromIni(flIni, UiData.FileSystem); //unioners infocard var im = new InfocardManager(flIni.Resources); TestingInfocard = RDLParse.Parse(im.GetXmlResource(65546), window.Fonts); }
public void SetInfocard(Infocard infocard) { icard.Dispose(); InfocardText = infocard.ExtractText(); icard = window.RichText.BuildText(infocard.Nodes, renderWidth > 0 ? renderWidth : 400, 0.7f * ImGuiHelper.Scale); }
public UIMessageBox(UIManager m, int infocard) : base(m, "../NEURONET/errorexplanation.cmp", 0, 0, 1.25f, 1.65f) { ifc = m.Game.GameData.GetInfocard(infocard); SetFormatting(); }
public void SetInfocard(Infocard infocard) { icard.SetInfocard(infocard); }
public UIMessageBox(UIManager m, Infocard infocard) : base(m, "../NEURONET/errorexplanation.cmp", 0, 0, 1.25f, 1.65f) { ifc = infocard; SetFormatting(); }