I would love to see this working on Linux. I tried a few years ago with no success, as the distro packages for Mono were quite abysmal and I wasn't about to build the entire toolchain myself. This time around things seem more mature and I am more dedicated. If it can't be got working, I'll likely start work on my own cross platform solution.
Here's a log of my attempt to get Legends Viewer working on Fedora 20 with a 40.16 generated world.
First, I installed the latest monodevelop and libraries via packages
straight from the project, rather than relying on my very old distro packages. The two I needed to grab everything were: monodevelop libmono-2_0-devel
After installing, I checked out the the latest git master and attempted to build it in MonoDevelop. A small tweak was required: rename Controls/Chart/dlgHF.Designer.cs to dlgHF.designer (Linux filenames are case sensitive).
It builds, but crashes on startup with the backtrace:
Could not set X locale modifiers
System.DllNotFoundException: user32.dll
at (wrapper managed-to-native) LegendsViewer.TabControlImproved:SendMessage (intptr,int,intptr,intptr)
at LegendsViewer.TabControlImproved.OnFontChanged (System.EventArgs e) [0x00023] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabControl.cs:164
at LegendsViewer.TabControlImproved.OnCreateControl () [0x0000d] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabControl.cs:157
at System.Windows.Forms.Control.CreateControl () [0x000a3] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3543
at System.Windows.Forms.Control.WmShowWindow (System.Windows.Forms.Message& m) [0x00039] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5496
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x001cf] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5080
at System.Windows.Forms.TabControl.WndProc (System.Windows.Forms.Message& m) [0x0006e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:925
at LegendsViewer.TabControlImproved.WndProc (System.Windows.Forms.Message& m) [0x000a8] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabControl.cs:284
at LegendsViewer.DwarfTabControl.WndProc (System.Windows.Forms.Message& m) [0x0007d] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabControl.cs:113
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:228
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:209
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x0008e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:240
Based on the declarations here, user32.SendMessage looks to be a windows native function:
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wParam, ref TCHITTESTINFO lParam);
To be portable, ideally, we'll need to find a managed code alternative, or at worst, special case a Linux equivalent. I'm not a windows api guru by any means, but it seems to be some sort of Window Manager action, whatever it is doing, it doesn't look mission critical. So I commented out all the lines referencing SendMessage.
Then the app builds and launches:
But it doesn't work. When I load the XML file, it crashes in FileLoader.LocateOtherFiles() because it expects windows path format with backslashes. As a quick hack I shortcut'ed the function, so I could manually fill in the values.
After some time the app parses the data and "Setup..." appears in blue. Clicking on "World Stats" crashes the app because the browser control isn't available.
libgluezilla not found. To have webbrowser support, you need libgluezilla installed
System.NullReferenceException: Object reference not set to an instance of an object
at LegendsViewer.Controls.HTMLControl.GetControl () [0x0009b] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/HTML/HTMLControl.cs:37
at LegendsViewer.DwarfTabPage.LoadPageControl () [0x00023] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabPage.cs:36
at LegendsViewer.DwarfTabPage.NewPageControl (LegendsViewer.PageControl pageControl) [0x0003d] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabPage.cs:29
at (wrapper remoting-invoke-with-check) LegendsViewer.DwarfTabPage:NewPageControl (LegendsViewer.PageControl)
at LegendsViewer.DwarfTabControl.Navigate (ControlOption control, System.Object navigateObject) [0x000a5] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/Controls/DwarfTabControl.cs:46
at (wrapper remoting-invoke-with-check) LegendsViewer.DwarfTabControl:Navigate (LegendsViewer.Controls.ControlOption,object)
at LegendsViewer.frmLegendsViewer.btnStats_Click (System.Object sender, System.EventArgs e) [0x0001e] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/LegendsViewer.cs:754
at System.Windows.Forms.Control.OnClick (System.EventArgs e) [0x0001c] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5710
at System.Windows.Forms.Button.OnClick (System.EventArgs e) [0x00024] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:102
at System.Windows.Forms.ButtonBase.OnMouseUp (System.Windows.Forms.MouseEventArgs mevent) [0x00081] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:572
at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs mevent) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:122
at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m) [0x0007e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5279
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x0016f] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5020
at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Message& m) [0x0004e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:632
at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:142
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:228
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:209
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x0008e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:240
libgluezilla is the native backbone to the
Mono.WebBrowser control. It replaces the IE Active X control, which of course isn't cross platform. Should be an easy fix, just install libgluezilla? Nope. The libgluezilla project is basically
dead and
abandoned. No major distributions still package the library, the github repo hasn't seen updates in years, and it reportedly doesn't build against the latest xulrunner.
That said, it looks like the project has been superseded by WebKit. Migrating to Mono.WebKit via the webkit-sharp native library is necessary to get the browser working. This is also good news for OS X users, as WebKit has OS X support, and Parker has stated previously that the browser is the blocker for an OS X build.
Moving on, the World Map screen renders, huzzah.
Every other tab is empty though and clicking on any search fields results in a null pointer crash, probably because the data structures are empty.
System.NullReferenceException: Object reference not set to an instance of an object
at LegendsViewer.frmLegendsViewer.searchHFList (System.Object sender, System.EventArgs e) [0x00043] in /home/ramblurr/src/df/df-legends-viewer/LegendsViewer/LegendsViewer.cs:183
at System.Windows.Forms.Control.OnTextChanged (System.EventArgs e) [0x0001c] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:6264
at System.Windows.Forms.TextBoxBase.OnTextChanged (System.EventArgs e) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:2471
at System.Windows.Forms.TextBoxBase.WndProc (System.Windows.Forms.Message& m) [0x0018b] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:1536
at System.Windows.Forms.TextBox.WndProc (System.Windows.Forms.Message& m) [0x00175] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs:658
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:228
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:209
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x0008e] in /builddir/build/BUILD/mono-3.10.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:240
Perhaps the file parsing is failing. Could it be choking on unix line endings? Perhaps it is something else.
Finally, I dabbled with getting a distributable binary of Legends Viewer built so we could do some proper distribution. cd'ing to LegendsViewer/bin/Debug and running:
mkbundle LegendsViewer.exe SevenZipSharp.dll -L . --deps -o legends-viewer
This resulted in a 13MB legends-viewer binary that didn't work unless the '7z64.dll' file was in the same directory (I forgot how windows, by default,
loads shared libraries from the working directory first, crazy!). Bundling the 7z[64].dll assemblies by adding them to the mkbundle command resulted in a IKVM.Reflection.BadImageFormatException. Presumably the mkbundle assembly parsing routines couldn't read the dll for whatever reason. Anyways creating an empty file "touch 7z64.dll" got the app started.
In the future to create a distributable binary, we'll need to fix that, either by sorting out the format error, or dropping 7z support, or using native 7z libs. Nonetheless, I have high hopes for creating distributable binaries for Linux users
That's all the investigation I'll do for today. Here's a tidy list of todos to serve as a foundational roadmap for Linux (and possibly OS X!) support:
- Migrate to Mono.WebKit instead of Mozilla
- Fix windows-specific path handling
- Remove or conditionalize the native windows WM API calls
- Make the GUI text more readable
- Use a native theme to make it less ugly
- Sort out 7z library for packaging
Parker147, shall I create these as issues in github? Would love to collaborate with you to get a working Linux build.