Added partial file import and Hints calculation
This commit is contained in:
+44
-7
@@ -14,6 +14,7 @@ namespace NonoGramme
|
||||
{
|
||||
private readonly Color DEFAULT_FULL_COLOR = Color.Black;
|
||||
private readonly Color DEFAULT_EMPTY_COLOR = Color.LightGray;
|
||||
private readonly Color DEBUG_UNDISCOVERED_COLOR = Color.DarkOliveGreen;
|
||||
private readonly Color DEFAULT_BORDER_COLOR = Color.Pink;
|
||||
private readonly Color DEFAULT_ERROR_COLOR = Color.Purple;
|
||||
|
||||
@@ -126,15 +127,38 @@ namespace NonoGramme
|
||||
rawData = matches[0].Groups[1].Value;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(rawData);
|
||||
|
||||
/*
|
||||
for ()
|
||||
//MessageBox.Show(rawData);
|
||||
if (rawData.Length != size.Width * size.Height)
|
||||
MessageBox.Show("The file contains conflicting datas");
|
||||
|
||||
//Filling the class with infos
|
||||
GridSize = size;
|
||||
HorizontalLines = new Line[GridSize.Height];
|
||||
VerticalLines = new Line[GridSize.Width];
|
||||
|
||||
for (int y = 0; y < GridSize.Height; y++)
|
||||
{
|
||||
HorizontalLines[y] = new Line(GridSize.Width);
|
||||
for (int x = 0; x < GridSize.Width; x++)
|
||||
{
|
||||
if (y == 0)
|
||||
{
|
||||
VerticalLines[x] = new Line(GridSize.Height);
|
||||
}
|
||||
|
||||
Tile.State tileState = Tile.State.Empty;
|
||||
int flatIndex = y * GridSize.Width + x;
|
||||
if (rawData[flatIndex] == 1)
|
||||
{
|
||||
tileState = Tile.State.Undiscovered;
|
||||
}
|
||||
HorizontalLines[y].Edit(x,tileState);
|
||||
VerticalLines[x].Edit(y,tileState);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
MessageBox.Show("File imported Successfully");
|
||||
}
|
||||
private void Populate()
|
||||
{
|
||||
@@ -157,7 +181,7 @@ namespace NonoGramme
|
||||
state = Tile.State.Empty;
|
||||
break;
|
||||
case 3:
|
||||
state = Tile.State.Full;
|
||||
state = Tile.State.Undiscovered;
|
||||
break;
|
||||
default:
|
||||
state = Tile.State.Empty;
|
||||
@@ -169,8 +193,21 @@ namespace NonoGramme
|
||||
}
|
||||
Console.WriteLine("Coucou");
|
||||
}
|
||||
public void RefreshGrid()
|
||||
{
|
||||
foreach (Line line in HorizontalLines)
|
||||
{
|
||||
line.RecalculateHints();
|
||||
}
|
||||
foreach (Line line in VerticalLines)
|
||||
{
|
||||
line.RecalculateHints();
|
||||
}
|
||||
}
|
||||
public Bitmap Draw(Bitmap UI,Point offset)
|
||||
{
|
||||
RefreshGrid();
|
||||
|
||||
Size actualSize = new Size(UI.Width - offset.X, UI.Height - offset.Y);
|
||||
Size blocSize = new Size(actualSize.Width/GridSize.Width,actualSize.Height/GridSize.Height);
|
||||
|
||||
@@ -216,7 +253,7 @@ namespace NonoGramme
|
||||
g.FillRectangle(new SolidBrush(DEFAULT_EMPTY_COLOR), new Rectangle(position, blocSize));
|
||||
break;
|
||||
case Tile.State.Undiscovered:
|
||||
g.FillRectangle(new SolidBrush(DEFAULT_FULL_COLOR), new Rectangle(position, blocSize));
|
||||
g.FillRectangle(new SolidBrush(DEBUG_UNDISCOVERED_COLOR), new Rectangle(position, blocSize));
|
||||
break;
|
||||
default:
|
||||
g.FillRectangle(new SolidBrush(DEFAULT_ERROR_COLOR), new Rectangle(position, blocSize));
|
||||
|
||||
Reference in New Issue
Block a user