uiMapEditer - HerissonMignion/FactorioOrganizer GitHub Wiki

Handles everything related to edition of the map.

uiMapEditer is a class that controls a picture box a receive inputs of the user via events (mouse move/down/up...).

Virtual coordinate

Virtual coordinate are PointF are graphical are Point. There two functions allow transition between virtual and ui.

  • ConvertUiToVirtual
  • ConvertVirtualToUi

The virtual pos of center of the screen is the property vpos. The property VirtualWidth is the width of the virtual area shown in the screen. This means that multiplying that property by a number greater than 1 will zoom out.

Image shown

uiMapEditer has a void RefreshImage. that void creates the new image to show to the user. At the end (when the next image to show is completely finished), it dispose the image actually in the .Image property of the picturebox and set the new image to that property.

This image is made in two part

  • Draw links
  • Draw mapobjects (both belts and machines)

It draw links before to make sure that links don't hide belts and machines.

Shown image when addmode, moving object, dragging the map

In addmode or when moving an object, there's a cercle or a rectangle following the mouse. Also when dragging the map, of course the map follow the mouse. The image in .Image is not modified. In these process, a Graphics object is made from picturebox.CreateGraphics. These graphics are temporary and will be erased when the picture box will be refreshed. The graphics of addmode and moving an object are handled in the mouse move event. Dragging the map however is handled in a timer under RefreshImage because i think that mouse move is too fast to draw an image sometimes very big.