Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
merge into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBlackhart committed Sep 18, 2015
2 parents 87cefdb + cc522f5 commit b8d67b8
Show file tree
Hide file tree
Showing 153 changed files with 6,772 additions and 10,178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ web/*.js*
build/
*.orig
.pub/
.packages
12 changes: 8 additions & 4 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#Children of Ur Web Client#

Below is a list of any creative works that were used in the making of this product.
Below is a list of any creative works that were used in the making of this product:

<a href="http://www.glitchthegame.com/public-domain-game-art/">Glitch Game Art</a> by Tiny Speck is licensed under <a href="https://creativecommons.org/publicdomain/zero/1.0/legalcode">CC0 1.0 Universal</a>
## Graphics

<a href="http://www.orangefreesounds.com/nature-sounds-rain/">Nature Sounds Rain</a> by Alexander is licensed under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>
- [Free Emoticon Icons](https://www.iconsmind.com/Free-Emoticons-flat-icons) by Iconsmind
- [Glitch Game Art](http://www.glitchthegame.com/public-domain-game-art/) by Tiny Speck is licensed under [CC0 1.0 Universal] (https://creativecommons.org/publicdomain/zero/1.0/legalcode)

<a href="https://www.iconsmind.com/Free-Emoticons-flat-icons">Free Emoticon Icons</a> by Iconsmind
## Sounds

- [Nature Sounds Rain](http://www.orangefreesounds.com/nature-sounds-rain/) by Alexander is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- [Rooster Crow Sound](http://soundbible.com/1218-Rooster-Crow.html) by Mike Koenig on SoundBible is licensed under [Attribution 3.0](https://creativecommons.org/licenses/by/3.0/us/)
3 changes: 2 additions & 1 deletion lib/components/components_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<link rel="import" href="../../../packages/cou_login/login/login.html">
<link rel="import" href="../../../packages/couclient/components/mailbox/mailbox.html">
<link rel="import" href="../../../packages/paper_elements/paper_radio_group.html">
<link rel="import" href="../../../packages/paper_elements/paper_radio_button.html">
<link rel="import" href="../../../packages/paper_elements/paper_radio_button.html">
<link rel="import" href="../../../packages/paper_elements/paper_toggle_button.html">
23 changes: 19 additions & 4 deletions lib/components/meters/meters.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@

}

#leftDisk.guideDisk {
border: 5px goldenrod;
width: 65px;
height: 65px;

/* needed to prevent the color from reversing */
border-top-style: groove;
border-bottom-style: ridge;
border-left-style: groove;
border-right-style: ridge;
}

#portrait {
position:absolute;
top:0;
Expand Down Expand Up @@ -144,7 +156,7 @@
}
#moodMeter .percent {
position:absolute;
top:35%;
top:32%;
left:0;
text-align:center;
width:100%;
Expand All @@ -156,7 +168,7 @@
}
#moodMeter .fraction {
position:absolute;
top:60%;
top:65%;
left:0;
color:#fff;
width:100%;
Expand Down Expand Up @@ -208,9 +220,12 @@

#moodAvatar {
position: relative;
width: 80px;
width: 60px;
height: 80px;
left: -10%;
left: 50%;
top: 6px;
transform: translateX(-50%) scale(.9);
background-size: contain;
background-repeat: no-repeat;
}

Expand Down
23 changes: 2 additions & 21 deletions lib/components/meters/meters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,8 @@ class Meters extends PolymerElement {
updateAvatarDisplay() {
if (runCount < 5 || runCount % 5 == 0) {
// run on load, and once every 5 refreshes afterward to avoid overloading the server
HttpRequest.requestCrossOrigin('$serverAddress/getSpritesheets?username=' + playername).then((String response) {
Map spritesheets = JSON.decode(response);
String imageUrl = spritesheets['base'];
avatarDisplay.style.backgroundImage = 'url(' + imageUrl + ')';

ImageElement portrait = new ImageElement();
portrait.src = imageUrl;
int nWidth = portrait.naturalWidth;

// TODO: improve this sizing method
if (nWidth < 1500) {
avatarDisplay.style.backgroundSize = '1050px';
avatarDisplay.style.backgroundPositionX = '0';
} else if (nWidth >= 1500 && nWidth < 2000) {
avatarDisplay.style.backgroundSize = '1500px';
avatarDisplay.style.backgroundPositionX = '-10px';
} else if (nWidth >= 2000 && nWidth < 3000) {
avatarDisplay.style.backgroundSize = '2000px';
avatarDisplay.style.backgroundPositionX = '-25px';
avatarDisplay.style.backgroundPositionY = '-5px';
}
HttpRequest.requestCrossOrigin('$serverAddress/trimImage?username=' + playername).then((String response) {
avatarDisplay.style.backgroundImage = "url(data:image/png;base64,$response)";
});
}
}
Expand Down
8 changes: 7 additions & 1 deletion lib/components/musicplayer/musicplayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@
}

a,
a:hover,
a:active,
a:focus {
outline: none;
text-decoration: none;
}

a:hover {
opacity: 0.8;
}
</style>

<ur-panel id="widget">
<div>
<a id="SCLink" target="{{link}}">
<a id="SCLink" _href="{{link}}" target="_blank" tabindex="-1">
<span>{{song}}</span>
<br>
By
Expand Down
178 changes: 178 additions & 0 deletions lib/src/display/chatmessage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
part of couclient;

class ChatMessage {
String player, message;

ChatMessage(this.player, this.message);

String toHtml() {
if (message is! String) {
return '';
}
String html, displayName = player;

message = parseUrl(message);
message = parseEmoji(message);
message = parseItemLinks(message);

if (message.toLowerCase().contains(game.username.toLowerCase())) {
transmit('playSound', 'mention');
}

// Apply labels
String nameClass = "name ";
if (player != null) {
// You
if (player == game.username) {
nameClass += "you ";
}
// Dev/Guide
if (game.devs.contains(player)) {
nameClass += "dev ";
} else if (game.guides.contains(player)) {
nameClass += "guide ";
}
}

if (game.username == player) {
displayName = "You";
}

if (player == null) {
// System message
html = '<p class="system">$message</p>';
} else if (message.startsWith('/me')) {
// /me message
message = message.replaceFirst('/me ', '');
html =
'<p class="me" style="color:${getColorFromUsername(player)};">'
'<i><a class="noUnderline" href="http://childrenofur.com/profile?username=${player}" target="_blank" title="Open Profile Page">$player</a> $message</i>'
'</p>';
} else if (message == " joined." || message == " left.") {
// Player joined or left
if (game.username != player) {
html =
'<p class="chat-member-change-event">'
'<span class="$nameClass" style="color: ${getColorFromUsername(player)};"><a class="noUnderline" href="http://childrenofur.com/profile?username=${player}" target="_blank" title="Open Profile Page">$displayName</a> </span>'
'<span class="message">$message</span>'
'</p>';
if (player != game.username) {
if (message == " joined.") {
toast("$player has arrived");
}
if (message == " left.") {
toast("$player left");
}
}
} else {
html = "";
}
} else if (message == "LocationChangeEvent" && player == "invalid_user") {
// Switching streets message
html =
'<p class="chat-member-change-event">'
'<span class="message">${currentStreet.label}</span>'
'</p>';
} else {
// Normal message
html =
'<p>'
'<span class="$nameClass" style="color: ${getColorFromUsername(player)};"><a class="noUnderline" href="http://childrenofur.com/profile?username=${player}" target="_blank" title="Open Profile Page">$displayName</a>: </span>'
'<span class="message">$message</span>'
'</p>';
}

return html;
}
}

// chat functions

List<String> EMOTICONS;
List<String> COLORS = [
"blue",
"deepskyblue",
"fuchsia",
"gray",
"green",
"olivedrab",
"maroon",
"navy",
"olive",
"orange",
"purple",
"red",
"teal"
];
List<Chat> openConversations = [];
List<String> chatToastBuffer = [];

// global functions

String getColorFromUsername(String username) {
int index = 0;
for (int i = 0; i < username.length; i++) {
index += username.codeUnitAt(i);
}

return COLORS[index % (COLORS.length - 1)];
}

String parseEmoji(String message) {
String returnString = "";
RegExp regex = new RegExp(":(.+?):");
message.splitMapJoin(regex, onMatch: (Match m) {
String match = m[1];
if (EMOTICONS.contains(match)) {
returnString += '<i class="emoticon emoticon-sm $match" title="$match"></i>';
} else {
returnString += m[0];
}
}, onNonMatch: (String s) => returnString += s);

return returnString;
}

String parseUrl(String message) {
/*
(https?:\/\/)? : the http or https schemes (optional)
[\w-]+(\.[\w-]+)+\.? : domain name with at least two components;
allows a trailing dot
(:\d+)? : the port (optional)
(\/\S*)? : the path (optional)
*/
String regexString = r"((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)";
//the r before the string makes dart interpret it as a raw string so that you don't have to escape characters like \

String returnString = "";
RegExp regex = new RegExp(regexString);
message.splitMapJoin(regex, onMatch: (Match m) {
String url = m[0];
if (!url.contains("http")) {
url = "http://" + url;
}
returnString += '<a href="${url}" target="_blank" class="MessageLink">${m[0]}</a>';
}, onNonMatch: (String s) => returnString += s);

return returnString;
}

String parseItemLinks(String message) {
String returnString = "";
RegExp regex = new RegExp("#(.+?)#");
(message.splitMapJoin(regex, onMatch: (Match m) {
String match = m[1];
if (Item.isItem(itemType: match)) {
String name = Item.getName(match);
String iconUrl = Item.getIcon(itemType: match);
returnString += '<a class="item-chat-link" title="View Item" href="#">'
'<span class="item-chat-link-icon" '
'style="background-image: url($iconUrl);">'
'</span>$name</a>';
} else {
returnString += m[0];
}
}, onNonMatch: (String s) => returnString += s));

return returnString;
}
Loading

0 comments on commit b8d67b8

Please sign in to comment.