Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - MadHaTr

Pages: [1] 2
Tools / Re: Map Editor/Creator
« on: May 23, 2017, 03:19:56 pm »
Okay that makes sense for blanks.

  • Each of my pixels as decimals can contain 0-255.
  • Each palette inside PALETTES.DAT is essentially 0-255 as well(Sets of 3 bytes= 768)
  • There are 5 palettes inside the DAT file so 0-1279 locations.
  • Okay I am making the assumption that each pixel is it's own reference to a colour in the palette, is this correct?  If so...
  • Is there a byte somewhere telling me an offset(since a byte can't reference inside all 5 palettes), or is it just hard coded that if I am opening BARNS.PCK  it will be using palette 5. Tactical Palette.

Actually... I guess since this is a map editor I can ignore all other palettes right? All I need is the tactical palette.  Could I still get question one answered,  also if someone sees a reason for me not ignoring the other palettes let me know.

Tools / Re: Map Editor/Creator
« on: May 22, 2017, 07:05:00 pm »
I seem to have my PCK file decompression algo working correctly. Where can in find the details on how to colour the pixels? I seen the palettes info page that and using 3 bytes to make a colour but I don't see where the reference is for what each byte in my PCK file means.

Here is a pic of the decompress(in hex) of the blanks.pck.  You can make out the diamond(isometric?) shape in the first sprite(in hex) (floor portion of tile?)

I've noted that none of the sprites in the pck files ive look at so far are 1,280 pixels(32x40).  In this included pic you can see the first sprite in the blanks.pck is 32x15.  So are these all just parts of potential 32x40 tiles? I guess once i start drawing them it may make more sense.

Tools / Re: Map Editor/Creator
« on: May 21, 2017, 05:12:22 pm »
MadHaTr, if you read Python, you might find this useful:

Thanks, I did have a look but I do not read py.  From what I could pick up it seemed that the code I needed to see was in some other files/structs which I could not locate.

Well WinForms is as old as Windows itself. :P As a shameless WPF fanboy I will say it is much easier for making custom UIs and controls like you would find in editors, rather than trying to hack around boilerplate Windows UI with Forms. It's true that the Visual Studio designer is better at WinForms than WPF, but it feels better to write WPF by hand anyways.

Sure, technology is not that important to the end-user, but it is important to the developer so these projects will actually end up somewhere besides the cutting room floor...
One thing I would suggest is looking into being more cross-platform. MapEdit's biggest gripe has always been its Windows-ness, so even if you're using .NET I would suggest checking what technologies are/will be easier to port in the future as Microsoft develops .NET Core / Xamarin. Being able to make maps on the go on a tablet would be amazing. ;)
I have to say I am really starting to enjoy the WPF, this is my first time using it and I like how flexible it is while coding up the interface.  Cross-platform is on the burner, I noted here on the forum people trying to get things working on their various systems.  I'd have to do some research like you say, while I know .NET is cross-platform I am not up on the details.

PCK files are super straightforward:
- TAB files (if available) are just a list of offsets for each sprite. They index directly into the PCK bytes, so to load sprite 3 you just start reading from PCK[offset3] until you reach PCK[offset4] (or the end of file).
The only catch is that while UFO only uses 2-byte offsets, TFTD sometimes uses 4-byte offsets, but you can just hardcode or guess it.
- PCK files are just a list of pixels (compressed or otherwise). They always have the same dimensions, so you can assume they're always 32px in width. In fact if you're loading the whole file at once you don't even need the offsets, as every sprite has an explicit "end of sprite" delimiter byte.
Thanks for this, I was able to see that the pck files were one image right after the other with the FF ending each of them.  I also figured out the tab file offset thing by looking at mapedits code.   I probably would have been lost for a long time,  sure I knew it was all in 2 or 4 byte sets but I didn't realize I had to toss these into a 16bit or 32 bit integer to see the proper numbers.  This is probably from my lack of formal education on the matter. I did have a comp sci class in HS and had 1 course in UNI but this was years(many) ago lol.

For the moment I think I will continue on with just reading/decompressing the pck file and getting the sprites rendered to an on screen tile map with some tool functionality.   When it comes time for the save files i'll get back to the proper formatting of files.

Tools / Re: Map Editor/Creator
« on: May 14, 2017, 12:22:47 am »
I was probably just inferring hostility, I don't believe anyone meant me to feel that way.

I was going over the data files today and reading on ufopedia.  I am using a hex editor to get a rough idea of things which worked great for the MCD files, they are very straight forward in each set of 62 bytes.   The BAT and PCK files on the other hand I am having difficulty locking them down. 

As I understand the BAT info about UFO from ufopedia, BAT files detail the start of sprite files inside the PCK files using 2 bytes of info(converted to dec/pixels?). It's not explained if the 2 byte data sets begins at the start of the file or later; I think they start right at the beginning because they each have 00 00. More importantly if the file references an uncompressed PCK file or the compressed PCK file.

The PCK file info explains decompressing by reading the first byte and skipping down the following rows, do I assume the rows are 32 bytes in length to match the sprite dimensions? Not sure how to know how large I should organize my rows so I can count downwards.

Tools / Re: Map Editor/Creator
« on: May 11, 2017, 01:37:21 am »
Thanks for the replies guys. I'm just a guy wanting to write a tool. You all seem kind of hostile.

I just quickly googled WPF vs WinForms, and threw in the info here. The article had no date, though checking google the date appears as 2015. I'm aware WPF was introduced in 2010. Here is another article from 5 days ago giving good reasons for WPF over WinForms; I'm mostly interested in the databinding and enhanced visual abilities. Obviously anyone should go do their own research if they are worried about it. As to the GUI, that was a screen shot from inside the msvc2015 project. It is a rough idea I had on how the layout might go.  So possibly elaborate on a realistic screenshot.

I am not saying anything bad about MapEdit or it's developer. I understand it has been around for a very long time.  I'm just looking for feedback on what everyone thinks would be a good user interface. Which requires no functionality.  Just ideas.

Like none of you have ever said oh I wish this was here or that control was over there or I wish I could do.  Like or maybe I wish the whole screen was the map editor and i had 10 squares along the bottom with my most used tiles and i just have to click a tab somewhere to open the tileset view and switch them out or grab a new tile. 

Tools / Re: Map Editor/Creator
« on: May 10, 2017, 10:00:50 pm »
Hey Solarius, thanks for responding. We're a bit far from me worrying about how many people will use this software.  This project will be a good learning adventure for me, especially since I have always be interested in tile maps and more importantly have loved X-Com from the day my buddy let me get a copy of his back in 94. 

I was dismayed ever so slightly that all the content creators here are having to use a partially broken tool. 

The one big difference, would be that the entire program will be in one window, with all the extra maps(tileset, routes) available in the smaller viewport on the left with a click of a button or hotkey.  Mapedit uses WinForm, this project will use WindowsPresentationFoundation which as it sounds is better at dealing with graphics. There are pros and cons.

So as I said I am looking for feedback on the entirety of the GUI.

Spoiler Windows Presentation Foundation:
WPF is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of standalone and browser-hosted applications. Although releases for WPF were stagnant for a while, Microsoft recently announced the future roadmap for WPF.


Powerful styling and skinning structure
Easy to create an own look and feel
It’s very flexible so you can re design your own controls without buying new controls
It's newer and thereby more in tune with current standards of technology
Does support Windows Forms
XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer (XAML) and a programmer
Highly advanced data binding possible.
Uses hardware acceleration for drawing the GUI, for better performance
The ability to reuse existing code
Declarative vs. procedural code


Requires .NET Framework 3.0
Compared to Windows Forms, still in evolving phases.
Requires Dx9 compatible video card for advanced graphics

Spoiler Winforms:
WinForms applications have always been used to develop desktop applications where you want the entire processing burden to be rested on the client machine. This includes everything from drawing of graphics applications to data-entry systems to point-of-sale systems and games.


Extensive documentation can be found on the Internet
Plenty of examples and tested thoroughly for years
Supports WPF
There are lot of 3rd party controls in the market to make the job easier
The designer in Visual Studio is still, as of writing, better for WinForms than for WPF, where you will have to do more of the work yourself with WPF

Designing your own look and feel in an application is a lot of work
Extra cost incurred to buy third party controls

Tools / Re: Map Editor/Creator
« on: May 10, 2017, 03:57:32 am »
Here is the prototype I have for the user interface.  I am looking for feedback for what people think should go where and what shall be added or removed.

The area between the left upper, left lower and the right canvas I was thinking of using for the buttons, like copy, paste, delete.  The rest is mostly self explanatory. 

Show me the feedback!

Tools / Map Editor/Creator
« on: May 10, 2017, 03:57:20 am »
I've started a new project using WPF/C# to create a map editor for x-com/open x-com maps.

  • Create intuitive UI
  • Write a tile engine to load the maps into and display to a canvas
  • Use tile engine to load tile sets to a different canvas in the main window
  • Undo/Redo
  • Write the file loading/writing module
  • create a git project once more than the UI is in place
Extended Goals
  • Custom window and interface graphic

User suggestions/requests
  • Take user feedback

OpenXcom Extended / Re: suggestion: complex UFO crash damage
« on: April 23, 2017, 01:10:19 am »
I'm not sure how it all works but I figured you would need some custom graphics tiles and load specific map types for the shot holes and dents, but instead for smaller dmg weapons could it be possible to have the ship shot down missing nav panels and shit like that, cause why would the ship crash with some holes in the hull, unless the pilot died. Though I imagine any of them could just grab the controls and fly.

OpenXcom Extended / Re: Any Way to turn off "shot following"?
« on: April 23, 2017, 01:06:00 am »
Yeah hopefully that helps.  You could close yours eyes when you shoot like Susan Calvin in I, Robot. :D

Tools / Re: MAPVIEW
« on: April 22, 2017, 04:54:34 pm »
Okay cool,  it seems KevL has been pretty active on his fork which is nice to see.  I made my own fork ( to get more acquainted with the code.  Not going to give any illusions, this shit is above my paygrade.  Especially whatever is doing all the rendering and array setup for the pictures/tiles and what not.  What I am ok with is the forms part. Currently my goal is to add hotkey functionality, if you check the fork so far I've just been fixing cosmetic stuff, and some old code that doesn't seem to be needed anymore. 

I do need some help here though, I got stuck.  The(cut, copy, fill) buttons (toolstripbuttons) were all made manually in a separate .cs file. 
Spoiler EditButtonsFactory.cs:
Code: [Select]
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

using MapView.Properties;

namespace MapView.Forms.MainWindow
internal sealed class EditButtonsFactory
private readonly MainViewPanel _mainViewPanel;

private readonly List<ToolStripButton> _pasteButtons = new List<ToolStripButton>();

public EditButtonsFactory(MainViewPanel panel)
_mainViewPanel = panel;

        /// <summary>
        /// Adds buttons for Up,Down,Cut,Copy,Paste and Fill to the specified
        /// toolstrip as well as sets some properties for the toolstrip.
        /// </summary>
        /// <param name="toolStrip"></param>
        public void BuildEditStrip(ToolStrip toolStrip)
// toolStripButtons
//var tssDivider1 = new ToolStripSeparator();
var tsbUp       = new ToolStripButton();
var tsbDown     = new ToolStripButton();
//var tssDivider2 = new ToolStripSeparator();
var tsbCut      = new ToolStripButton();
var tsbCopy     = new ToolStripButton();
var tsbPaste    = new ToolStripButton();
//var tssDivider3 = new ToolStripSeparator();
var tsbFill     = new ToolStripButton();
//var tssDivider4 = new ToolStripSeparator();
// toolStrip
var tsItems = new ToolStripItem[] // NOTE: c# cant figure out how to use 1 separator 3 times.  //Just created them on the fly in the array MadHaTr 4/21/2017
                new ToolStripSeparator(),
                new ToolStripSeparator(),
                new ToolStripSeparator(),
                new ToolStripSeparator()
// tsbUp
tsbUp.AutoSize = false;
tsbUp.DisplayStyle = ToolStripItemDisplayStyle.Image;
tsbUp.ImageScaling = ToolStripItemImageScaling.None;
tsbUp.ImageTransparentColor = Color.Magenta;
tsbUp.Name = "tsbUp";
tsbUp.Size = new Size(25, 25);
// tsbUp.Text = "Level Up";
tsbUp.ToolTipText = "Level Up";
tsbUp.Click += OnUpClick;
// tsbDown
tsbDown.AutoSize = false;
tsbDown.DisplayStyle = ToolStripItemDisplayStyle.Image;
tsbDown.ImageScaling = ToolStripItemImageScaling.None;
tsbDown.ImageTransparentColor = Color.Magenta;
tsbDown.Name = "tsbDown";
tsbDown.Size = new Size(25, 25);
// tsbDown.Text = "Level Down";
tsbDown.ToolTipText = "Level Down";
tsbDown.Click += OnDownClick;
// tsbCut
tsbCut.AutoSize = false;
tsbCut.DisplayStyle = ToolStripItemDisplayStyle.Image;
tsbCut.ImageScaling = ToolStripItemImageScaling.None;
tsbCut.ImageTransparentColor = Color.Magenta;
tsbCut.Name = "tsbCut";
tsbCut.Size = new Size(25, 25);
// tsbCut.Text = "Cut";
tsbCut.ToolTipText = "Cut";
tsbCut.Click += (sender, e) =>
_mainViewPanel.OnCut(sender, e);
// tsbCopy
tsbCopy.AutoSize = false;
tsbCopy.DisplayStyle = ToolStripItemDisplayStyle.Image;
tsbCopy.ImageScaling = ToolStripItemImageScaling.None;
tsbCopy.ImageTransparentColor = Color.Magenta;
tsbCopy.Name = "tsbCopy";
tsbCopy.Size = new Size(25, 25);
// tsbCopy.Text = "Copy";
tsbCopy.ToolTipText = "Copy";
tsbCopy.Click += (sender, e) =>
_mainViewPanel.OnCopy(sender, e);
// tsbPaste
tsbPaste.AutoSize = false;
tsbPaste.DisplayStyle = ToolStripItemDisplayStyle.Image;
tsbPaste.ImageScaling = ToolStripItemImageScaling.None;
tsbPaste.ImageTransparentColor = Color.Magenta;
tsbPaste.Name = "tsbPaste";
tsbPaste.Size = new Size(25, 25);
// tsbPaste.Text = "Paste";
tsbPaste.ToolTipText = "Paste";
tsbPaste.Click += (sender, e) =>
_mainViewPanel.OnPaste(sender, e);
tsbPaste.Enabled = false;
// tsbFill
tsbFill.AutoSize = false;
tsbFill.DisplayStyle = ToolStripItemDisplayStyle.Text;
tsbFill.Name = "tsbFill";
tsbFill.Size = new Size(25, 25);
tsbFill.Text = "Fill";
tsbFill.ToolTipText = "Fill";
tsbFill.Click += (sender, e) =>
_mainViewPanel.OnFill(sender, e);
tsbUp.Image    = Resources.up;
tsbDown.Image  = Resources.down;
tsbCut.Image   = Resources.cut;
tsbCopy.Image  = Resources.copy;
tsbPaste.Image = Resources.paste;
// tsbFill.Image  = ; // TODO: embed a Fill image.

private static void Refresh()
// MainViewPanel.Instance.Refresh(); // either this
MainViewPanel.Instance.MainView.Refresh(); // or this, both works


// TODO: refresh TopRouteView (both Top & Route panels) also.

/// <summary>
/// Enables the paste button in each viewer after cut or copy is clicked.
/// </summary>
private void EnablePasteButton()
foreach (var tsb in _pasteButtons)
tsb.Enabled = true;

private void OnDownClick(object sender, EventArgs e)
if (MainViewPanel.Instance.MainView.Map != null)

private void OnUpClick(object sender, EventArgs e)
if (MainViewPanel.Instance.MainView.Map != null)

I am used to the designer creating the buttons and having them inside the main form class which I think of as the main program loop. In this case it would be XCMainWindow() inside this .cs file
Spoiler XCMainWindow.cs:

Hit the char limit of the forum, so here is the link to the next file.

My problem is I have/had a couple lines of code to detect keypresses in the main form file, and if a key is pressed it would trigger the   .click functionality of the button.  Problem is since they are in different files they are in different scopes? so when I try to trigger the buttons .click from inside the main loop (XCMainWindow()) it had no idea what I am talking about cause in its eye it does not exist.

Usually I think anyway, you could just make these functions/variables public and they would be available to the other files(classes? methods?)  Though the EditButtonsFactory.cs class is declared in a way I do no understand I guess.  I've not very good with classes and it gets worse when they are across different files.

I can just redo all the buttons in main cs file but I don't want to get to far away from KevL's code if he wants to merge my other smaller cosmetic fixes in.  Also new to GitHub so not really sure how its controlled.

So anyway, anyone who thinks they can offer solution, feel free to do so.  I spent all day yesterday messing around with this stuff.  It can be fun.

« on: April 21, 2017, 05:26:23 pm »
Edit - Am now working on the code and asking for help on a few things, see below.


I am attempting to figure out how to use the program mapview. I seem to have it somewhat figured out.  I am curious about a few things which I consider to be bugs or just odd features.  I have compiled from the latest (as of 11:00 Atlantic Time April 21) KevL git (

When I open the first 3 UFO's in the vanilla OXC they seem to be corrupted. (attached files)

When I have any other window open (Tile view) the selction behaviour on the main window changes to selecting of rectangular areas (think drag selection of area) while only click different tiles, thus making it impossible for me to edit maps with the tile view window open.  Also I lose all control of the window, I can no longer select any buttons. (attached files)

Are there no hotkeys for the editing functions (fill, copy and cut) took me forever to realise I needed to be hitting these windows buttons up top to edit, I figured a good double click or a ctrl-v would be the way to do it.  (maybe this is a bug, related to previous said behaviour)

Is there no undo function?

Thanks guys, appreciate your help.

XPiratez / Re: Bugs & Crash Reports
« on: April 17, 2017, 11:48:51 pm »
Bug:  I had a sharp guy in the workshop ready to be robbed, the project had no been started and no assigned runts.  I forgot what Item sharp guy gives me so I thought I would remove it and add it back.  The bug , the sharp guy was deleted.

Autosave is before,  x1 save is after.   The ship is returning from a mission with the sharp guy in the autosave. Once it returns you may reproduce the bug by simply adding a sharp guy robbery with no runts and then removing it and trying to add it again. The sharp guy is gone.

Troubleshooting / Re: Xcode build failure (OSX 10.12)
« on: April 14, 2017, 04:37:35 am »
You followed the instructions in the xcode folder that came with the source code?   

To successfully build an OpenXcom OSX bundle you will need the relevant Xcode project files provided herewith as well as all the relevant dependencies installed in /usr/local/.

The dependencies you require are following:
- SDL (libsdl1.2)
- SDL_mixer (libsdl-mixer1.2)
- SDL_gfx (libsdl-gfx1.2), version 2.0.22 or later
- SDL_image (libsdl-image1.2)
- yaml-cpp, version 0.5 or later

If you want to save yourself the trouble - don’t do it manually, use Homebrew package manager - or MacPorts - instead.

This guide assumes you listened to the previous recommendation and had your dependencies installed with brew terminal command (for Homebrew), like this:
$ brew install cmake yaml-cpp --with-static-lib sdl sdl_gfx sdl_image sdl_mixer --with-flac --with-libmikmod --with-libvorbis --with-static-lib
or port terminal command (for MacPorts), like this:
$ sudo port install yaml-cpp+universal libsdl+universal libsdl_gfx+universal libsdl_image+universal libsdl_mixer+universal

1. Open the `OpenxXcom.xcodeproj` with Xcode.  Right click on the project (on the left pane) and click 'Add files to "OpenxXcom"'.  Select the 'src' directory from the root of the project.  Don't copy the files and do create folder groups.

1. Push the ‘Build’ button and cross your fingers. Congratulations, you have a working build! But it is still unplayable though.

1. Find your newly created bundle in ‘./Build/Products/Release’ folder or otherwise 'DerivedData' (find it within your Xcode preferences), and copy it to some place you feel comfortable keeping your games in.

If you want to use the portable bundle, then:

1. Copy the relevant original game data files you possess into the ‘UFO’ (for UFO: Enemy Unknown) and/or ‘TFTD’ (for XCOM: Terror from the Deep) folder within the bundle respectively. If asked by the system what to do with the files and folders already present there, select ‘Merge’.

Or, if you prefer to keep your build always separate from the game data files for various reasons:

1. Create the directory `/Users/Shared/OpenXcom/` and move your original xcom data files (UFO and TFTD directories) there.

Most of the errors I have seen are improper use of dependencies.  Though I know nothing of xcode or osx.  I know a few people have had to add YAML_CPP_DLL to the preprocessor definitions. Is there something like this in xcode?  Though honestly, not sure but I don't think your error looks like a YAML error.   

I literally just finished getting it working on Win10, in Visual Studio Community 2017(VS15)

XPiratez / Re: Bugs & Crash Reports
« on: April 13, 2017, 04:02:56 am »
Is it normal or a bug when I stun, in this example 2 reticulans, 1 a peon the other a reticulan hybrid.  Both had the Sleepy time and not the blood while on the ground.  Yet when I end mission, 1 is dead.  I notice this happening all the time.

Also a bug report.  Sorry happened a while ago in game.  Was on a harvester type ship(this is my first place so I am not to up on shit) on the bridge I was shooting a beastmaster out of armor, by the control consoles.  She goes down console blows up but I notice my view enemys went from 1 to 7 or more.(not sure why it showed them while the one was unconscience, maybe they were invisible at first until they moved)  I looked(from afar) and the breast master was on the ground sleeping so I moved out to look for other hostiles.  Well the beastmaster I guess woke up but it was really 7 of them, I had 7 or more armorless beast masters coming down from the bridge and causing all hell.   

So there is a some kind of beastmaster DUPE bug. 

I'm sorry I never grabbed the save, never thought of it at the time.  Felt I should report it anyway. 

Pages: [1] 2