Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Towdium committed Jul 25, 2019
1 parent dc76e78 commit c1f9a16
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 19 deletions.
49 changes: 46 additions & 3 deletions art/1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions src/main/java/me/towdium/stask/client/widgets/WHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public class WHistory extends WContainer {

public WHistory(int x, Game g) {
game = g;
width = x;
width = x - 2;
List<Cluster.Processor> ps = game.getCluster().getLayout();
for (int i = 0; i < ps.size(); i++) {
Cluster.Processor p = ps.get(i);
Rail r = new Rail(p, x, i % 2 == 0);
Rail r = new Rail(p, width, i % 2 == 0);
put(r, 0, Rail.HEIGHT * i);
processors.put(p, r);
}
bar = new WBar(x - Rail.MARGIN).setListener((w, o, n) -> {
bar = new WBar(width - Rail.MARGIN).setListener((w, o, n) -> {
int count = game.getCount();
if (count < width - Rail.MARGIN) offset = 0;
else offset = (int) ((count - width + Rail.MARGIN) * n);
Expand All @@ -67,8 +67,9 @@ public void onRefresh(Vector2i mouse) {
if (c != latest) {
latest = c;
bar.setPos(1);
bar.setRatio(latest == 0 ? 1 : Math.min((width - Rail.MARGIN) / (float) latest, 1));
processors.values().forEach(i -> i.setOffset(Math.max(0, latest - (width - Rail.MARGIN))));
bar.setRatio(latest == 0 ? 1 : Math.min((width - Rail.MARGIN) / (float) (latest / 4), 1));
offset = Math.max(0, latest / 4 - (width - Rail.MARGIN));
processors.values().forEach(i -> i.setOffset(offset));
}
super.onRefresh(mouse);
}
Expand All @@ -82,7 +83,7 @@ private void overlay(List<Graph.Work> ws, Vector2i m) {
p.overlay(s);
}

class Overlay extends WContainer {
static class Overlay extends WContainer {
static final int MARGIN = 10;
int x, y;

Expand All @@ -93,7 +94,7 @@ public Overlay(List<Graph.Work> ws) {
for (int i = 0; i < ws.size(); i++) put(new Node(ws.get(i)), MARGIN, MARGIN + i * Node.HEIGHT);
}

class Node extends WFocus.Impl {
static class Node extends WFocus.Impl {
public static final int WIDTH = 170;
public static final int HEIGHT = 28;
Graph.Work work;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
@ParametersAreNonnullByDefault
@SuppressWarnings("Duplicates")
public class WSchedule extends WContainer {
public class WSchedule extends WContainer { // TODO remove task
Game game;
Map<Processor, Rail> processors = new IdentityHashMap<>();
public static final int HEIGHT = Rail.HEIGHT * 4;
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/me/towdium/stask/logic/tutorials/TS1L1.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ public void onDraw(Painter p, Vector2i mouse) {
}

private void start() {
BUS.gate(Event.class, this, e -> e instanceof Event.EGame.Start);
BUS.subscribe(Event.EGame.Finish.class, this, e -> {
BUS.cancel(this);
finish();
});
BUS.gate(Event.class, this, e -> false);
BUS.subscribe(Event.ETutorial.class, this, e -> {
if (e.id.equals("S2S2")) {
Schedule schedule = game.getSchedule();
Expand All @@ -138,6 +134,8 @@ private void start() {
schedule.allocate(graph.getTask("B"), cluster.getProcessor("A"));
schedule.allocate(graph.getTask("C"), cluster.getProcessor("B"));
schedule.allocate(graph.getTask("D"), cluster.getProcessor("B"));
BUS.cancel(this);
finish();
}
});

Expand All @@ -146,7 +144,11 @@ private void start() {
}

private void finish() {
widget.update(S3S1, true);
widget.update(S3S2, false);
BUS.gate(Event.class, this, v -> v instanceof Event.EGame.Start);
BUS.subscribe(Event.EGame.Finish.class, this, v -> {
BUS.cancel(this);
widget.update(S3S1, true);
widget.update(S3S2, false);
});
}
}
23 changes: 23 additions & 0 deletions src/main/resources/clusters/1-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"comm": 1,
"processors": {
"A": {
"speed": 1
},
"B": {
"speed": 1,
"speedup": {
"\u03b1": 2,
"\u03b2": 3
}
}
},
"layout": [
"A",
"B"
],
"policy": {
"background": false,
"multiple": false
}
}
14 changes: 14 additions & 0 deletions src/main/resources/games/1-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"graphs": [
"1-5"
],
"cluster": "1-5",
"aims": [
4,
3
],
"times": [
0
],
"desc": "Demo."
}
3 changes: 2 additions & 1 deletion src/main/resources/general/levels.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"1-1",
"1-2",
"1-3",
"1-4"
"1-4",
"1-5"
],
"desc": "Introduction to basics of task graph scheduling and the game."
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/resources/graphs/1-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"tasks": {
"A": {
"time": 1,
"type": "\u03b1",
"after": {}
},
"B": {
"time": 1,
"type": "\u03b1",
"after": {
"A": 1
}
},
"C": {
"time": 1,
"type": "\u03b1",
"after": {
"A": 1
}
},
"D": {
"time": 1,
"type": "\u03b1",
"after": {
"A": 1
}
}
},
"layout": [
[
"A"
],
[
"B",
"C",
"D"
]
]
}

0 comments on commit c1f9a16

Please sign in to comment.