Author Topic: MAPVIEW upgrade  (Read 73674 times)

Offline hellrazor

  • Commander
  • *****
  • Posts: 2191
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: MAPVIEW upgrade
« Reply #390 on: February 10, 2019, 03:34:04 pm »
a Mapfile doesn't store Pck entries, it stores Mcd record ids (which then have pointers to Pck data)

so the quantity of images isn't limited by the Mapfile format;

Good to know then i can make this UFO =)

Offline tkzv

  • Commander
  • *****
  • Posts: 586
    • View Profile
Re: MAPVIEW upgrade
« Reply #391 on: February 11, 2019, 12:53:14 am »
Thanks for trying to make this work in Mono, kevL.

To answer your question on GitHub: I treated all black pixels as transparent, because not drawing only colour #0 did not have the desired effect. As far as I can tell, you replaced my check with (palid != Palette.TransparentId) in case the transparent colour isn't 0. This makes sense. Unfortunately, this doesn't work for me. I downloaded your version ab4868e, compiled it and again got black rectangles.

UPDATE: My bad, forgot to define LOCKBITS. Now it looks more or less fine. Does it have to draw gaps between tiles? Also, when I move mouse over the window, a number of horizontal lines appear, vaguely in a shape of the craft displayed. What may be causing them?

UPDATE 2: Found "Use Mono" option. Now everything is fine.

Stoddard's latest build https://lxnt.wtf/oxem/builds//MapView/MapView-ab4868ec-2019-02-08-mono.7z does not work in my system (Ubuntu 16.04), giving the error:

For System.MissingMethodException: Method 'String.Format' not found.
  at YamlDotNet.RepresentationModel.YamlStream.Load (IParser parser) <0x40cbb760 + 0x0003b> in <filename unknown>:0
  at YamlDotNet.RepresentationModel.YamlStream.Load (System.IO.TextReader input) <0x40cb99b0 + 0x00047> in <filename unknown>:0
  at MapView.XCMainWindow.LoadOptions () <0x40cb7f20 + 0x0013b> in <filename unknown>:0
  at MapView.XCMainWindow..ctor () <0x40c17b80 + 0x006bb> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) MapView.XCMainWindow:.ctor ()
  at MapView.Startup.RunProgram () <0x40bd6fe0 + 0x000db> in <filename unknown>:0
« Last Edit: February 11, 2019, 01:10:56 am by tkzv »

Online kevL

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: MAPVIEW upgrade
« Reply #392 on: February 11, 2019, 03:43:06 am »
Thanks for trying to make this work in Mono, kevL.
np. you did the groundwork, i had the time, it was interesting ....... tks.

Quote
To answer your question on GitHub: I treated all black pixels as transparent, because not drawing only colour #0 did not have the desired effect. As far as I can tell, you replaced my check with (palid != Palette.TransparentId) in case the transparent colour isn't 0. This makes sense.

note that (const)Palette.TransparentId is defined as "0" in the code elsewhere -- it's not, eg, getting the transparency ID out of an image and using that, it's just avoiding the use of "0" (as a magic number).

The thing is, if you want to test against palette ids, this is the necessary step:

Code: [Select]
    palid = bindata[++i];

bindata is retrieved from an XCImage object, in this case a terrain-sprite at the right animation frame

ps. LOCKBITS is an experimental routine that draws sprites pixel by pixel; but i didn't notice any speed increase so its on hold indefinitely.


Quote
UPDATE 2: Found "Use Mono" option. Now everything is fine.
i guess I should make note of that on the Distribution page ... a bit of my bad


Quote
Stoddard's latest build https://lxnt.wtf/oxem/builds//MapView/MapView-ab4868ec-2019-02-08-mono.7z does not work in my system (Ubuntu 16.04), giving the error:

For System.MissingMethodException: Method 'String.Format' not found.
  at YamlDotNet.RepresentationModel.YamlStream.Load (IParser parser) <0x40cbb760 + 0x0003b> in <filename unknown>:0
  at YamlDotNet.RepresentationModel.YamlStream.Load (System.IO.TextReader input) <0x40cb99b0 + 0x00047> in <filename unknown>:0
  at MapView.XCMainWindow.LoadOptions () <0x40cb7f20 + 0x0013b> in <filename unknown>:0
  at MapView.XCMainWindow..ctor () <0x40c17b80 + 0x006bb> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) MapView.XCMainWindow:.ctor ()
  at MapView.Startup.RunProgram () <0x40bd6fe0 + 0x000db> in <filename unknown>:0

hm, appears Mono doesn't interpret something in YamlDotNet quite right. perhaps @Stoddard can give it a run and get the line # of the offending String.Format() ? Does it happen with an empty /settings folder? Ie, try deleting MapViewers.yml (window positions)



hm, i googled for "mono MissingMethodException string.format"

a couple of possible leads ...

a) Unable to execute build.sh in Ubuntu due to "Error: Method 'String.Format' not found."
https://github.com/cake-build/cake/issues/1929
(resolution: upgrade Mono)

b) Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.Object)
https://stackoverflow.com/questions/30558827/method-not-found-system-string-system-string-formatsystem-iformatprovider-sy
(resolution: force a different overload for String.Format())


here's a better stacktrace of what i think is going on,
https://github.com/kevL/OpenXCOM.Tools/blob/master/YamlDotNet/Core/ParserExtensions.cs#L46
called from
https://github.com/kevL/OpenXCOM.Tools/blob/master/YamlDotNet/RepresentationModel/YamlStream.cs#L100
called from
https://github.com/kevL/OpenXCOM.Tools/blob/master/MapView/Forms/MainWindow/XCMainWindow.cs#L573

which means parser.Allow<T>() is null, which means parser.Accept<T>() is false, which means parser.Current is *not* T, which throws a YamlException with the string.Format() call that borks.

Try deleting MapViewers.yml
« Last Edit: February 11, 2019, 03:50:25 am by kevL »

Offline tkzv

  • Commander
  • *****
  • Posts: 586
    • View Profile
Re: MAPVIEW upgrade
« Reply #393 on: February 11, 2019, 08:56:20 am »
(resolution: upgrade Mono)
Most likely for me. 16.04 has frozen the version.

Offline luke83

  • Commander
  • *****
  • Posts: 1461
    • View Profile
    • openxcommods
Re: MAPVIEW upgrade
« Reply #394 on: February 11, 2019, 11:49:38 am »
Hey KevL, do these errors mean anything to you?

I get this on mapset Grunge1, if i make ANY changes to that mapset ( even just changeing the shade of 1 pixel in the set), when i try to load it back into Mapview it gives the below errors. At first i thought it was MCDEDIT corrupting the file but it loads perfectly in Openxcom ( and displays correctly) its only mapview that crashes out.

Any thoughts?
« Last Edit: February 11, 2019, 11:54:43 am by luke83 »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 8588
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: MAPVIEW upgrade
« Reply #395 on: February 11, 2019, 12:05:54 pm »
Kevl, is there any method of converting the old mapedit.dat/images.dat information to your format?
I would like to give your work a try, but I have hundreds of custom terrains and mapblocks, and there's just no way I'm going to do this manually.

Online kevL

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: MAPVIEW upgrade
« Reply #396 on: February 11, 2019, 03:56:33 pm »
@luke83
loading ...

EDIT:
GRUNGE1_L83.PCK/TAB looks borked. It won't open in PckView (correctly) either. suggest recreating if poss.



@Solarius Scorch
in the .7z package (windows build) there's a subdir /ConfigConverter

it's a standalone app that requires MapEdit.dat, Images.dat, AND Paths.pth (input)

and outputs MapTilesets.yml

There's a ReadMe.txt ...


It's only been tested with what I have here, and a couple other dats that unfortunately strike me as a bit buggy, or at least quirky from the git go ...

am curious what results you could get from it. Pls pay attention to any dialogs that pop, the output (MapTilesets) could well need tweaking,

but i'd be happy to work on it with ya if it comes to that,
« Last Edit: February 11, 2019, 05:20:06 pm by kevL »

Offline luke83

  • Commander
  • *****
  • Posts: 1461
    • View Profile
    • openxcommods
Re: MAPVIEW upgrade
« Reply #397 on: February 11, 2019, 06:27:00 pm »
Borked? It looks fine on my end, what are you seeing?

Yes i can recreate it, problem is, as soon as i change anything at all, it "breaks" again...its loading into OXC ok but i would like to have a working file, i might try changing the images through PCK view then and see if that avoids what ever is going on.

Thanks again mate :)
« Last Edit: February 11, 2019, 06:30:04 pm by luke83 »

Online kevL

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: MAPVIEW upgrade
« Reply #398 on: February 11, 2019, 07:51:07 pm »
i did a bit of debugging ...

for some reason there's a mismatch between the quantity of sprites in the PCK and the quantity of sprites expected by the TAB.

Code: [Select]
SpriteCollection..cTor
. fsTab.Length= 106
. tabOffsetLength= 2
. tabSprites= 53
pckSprites= 56 tabSprites= 53


looking at the PCK and TAB files in a hexeditor shows that the last few blank sprites have somehow caused a mismatch between the PCK and TAB data. (i fixed it with the hexeditor to make it work, but the point is that something went distinctly screwy somewhere along the production line)

OXC and MCDEdit can let things go through okay -- no harm done perhaps. But PckView/MapView do error-checking to ensure the quantity of sprites match the quantity expected by the TAB file. If they don't the spriteset goes null,

that's just the way it is, Luke


(but i'll put a note in my TODO, to issue an error... hrm, it's problematic due to the UFO vs TFTD taboffsets... bleh)

Offline luke83

  • Commander
  • *****
  • Posts: 1461
    • View Profile
    • openxcommods
Re: MAPVIEW upgrade
« Reply #399 on: February 12, 2019, 08:03:34 am »
Used your awesome PCKview to change the graphics over without any issues, i dont know what caused the issue but its great to be able to work around them :)

Online kevL

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: MAPVIEW upgrade
« Reply #400 on: February 12, 2019, 09:33:21 am »
sweet :)

but all i've been doing is riff off what Ben did,

Offline luke83

  • Commander
  • *****
  • Posts: 1461
    • View Profile
    • openxcommods
Re: MAPVIEW upgrade
« Reply #401 on: February 13, 2019, 07:46:42 am »
Still, your doing great work, keep it up, the community appreciated you keeping the tools alive.

I wish Apoc had someone working on the modding tools, i just found a image extractor that is dos based, still looking for any newer programs. I am looking into the idea of doing my Foxy ( Fantasy Open Xcom) in APoc instead of OXC so am now looking at tools.
« Last Edit: February 13, 2019, 07:49:20 am by luke83 »

Offline tkzv

  • Commander
  • *****
  • Posts: 586
    • View Profile
Re: MAPVIEW upgrade
« Reply #402 on: February 15, 2019, 12:02:56 pm »
MapView with Mono has troubles saving GIF images. The background is filled with garbage.


And a few questions to avoid creating an extra post:

Is there any easier way to add custom maps to the tree, other than modifying MapTilesets.yml and restarting?

Is there an undo?

Are there keyboard shortcuts for map editing (move cursor, change level, cut/copy/paste...)?
« Last Edit: February 15, 2019, 12:07:13 pm by tkzv »

Online kevL

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: MAPVIEW upgrade
« Reply #403 on: February 15, 2019, 04:19:01 pm »
MapView with Mono has troubles saving GIF images. The background is filled with garbage.

I'd like to output screenshots in PNG (eventually), i glanced at the SaveGif() function when implementing PNG input/output for PckView ... hoped it was working ok, guess not :\


answers to these questions are in the CHM-help file. if there's a viewer for CHM on non-windows ...

Quote
Is there any easier way to add custom maps to the tree, other than modifying MapTilesets.yml and restarting?

right click on the Maptree and, depending on what node is selected, options should pop up in a menu

Quote
Is there an undo?

no. Implementing Undo/Redo in a nontrivial codebase that wasn't written with it in mind is (very) nontrivial.

Quote
Are there keyboard shortcuts for map editing (move cursor, change level, cut/copy/paste...)?

cut = Ctrl+x
copy = Ctrl+c
paste = Ctrl+v
delete = Delete

(but not sure about non-windows systems)

move cursor - nope, am thinking about it at some point tho.
change level - nope.

because of the way MapView was originally coded, implementing shortcuts is a fair bit more complicated than normal,

Offline Stoddard

  • Colonel
  • ****
  • Posts: 457
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: MAPVIEW upgrade
« Reply #404 on: February 15, 2019, 04:44:52 pm »
I'd like to output screenshots in PNG (eventually), i glanced at the SaveGif() function when implementing PNG input/output for PckView ... hoped it was working ok, guess not :\

This very much looks like uninitialized memory, like, dest image not cleared before drawing. Maybe windows does it automatically while mono does not.