-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWarningWindowSave.cs
More file actions
118 lines (101 loc) · 2.78 KB
/
WarningWindowSave.cs
File metadata and controls
118 lines (101 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System.Linq;
using System;
using FFRMapEditorMono.FFR;
namespace FFRMapEditorMono
{
public class SaveWarningWindow : WarningWindow
{
public SaveWarningWindow(Texture2D _windowtexture, SpriteFont _font, Texture2D _buttonTexture, Point resolution)
{
Type = WarningType.SaveValidation;
windowTexture = _windowtexture;
font = _font;
Show = false;
zoom = 3.0f;
windowWidth = 28 * 8;
windowDimensions = new(windowWidth, 100);
UpdatePosition(resolution);
buttons = new()
{
new(font, "Save map file anyway", _buttonTexture, new() { new EditorTask(EditorTasks.SaveNoWarning), new EditorTask(EditorTasks.SaveWarningClose, 10) }),
new(font, "Return to editor", _buttonTexture, new() { new EditorTask(EditorTasks.SaveWarningClose, 10)})
};
}
public void ProcessTasks(CanvasFFR overworld, Point resolution, TaskManager tasks)
{
EditorTask task;
if (tasks.Pop(EditorTasks.SaveWarningUpdate, out task))
{
var validationresult = overworld.ValidateObjects();
warningText = "*** Warning *** \n\n";
if (!overworld.DefaultDockPlaced)
{
warningText += "Default dock hasn't been placed.\n\n";
}
var missingobjects = overworld.MissingMapObjects;
if (missingobjects.Any())
{
string currentline = "";
//int
currentline += "Missing Map Objects: ";
for (int i = 0; i < missingobjects.Count; i++)
{
string objectname = Enum.GetName(missingobjects[i]);
if (currentline.Length + objectname.Length + 2 > 60)
{
warningText += currentline + "\n";
currentline = " " + objectname;
}
else
{
currentline += objectname;
}
if (i < (missingobjects.Count - 1))
{
currentline += ", ";
}
else
{
currentline += ".";
}
}
warningText += currentline + "\n\n";
}
var missingtiles = overworld.MissingRequiredTiles;
if (missingtiles.Any())
{
string currentline = "";
currentline += "Missing Required Tiles: ";
for (int i = 0; i < missingtiles.Count; i++)
{
string tilename = missingtiles[i];
if (currentline.Length + tilename.Length + 2 > 60)
{
warningText += currentline + "\n";
currentline = " " + tilename;
}
else
{
currentline += tilename;
}
if (i < (missingtiles.Count - 1))
{
currentline += ", ";
}
else
{
currentline += ".";
}
}
warningText += currentline + "\n\n";
}
var windowHeight = warningText.Count(c => c == '\n') * 8 + 32;
windowDimensions = new Vector2(windowWidth, windowHeight);
UpdatePosition(resolution);
}
}
}
}