Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more data to some objects #38

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions TsMap.Canvas/TriStateTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected override void OnCreateControl()
CheckBoxes = false;

_updating = true;
UpdateChildState(Nodes, (int) CheckedState.Unchecked, false, true);
UpdateChildState(Nodes, (int)CheckedState.Unchecked, false, true);
_updating = false;
}
protected override void OnAfterCheck(TreeViewEventArgs e)
Expand All @@ -65,7 +65,7 @@ protected override void OnAfterCheck(TreeViewEventArgs e)
_updating = true;
var node = e.Node;

node.StateImageIndex = node.Checked ? (int) CheckedState.Checked : (int) CheckedState.Unchecked;
node.StateImageIndex = node.Checked ? (int)CheckedState.Checked : (int)CheckedState.Unchecked;
UpdateChildState(node.Nodes, node.StateImageIndex, node.Checked);
UpdateParentState(node.Parent);
ItemChecked(node);
Expand Down Expand Up @@ -123,15 +123,15 @@ protected void UpdateChildState(TreeNodeCollection childNodes, int stateImageInd
protected void UpdateParentState(TreeNode node)
{
if (node == null) return;
var checkedChildren = node.Nodes.Cast<TreeNode>().Count(childNode => childNode.StateImageIndex == (int) CheckedState.Checked);
var checkedChildren = node.Nodes.Cast<TreeNode>().Count(childNode => childNode.StateImageIndex == (int)CheckedState.Checked);

if (checkedChildren == node.Nodes.Count)
{
node.StateImageIndex = (int) CheckedState.Checked;
node.StateImageIndex = (int)CheckedState.Checked;
node.Checked = true;
}
else
node.StateImageIndex = (int) CheckedState.Mixed;
node.StateImageIndex = (int)CheckedState.Mixed;
}

public TreeNode GetNodeByName(TreeNode rootNode, string name)
Expand Down Expand Up @@ -162,7 +162,7 @@ public CheckedState GetStateByNodeName(string name)
{
var node = GetNodeByName(name);
if (node == null) return CheckedState.Unchecked;
return (CheckedState) node.StateImageIndex;
return (CheckedState)node.StateImageIndex;
}

public bool GetCheckedByNodeName(string name)
Expand Down
4 changes: 2 additions & 2 deletions TsMap.Canvas/TsMapCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void GenerateTileMap(int startZoomLevel, int endZoomLevel, string export

for (int z = startZoomLevel; z <= endZoomLevel; z++) // https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
{
ZoomOutAndCenterMap((int) Math.Pow(2, z) * tileSize, (int) Math.Pow(2, z) * tileSize,
ZoomOutAndCenterMap((int)Math.Pow(2, z) * tileSize, (int)Math.Pow(2, z) * tileSize,
out PointF pos, out float zoom); // get zoom and start coords for current tile level

for (int x = 0; x < Math.Pow(2, z); x++)
Expand Down Expand Up @@ -247,7 +247,7 @@ private void MapPanel_Paint(object sender, PaintEventArgs e)

e.Graphics.ResetTransform();
e.Graphics.FillRectangle(Brushes.Black, new Rectangle(0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height));
e.Graphics.DrawString( $"Generating Tile Map, current tile: {_currentGeneratedTile}/{_totalTileCount}", font,
e.Graphics.DrawString($"Generating Tile Map, current tile: {_currentGeneratedTile}/{_totalTileCount}", font,
Brushes.CornflowerBlue, 10, 10);

if (_totalTileCount == 0)
Expand Down
6 changes: 3 additions & 3 deletions TsMap/FileSystem/CityHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static ulong HashLen0To16(byte[] s, ulong len)
{
var a = Fetch64(s);
var b = Fetch64(s, len - 8);
return HashLen16(a, RotateByAtleast1(b + len, (int) len)) ^ b;
return HashLen16(a, RotateByAtleast1(b + len, (int)len)) ^ b;
}

if (len >= 4)
Expand All @@ -136,8 +136,8 @@ private static ulong HashLen0To16(byte[] s, ulong len)
var a = s[0];
var b = s[len >> 1];
var c = s[len - 1];
var y = a + ((uint) b << 8);
var z = len + ((uint) c << 2);
var y = a + ((uint)b << 8);
var z = len + ((uint)c << 2);
return ShiftMix(y * K2 ^ z * K3) * K2;
}

Expand Down
45 changes: 45 additions & 0 deletions TsMap/Helper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;

namespace TsMap
{

public static class RenderHelper
{

public static PointF RotatePoint(float x, float z, float angle, float rotX, float rotZ)
{
var s = Math.Sin(angle);
Expand Down Expand Up @@ -45,6 +49,47 @@ public static int GetZoomIndex(Rectangle clip, float scale)
if (smallestSize < 18500) return 2;
return 3;
}

public static PointF GetPoint(float x, float y)
{
return new PointF(x, y);
}

public static PointF GetPoint((float, float) p)
{
return new PointF(p.Item1, p.Item2);
}

public static PointF GetPoint(TsItem.TsItem item)
{
return new PointF(item.X, item.Z);
}

public static (float, float) ScsMapCorrection(float x, float y)
{
if (x < -31100 && x > -60720 && y < -5500 && y > -56300)
{
x = (x + 31100f) * 0.75f - 31700f;
y = (y + 5500f) * 0.75f - 5100f;
}
return (x, y);
}

public static PointF ScsMapCorrection(PointF p)
{
return GetPoint(ScsMapCorrection(p.X, p.Y));
}

public static PointF[] ScsMapCorrection(PointF[] p)
{
return p.Select(pp => ScsMapCorrection(pp)).ToArray();
}

public static List<PointF> ScsMapCorrection(List<PointF> p)
{
return p.Select(pp => ScsMapCorrection(pp)).ToList();
}

}

public static class SiiHelper
Expand Down
6 changes: 3 additions & 3 deletions TsMap/JsonHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;

namespace TsMap
{
Expand Down
3 changes: 1 addition & 2 deletions TsMap/LocalizationManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using TsMap.FileSystem;
Expand Down Expand Up @@ -122,7 +121,7 @@ public void AddLocaleValue(string localeName, string localized_name_key, string

if (!_localization[localeName].ContainsKey(localized_name_key))
{
_localization[localeName].Add(localized_name_key, localized_name);
_localization[localeName].Add(localized_name_key, localized_name);
}
}

Expand Down
14 changes: 7 additions & 7 deletions TsMap/Map/Overlays/ColorTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ internal Color8888(byte a, byte r, byte g, byte b)
internal Color8888(Color565 color565, byte a)
{
A = a;
R = (byte) (color565.R << 3);
G = (byte) (color565.G << 2);
B = (byte) (color565.B << 3);
R = (byte)(color565.R << 3);
G = (byte)(color565.G << 2);
B = (byte)(color565.B << 3);
}

internal void SetAlpha(byte a)
Expand All @@ -42,19 +42,19 @@ private Color565(byte r, byte g, byte b)
B = b;
}

internal Color565(ushort color) : this((byte) ((color >> 11) & 0x1F), (byte) ((color >> 5) & 0x3F),
(byte) (color & 0x1F))
internal Color565(ushort color) : this((byte)((color >> 11) & 0x1F), (byte)((color >> 5) & 0x3F),
(byte)(color & 0x1F))
{
}

public static Color565 operator +(Color565 col1, Color565 col2)
{
return new Color565((byte) (col1.R + col2.R), (byte) (col1.G + col2.G), (byte) (col1.B + col2.B));
return new Color565((byte)(col1.R + col2.R), (byte)(col1.G + col2.G), (byte)(col1.B + col2.B));
}

public static Color565 operator *(Color565 col1, double val)
{
return new Color565((byte) (col1.R * val), (byte) (col1.G * val), (byte) (col1.B * val));
return new Color565((byte)(col1.R * val), (byte)(col1.G * val), (byte)(col1.B * val));
}

public static Color565 operator *(double val, Color565 col1)
Expand Down
3 changes: 3 additions & 0 deletions TsMap/Map/Overlays/MapOverlayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ private OverlayImage GetOrCreateOverlayImage(string overlayName, OverlayType ove
case OverlayType.BusStop:
path = $"tsmap/overlay/{overlayName}.mat";
break;
case OverlayType.Flag:
path = $"material/ui/flags/{overlayName}.mat";
break;
default:
path = $"{PathHelper.EnsureLocalPath(overlayName)}.mat";
break;
Expand Down
Loading