Skip to content

Commit

Permalink
differentiate system and big chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlezucc committed Jul 22, 2022
1 parent de6f824 commit c74a1cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
23 changes: 13 additions & 10 deletions web/dart/session/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void _performChat(int pcId, String msg) {

gameLog(
(mine ? '' : '<span class="dice">$name</span> ') + msg,
owner: mine ? msgMine : msgOthers,
msgType: mine ? msgMine : msgOthers,
);
}

Expand Down Expand Up @@ -156,16 +156,19 @@ void initGameLog() {
}
}

const msgGlobal = 0;
const msgMine = 1;
const msgOthers = 2;
const msgMine = 0;
const msgOthers = 1;
const msgSystem = 2;
const msgBig = 3;

SpanElement gameLog(String s, {int owner = msgGlobal, bool mild = false}) {
SpanElement gameLog(String s, {int msgType = msgSystem, bool mild = false}) {
var line = SpanElement()..innerHtml = s;

if (owner == msgGlobal) {
line.className = 'global';
} else if (owner == msgMine) {
if (msgType == msgSystem) {
line.className = 'system';
} else if (msgType == msgBig) {
line.className = 'big';
} else if (msgType == msgMine) {
line.className = 'mine';
}

Expand Down Expand Up @@ -213,7 +216,7 @@ void miniLog(String s) {
}

void demoLog(String s) {
gameLog(s, mild: true);
gameLog(s, mild: true, msgType: msgBig);
}

void logInviteLink(Session session) async {
Expand All @@ -227,7 +230,7 @@ void logInviteLink(Session session) async {
var tooltip = SpanElement()..text = 'Copied to Clipboard!';

var line = gameLog('''Hello, GM!<br>Players can join at
<b>${session.inviteLink}</b>.''', owner: msgOthers)
<b>${session.inviteLink}</b>.''', msgType: msgBig)
..classes.add('clickable');

line
Expand Down
2 changes: 1 addition & 1 deletion web/dart/session/roll_dice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void onDiceRoll(RollCombo combo, {int initiator}) {
gameLog(
'''$name rolled $comboString
and got <span>$resultString$sumString''',
owner: mine ? msgMine : msgOthers,
msgType: mine ? msgMine : msgOthers,
);
}

Expand Down
6 changes: 4 additions & 2 deletions web/sass/game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,11 @@

&.hidden { opacity: 0.6; }

&.global {
&.big {
max-width: calc(100% - 16px);
}

&.system {
align-self: center;
text-align: center;
background: none;
Expand All @@ -645,7 +648,6 @@
> .clickable {
@extend %responsive;
@extend %with-tooltip;
max-width: calc(100% - 16px);
cursor: pointer;
display: block;
user-select: none;
Expand Down

0 comments on commit c74a1cb

Please sign in to comment.