-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- state creators
- Loading branch information
Showing
28 changed files
with
2,273 additions
and
2,118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rc/net/wolfTec/states/GameRoundSetup.java → ...Src/net/wolfTec/model/GameRoundSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,104 @@ | ||
package net.wolfTec.renderer; | ||
|
||
import net.wolfTec.Constants; | ||
import org.stjs.javascript.Array; | ||
import org.stjs.javascript.Global; | ||
import org.stjs.javascript.JSCollections; | ||
import org.stjs.javascript.dom.Canvas; | ||
import org.stjs.javascript.dom.canvas.CanvasRenderingContext2D; | ||
|
||
public class LayeredCanvas { | ||
|
||
private Canvas cv; | ||
private CanvasRenderingContext2D ctx; | ||
public int w; | ||
public int h; | ||
private Array<CanvasRenderingContext2D> contexts; | ||
private Array<Canvas> layers; | ||
|
||
public LayeredCanvas (String canvasId, int frames, int w, int h) { | ||
|
||
// root canvas | ||
this.cv = (Canvas) Global.window.document.getElementById(canvasId); | ||
this.cv.width = w; | ||
this.cv.height = h; | ||
this.ctx = this.cv.getContext("2d"); | ||
this.w = w; | ||
this.h = h; | ||
|
||
// cached layers | ||
if (frames > 0) { | ||
this.contexts = JSCollections.$array(); | ||
this.layers = JSCollections.$array(); | ||
|
||
int n = 0; | ||
while (n < frames) { | ||
Canvas cv = (Canvas) Global.window.document.createElement("canvas"); | ||
|
||
cv.width = w; | ||
cv.height = h; | ||
|
||
this.contexts.$set(n, cv.getContext("2d")); | ||
this.layers.$set(n, cv); | ||
|
||
n++; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param index | ||
*/ | ||
public void renderLayer (int index) { | ||
CanvasRenderingContext2D ctx = this.getContext(Constants.INACTIVE_ID); | ||
ctx.clearRect(0, 0, this.w, this.h); | ||
ctx.drawImage(getLayer(index), 0, 0, this.w, this.h); | ||
} | ||
|
||
/** | ||
* | ||
* @param {number?} index | ||
* @returns {HTMLCanvasElement} | ||
*/ | ||
public Canvas getLayer (int index) { | ||
if (index == Constants.INACTIVE_ID) { | ||
return this.cv; | ||
} | ||
|
||
return this.layers.$get(index); | ||
} | ||
|
||
/** | ||
* | ||
* @param index | ||
*/ | ||
public void clear (int index) { | ||
this.getContext(index).clearRect(0, 0, this.w, this.h); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public void clearAll () { | ||
int n = this.layers.$length() - 1; | ||
while (n >= 0) { | ||
this.clear(n); | ||
n--; | ||
} | ||
this.clear(Constants.INACTIVE_ID); | ||
} | ||
|
||
/** | ||
* | ||
* @param {number?} index | ||
* @returns {CanvasRenderingContext2D} | ||
*/ | ||
public CanvasRenderingContext2D getContext (int index) { | ||
if (index == Constants.INACTIVE_ID) { | ||
return this.ctx; | ||
} | ||
|
||
return this.contexts.$get(index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package net.wolfTec.renderer; | ||
|
||
import org.stjs.javascript.Array; | ||
import org.stjs.javascript.JSCollections; | ||
import org.stjs.javascript.functions.Callback0; | ||
|
||
public class Pagination { | ||
|
||
public int page; | ||
public final Array<Object> list; | ||
public final Array<Object> entries; | ||
public final Callback0 updateFn; | ||
|
||
public Pagination (Array<Object> list, int pageSize, Callback0 updateFn) { | ||
this.page = 0; | ||
this.list = list; | ||
|
||
this.entries = JSCollections.$array(); | ||
while (pageSize > 0) { | ||
this.entries.push(null); | ||
pageSize--; | ||
} | ||
|
||
this.updateFn = updateFn; | ||
} | ||
|
||
/** | ||
* Selects a page from the list. The entries of the selected page will be saved in the **entries** property | ||
* of the pagination object. | ||
* | ||
* @param index | ||
*/ | ||
public void selectPage (int index) { | ||
int PAGE_SIZE = this.entries.$length(); | ||
|
||
if (index < 0 || index * PAGE_SIZE >= this.list.$length()) { | ||
return; | ||
} | ||
|
||
this.page = index; | ||
|
||
index = (index * PAGE_SIZE); | ||
for (int n = 0; n < PAGE_SIZE; n++) { | ||
this.entries.$set(n, index + n >= this.list.$length() ? null : this.list.$get(index + n)); | ||
} | ||
|
||
if (this.updateFn != null) { | ||
this.updateFn.$invoke(); | ||
} | ||
} | ||
} |
Oops, something went wrong.