kapstok / NHL-DePa2 (public) (License: Unspecified) (since 2018-11-09) (hash sha1)
Design Patterns school project; a GUI using multiple Design Patterns.
List of commits:
Subject Hash Author Date (UTC)
Fully implement File I/O. 45cbb48489a24857cfc76144b38b12ccebfd9e61 Jan Allersma 2018-09-27 16:03:40
Fix GroupMenu bug. be41e51819be1a23e7761ea0662eb188ac641aca Jan Allersma 2018-09-27 14:55:20
Fix TODO's from previous commit. 89d8172b77336a6c18f30521147eb81287961f11 Jan Allersma 2018-09-27 14:06:30
Add groups as preparation for step 3. a91368128e7444f69b3a30ee4d17f9063c8846b8 Jan Allersma 2018-09-26 18:31:49
Fix minor bug. Small cleanup 'ellipse' code. 6c911405eb8e48ffe2d63aaff5255adbd4aec889 Jan Allersma 2018-09-21 18:10:01
Implement file I/O. 6219eca932d454a7dab5fe8679f07865ce3cf49d Jan Allersma 2018-09-21 15:52:45
Add shape 'ellipse'. 99d8b029c769bc291af73df3fd445da3cbf5bef4 Jan Allersma 2018-09-21 10:44:36
Add shape 'circle'. 092cb3c3f788b461192a6e164955c53acaf58720 Jan Allersma 2018-09-21 09:35:27
Add resize option (again). 08c95e97268cf9d74bcb963503eec512e528edfe Jan Allersma 2018-09-20 18:09:03
Fix undo bug. 6ab126be633075923cdcce53044e2468f967db41 Jan Allersma 2018-09-20 10:46:50
Implement 'delete shape' feature. 16d42472d44a9dae988c4745c90c791a8770541b Jan Allersma 2018-09-19 09:04:40
Fix undo/redo for 'MoveCmd'. be51bea021bfe5ff79e16a92d350677aed736ddd Jan Allersma 2018-09-19 08:49:55
Implement shapeOptions without undo/redo. bbe699f41e5dacbfdadfaa879452ac2f4501f5a1 Jan Allersma 2018-09-18 19:44:44
WIP: Restore 'shapeOptions.d'. 888b8ea647c0f25cfbeefcd97ee7ebb59e7f0751 Jan Allersma 2018-09-18 15:46:05
Rebuild project from scratch. df0f2f82a86581ba9fa3a169d63a950229341a9f Jan Allersma 2018-09-18 15:04:32
Add resize option. 961e464090918d83690ff66838f2fc96c6ad213a Jan Allersma 2018-09-13 18:29:44
Make `MoveCmd` Command-oriented. 2970a8d862285752551be2464422375ca958357f Jan Allersma 2018-09-12 15:33:17
Change of strategy: Make project command-oriented. ce40dffb1675661922411eeb07f148f61a176c22 Jan Allersma 2018-09-12 11:35:45
Initial commit. 38c8818349679937ae25dde38949202ec45ea7b2 Jan Allersma 2018-09-11 20:21:57
Commit 45cbb48489a24857cfc76144b38b12ccebfd9e61 - Fully implement File I/O.
Also some minor fixes, including shape having a differently calculated position.
Author: Jan Allersma
Author date (UTC): 2018-09-27 16:03
Committer name: Jan Allersma
Committer date (UTC): 2018-10-05 17:17
Parent(s): be41e51819be1a23e7761ea0662eb188ac641aca
Signing key:
Tree: ef51b83e58dffff11b57889ea38c8712c8fb9a1b
File Lines added Lines deleted
README.md 7 0
example.sav 6 10
source/entities/ellipse.d 2 2
source/entities/shape.d 0 1
source/file.d 35 25
source/frontend/menubar.d 1 0
source/groups.d 11 3
source/history.d 2 2
File README.md changed (mode: 100644) (index 9918e23..45e0812)
... ... use 'dub' to compile and run the code.
26 26 # Roadmap # Roadmap
27 27
28 28 - Delete group? Hoe? - Delete group? Hoe?
29
30 - Grafische indicatie van een groep. De groepen worden wel goed weergegeven,
31 maar subgroepen niet.
32
33 # Vragen
34
35 - Is het Visitor pattern niet al geimplementeerd met Command als Visitor?
File example.sav changed (mode: 100644) (index a56a457..6b96040)
1 rectangle 127 158 125
1 2 group 2 group 2
2 ornament top "rondje"
3 ellipse 100 100 20 50
4 group 3
5 rectangle 10 20 100 100
6 ornament top "group"
7 ornament top "ellipses"
8 group 2
9 ellipse 50 150 20 50
10 ellipse 70 150 20 50
11 rectangle 100 100 10 10
3 ellipse 395 218 50
4 group 1
5 circle 277 398 50
6 group 1
7 circle 36 464 110
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/frontend/menubar.d changed (mode: 100644) (index 2ca873f..4166939)
... ... public class FileMenu : MenuItem { // protected
57 57
58 58 private bool newCallback(Event event, Widget widget) { private bool newCallback(Event event, Widget widget) {
59 59 Global.History.clear(); Global.History.clear();
60 Global.Groups.clear();
60 61 Global.canvas.repaint(); Global.canvas.repaint();
61 62 return true; return true;
62 63 } }
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 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-DePa2

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-DePa2

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-DePa2

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main