File source/entities/ellipse.d changed (mode: 100644) (index 27642ad..1ff53f5) |
... |
... |
class Ellipse : Shape { |
22 |
22 |
@property |
@property |
23 |
23 |
public override int[2] position() { |
public override int[2] position() { |
24 |
24 |
return [ |
return [ |
25 |
|
to!int(bounds[0][0] + size), |
|
|
25 |
|
to!int(bounds[0][0] + size / 2), |
26 |
26 |
to!int(bounds[0][1] + size) |
to!int(bounds[0][1] + size) |
27 |
27 |
]; |
]; |
28 |
28 |
} |
} |
29 |
29 |
|
|
30 |
30 |
public override void resize(int amount) { |
public override void resize(int amount) { |
31 |
31 |
int[2] newPos = [ |
int[2] newPos = [ |
32 |
|
to!int(bounds[0][0] + size), |
|
|
32 |
|
to!int(bounds[0][0] + size / 2), |
33 |
33 |
to!int(bounds[0][1] + size) |
to!int(bounds[0][1] + size) |
34 |
34 |
]; |
]; |
35 |
35 |
|
|
File source/entities/shape.d changed (mode: 100644) (index ebd2d4f..19ce45c) |
... |
... |
class Shape : Entity { |
67 |
67 |
|
|
68 |
68 |
public override void render() { |
public override void render() { |
69 |
69 |
if(active) { |
if(active) { |
70 |
|
writeln(type ~ to!string(Global.Brush.red)); |
|
71 |
70 |
c.setSourceRgba ( |
c.setSourceRgba ( |
72 |
71 |
Global.Brush.red, Global.Brush.green, |
Global.Brush.red, Global.Brush.green, |
73 |
72 |
Global.Brush.blue, Global.Brush.alpha |
Global.Brush.blue, Global.Brush.alpha |
File source/file.d changed (mode: 100644) (index cbadc6e..a7d8a60) |
... |
... |
public class Savefile { |
26 |
26 |
content ~= entity.to_string(); |
content ~= entity.to_string(); |
27 |
27 |
} |
} |
28 |
28 |
|
|
29 |
|
public void fromFile() { |
|
30 |
|
int depth = 0; |
|
|
29 |
|
public void load() { |
|
30 |
|
Entity e; |
31 |
31 |
Shape[] entities = []; |
Shape[] entities = []; |
32 |
|
Group group; |
|
33 |
32 |
|
|
34 |
33 |
Global.Groups.clear(); |
Global.Groups.clear(); |
35 |
34 |
File f = File(filename, "r"); |
File f = File(filename, "r"); |
|
35 |
|
e = fromFile(f, entities); |
36 |
36 |
|
|
37 |
|
while(!f.eof()) { |
|
38 |
|
string line = strip(f.readln()); |
|
39 |
|
|
|
40 |
|
if(line == "") |
|
41 |
|
break; |
|
42 |
|
|
|
43 |
|
depth = groupsize(line); |
|
44 |
|
|
|
45 |
|
if(depth > 0) { |
|
46 |
|
group = Global.Groups.newGroup; |
|
47 |
|
|
|
48 |
|
for(int i = 0; i < depth; i++) { |
|
49 |
|
line = strip(f.readln()); |
|
50 |
|
group.add(parseLine(line)); // Should check wether it is a new group. |
|
51 |
|
} |
|
52 |
|
} else { |
|
53 |
|
entities.length++; |
|
54 |
|
entities[entities.length - 1] = parseLine(line); |
|
55 |
|
} |
|
56 |
|
} |
|
|
37 |
|
while(e !is null) |
|
38 |
|
e = fromFile(f, entities); |
57 |
39 |
|
|
58 |
40 |
f.close(); |
f.close(); |
59 |
41 |
|
|
|
... |
... |
public class Savefile { |
70 |
52 |
content = ""; |
content = ""; |
71 |
53 |
} |
} |
72 |
54 |
|
|
73 |
|
// TODO: Should be called by a similar function that checks wether the |
|
74 |
|
// line is in a group. |
|
75 |
55 |
private Shape parseLine(string line) { |
private Shape parseLine(string line) { |
76 |
56 |
auto words = line.split(); |
auto words = line.split(); |
77 |
57 |
|
|
|
... |
... |
public class Savefile { |
102 |
82 |
} |
} |
103 |
83 |
} |
} |
104 |
84 |
|
|
|
85 |
|
private Entity fromFile(ref File f, ref Shape[] shapes) { |
|
86 |
|
int depth = 0; |
|
87 |
|
Group group; |
|
88 |
|
string line; |
|
89 |
|
|
|
90 |
|
if(f.eof) return null; |
|
91 |
|
line = strip(f.readln()); |
|
92 |
|
if(line == "") return null; |
|
93 |
|
|
|
94 |
|
depth = groupsize(line); |
|
95 |
|
|
|
96 |
|
if(depth > 0) { |
|
97 |
|
group = Global.Groups.newGroup; |
|
98 |
|
|
|
99 |
|
for(int i = 0; i < depth; i++) { |
|
100 |
|
Entity e = fromFile(f,shapes); |
|
101 |
|
if(e is null) return group; |
|
102 |
|
else group.add(e); |
|
103 |
|
} |
|
104 |
|
|
|
105 |
|
return group; |
|
106 |
|
} else { |
|
107 |
|
shapes.length++; |
|
108 |
|
shapes[shapes.length - 1] = parseLine(line); |
|
109 |
|
write("SHAPES: "); |
|
110 |
|
writeln(shapes); |
|
111 |
|
return shapes[shapes.length - 1]; |
|
112 |
|
} |
|
113 |
|
} |
|
114 |
|
|
105 |
115 |
private int groupsize(string line) { |
private int groupsize(string line) { |
106 |
116 |
auto words = line.split(); |
auto words = line.split(); |
107 |
117 |
|
|
File source/groups.d changed (mode: 100644) (index 7a0f9e7..e4bec03) |
1 |
1 |
module dp.groups; |
module dp.groups; |
2 |
2 |
|
|
3 |
3 |
import dp.ent.group; |
import dp.ent.group; |
|
4 |
|
import Brush = dp.brush; |
4 |
5 |
|
|
5 |
6 |
public static class Groups { |
public static class Groups { |
6 |
7 |
private static Group[] groups = []; |
private static Group[] groups = []; |
|
... |
... |
public static class Groups { |
17 |
18 |
|
|
18 |
19 |
@property |
@property |
19 |
20 |
public static Group newGroup() { |
public static Group newGroup() { |
20 |
|
groups.length++; |
|
21 |
|
groups[groups.length-1] = new Group(); |
|
22 |
|
return groups[groups.length-1]; |
|
|
21 |
|
if(Brush.group is null) { |
|
22 |
|
groups.length++; |
|
23 |
|
groups[groups.length-1] = new Group(); |
|
24 |
|
return groups[groups.length-1]; |
|
25 |
|
} else { |
|
26 |
|
Group g = new Group(); |
|
27 |
|
Brush.group.add(g); |
|
28 |
|
Brush.group = g; |
|
29 |
|
return g; |
|
30 |
|
} |
23 |
31 |
} |
} |
24 |
32 |
|
|
25 |
33 |
public static void clear() { |
public static void clear() { |
File source/history.d changed (mode: 100644) (index 99ebc26..4a3378c) |
... |
... |
static class History { |
61 |
61 |
} |
} |
62 |
62 |
|
|
63 |
63 |
public static void clear() { |
public static void clear() { |
64 |
|
cmdPtr = 0; |
|
|
64 |
|
cmdPtr = commands.length = 0; |
65 |
65 |
} |
} |
66 |
66 |
|
|
67 |
67 |
public static void save(string filename) { |
public static void save(string filename) { |
|
... |
... |
static class History { |
81 |
81 |
public static void load(string filename) { |
public static void load(string filename) { |
82 |
82 |
Savefile file = new Savefile(filename); |
Savefile file = new Savefile(filename); |
83 |
83 |
|
|
84 |
|
file.fromFile(); |
|
|
84 |
|
file.load(); |
85 |
85 |
} |
} |
86 |
86 |
} |
} |