home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve keybinding help in web client.
[plomrogue2-experiments]
/
new2
/
rogue_chat.html
diff --git
a/new2/rogue_chat.html
b/new2/rogue_chat.html
index 3d8e4c3850fa373bdb8dae0e2823cef6c50729be..37eb27a426c53bdc893d118dff6432aaa3c6a56f 100644
(file)
--- a/
new2/rogue_chat.html
+++ b/
new2/rogue_chat.html
@@
-26,13
+26,14
@@
let terminal = {
set_font: function(type='normal') {
this.ctx.font = type + ' ' + this.charHeight + 'px monospace';
},
set_font: function(type='normal') {
this.ctx.font = type + ' ' + this.charHeight + 'px monospace';
},
+ write_cheap: function(start_y, start_x, msg) {
+ this.ctx.fillText(msg, start_x*this.charWidth, start_y*this.charHeight);
+ },
+ set_color: function(color) {
+ this.ctx.fillStyle = color;
+ },
write: function(start_y, start_x, msg, foreground_color='white') {
write: function(start_y, start_x, msg, foreground_color='white') {
- if (foreground_color === 'black') {
- this.ctx.fillStyle = 'white';
- } else {
- this.ctx.fillStyle = 'black';
- }
- this.ctx.fillText(msg, start_x*this.charWidth, start_y*this.charHeight);
+ this.ctx.fillStyle = 'black';
this.ctx.fillRect(start_x*this.charWidth, start_y*this.charHeight,
this.charWidth*msg.length, this.charHeight);
this.ctx.fillStyle = foreground_color;
this.ctx.fillRect(start_x*this.charWidth, start_y*this.charHeight,
this.charWidth*msg.length, this.charHeight);
this.ctx.fillStyle = foreground_color;
@@
-99,22
+100,28
@@
let tui = {
}
},
draw_map: function() {
}
},
draw_map: function() {
- terminal.drawBox(0, 0, terminal.rows, terminal.cols / 2);
+ terminal.drawBox(0, 0, terminal.rows, terminal.cols / 2, 'black');
+ let last_c = '';
+ let color = 'white';
for (let i = 0, y = 0, x = 0; i < game.map.length; i++, x++) {
if (x >= game.map_size[1]) {
x = 0;
y += 1;
};
let c = game.map[i];
for (let i = 0, y = 0, x = 0; i < game.map.length; i++, x++) {
if (x >= game.map_size[1]) {
x = 0;
y += 1;
};
let c = game.map[i];
- let color = 'white';
- if (c == '.') {
- color = '#ffaa00';
- } else if (c == '~') {
- color = '#5555ff';
- } else if (c == 'X') {
- color = '#55ff00';
+ if (c != last_c) {
+ last_c = c;
+ color = 'white';
+ if (c == '.') {
+ color = '#ffaa00';
+ } else if (c == '~') {
+ color = '#5555ff';
+ } else if (c == 'X') {
+ color = '#55ff00';
+ }
+ terminal.set_color(color);
}
}
- terminal.write
(y, x, game.map[i], color
);
+ terminal.write
_cheap(y, x, c
);
}
for (const t in game.things) {
terminal.write(game.things[t][0], game.things[t][1], '@');
}
for (const t in game.things) {
terminal.write(game.things[t][0], game.things[t][1], '@');
@@
-140,8
+147,7
@@
let tui = {
chunk += msg[i];
}
chat.history.unshift(' '.repeat(indent) + chunk);
chunk += msg[i];
}
chat.history.unshift(' '.repeat(indent) + chunk);
- if (chat.history.length > terminal.rows - 2) {
-
+ while (chat.history.length > terminal.rows - 2) {
chat.history.pop();
};
this.draw_history();
chat.history.pop();
};
this.draw_history();