Skip to content

Commit

Permalink
Drawing block UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanik committed Dec 30, 2012
1 parent 8a5e591 commit 19cb005
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<ul>
<li>WSAD keys to move around
<li>Click and drag the mouse to change the view
<li>1-5 keys or mouse wheel to change the current block type
<li>Number keys or mouse wheel to change the current block type
<li>Left click to place a block of the current type
<li>Right click or ctrl-click to remove a block
<li>Alt-enter to toggle fullscreen mode/mouse lock
Expand Down
17 changes: 8 additions & 9 deletions src/blk/game/fps/fpsclientcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ blk.game.fps.FpsClientController.prototype.drawBlockTypes_ =
return;
}
var inventory = localPlayer.getInventory();
var selectedIndex = 0;//localPlayer.blockIndex;
var blockTypes = [];//localPlayer.blockTypes;
var actor = inventory.getTarget();
var heldTool = actor.getHeldTool();

var renderState = this.game.getRenderState();
var viewport = this.getScreenViewport();
Expand All @@ -395,19 +395,19 @@ blk.game.fps.FpsClientController.prototype.drawBlockTypes_ =
spriteBuffer.clear();

var x = 0;
var width = blockTypes.length * (16 + 1);
var width = inventory.getChildCount() * (16 + 1);
var height = 16;
var texCoords = blk.game.fps.FpsClientController.tmpVec4_;
for (var n = 0; n < blockTypes.length; n++) {
var block = blockTypes[n];
inventory.forEachChild(function(blockTool) {
var block = blockTool.getBlockType();
blockAtlas.getSlotCoords(block.atlasSlot, texCoords);
spriteBuffer.add(
texCoords[0], texCoords[1],
texCoords[2] - texCoords[0], texCoords[3] - texCoords[1],
selectedIndex == n ? 0xFFFFFFFF : 0xFF777777,
blockTool == heldTool ? 0xFFFFFFFF : 0xFF777777,
x, 0, 16, 16);
x += 16 + 1;
}
});

var worldMatrix = blk.game.fps.FpsClientController.tmpMat4_;
goog.vec.Mat4.setFromValues(worldMatrix,
Expand All @@ -434,12 +434,11 @@ blk.game.fps.FpsClientController.prototype.hitTestBlockTypes_ =
return;
}
var inventory = localPlayer.getInventory();
var blockTypes = [];//localPlayer.blockTypes;

var viewport = this.getScreenViewport();
var scale = 2;
var itemSize = (16 + 1) * scale;
var width = blockTypes.length * itemSize;
var width = inventory.getChildCount() * itemSize;
var height = 16 * scale;
if (mouseData.clientY >= viewport.height - height - 2) {
var left = viewport.width / 2 - width / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/blk/ui/screens/helpscreen.soy
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</tr>
<tr>
<td>Change block type</td>
<td>1-5, mouse wheel</td>
<td>Number keys, mouse wheel</td>
</tr>
<tr>
<td>Chat</td>
Expand Down

0 comments on commit 19cb005

Please sign in to comment.