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

Commit

Permalink
added an achievements interface (default keybind = y)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBlackhart committed Feb 11, 2016
1 parent 10482ce commit add0bb8
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 2 deletions.
62 changes: 62 additions & 0 deletions lib/src/display/windows/achievements_window.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
part of couclient;

class Achievement {
String id;
String name;
String description;
String category;
String imageUrl;
String awarded = "false";
}

class AchievementsWindow extends Modal {
String id = 'achievementsWindow';
DivElement categoryList;
UListElement categories;

AchievementsWindow() {
prepare();
categoryList = querySelector('#categoryList');
categories = querySelector('#categories');

querySelectorAll("#categories li").onClick.listen((MouseEvent event) async {
categoryList.children.clear();
Element target = event.target;
String category = target.text;
String url = "http://${Configs.utilServerAddress}/listAchievements?email=${game
.email}&excludeNonMatches=false&category=$category";
Map map = JSON.decode(await HttpRequest.getString(url));
List<Achievement> achievements = decode(
JSON.encode(map.values.toList()), type: const TypeHelper<List<Achievement>>().type);

DivElement earned = new DivElement()..classes = ['earned-achvments'];
DivElement unearned = new DivElement()..classes = ['unearned-achvments'];
achievements.forEach((Achievement a) {
if(a.awarded == "true") {
earned.append(_createAchieveIcon(a));
} else {
unearned.append(_createAchieveIcon(a));
}
});

categoryList.append(new DivElement()..text="Earned"..className='title');
categoryList.append(earned);
categoryList.append(new BRElement());
categoryList.append(new DivElement()..text="Unearned"..className='title');
categoryList.append(unearned);
});

setupUiButton(querySelector('#open-achievements'));
setupKeyBinding("Achievements");
}

Element _createAchieveIcon(Achievement achievement) {
DivElement achvIcon = new DivElement()
..classes = ["achvment-icon"]
..dataset["achv-awarded"] = achievement.awarded.toString()
..style.backgroundImage = "url(${achievement.imageUrl})"
..title = achievement.description;

return achvIcon;
}
}
2 changes: 2 additions & 0 deletions lib/src/display/windows/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class WindowManager {
RockWindow rockWindow;
EmoticonPicker emoticonPicker;
QuestLogWindow questLog;
AchievementsWindow achievements;

WindowManager() {
// Declaring all the possible popup windows
Expand All @@ -23,6 +24,7 @@ class WindowManager {
rockWindow = new RockWindow();
emoticonPicker = new EmoticonPicker();
questLog = new QuestLogWindow();
achievements = new AchievementsWindow();
}

static int get randomId => random.nextInt(9999999);
Expand Down
4 changes: 3 additions & 1 deletion lib/src/game/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class InputManager {
"ImgMenuBindingPrimary": 73,
"ImgMenuBindingAlt": 73,
"QuestLogBindingPrimary": 81,
"QuestLogBindingAlt": 81
"QuestLogBindingAlt": 81,
"AchievementsBindingPrimary": 89,
"AchievementsBindingAlt": 89
};
int _ignoreCount = 0;
bool get ignoreKeys => _ignoreCount != 0;
Expand Down
1 change: 1 addition & 0 deletions web/files/css/desktop/_desktop.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@import url(windows/note_window.css);
@import url(windows/bag_window.css);
@import url(windows/questlog_window.css);
@import url(windows/achievements_window.css);

/* Overlays */
@import url(overlays/overlay.css);
Expand Down
57 changes: 57 additions & 0 deletions web/files/css/desktop/windows/achievements_window.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#achievementsWindow article {
display: flex;
font-size: medium;
border: 2px solid #cccccc;
border-radius: 10px;
background-color: #eee;
font-family: "Lato", sans-serif;
}

#achievementsWindow #categories {
display: inline-block;
padding: 0;
margin: 0 10px 0 0;
list-style-type: none;
width: 33%;
}

#achievementsWindow .title {
min-height: 1em;
margin-bottom: 5px;
}

#achievementsWindow #categoryList {
border-left: 2px solid #cccccc;
padding: 0 20px 0 20px;
flex-basis: 66%;
display: flex;
flex-direction: column;
}

#achievementsWindow .earned-achvments {
display: flex;
flex-wrap: wrap;
overflow-y: auto;
min-height: 80px;
border-bottom: 2px solid #cccccc;
}

#achievementsWindow .unearned-achvments {
display: flex;
flex-wrap: wrap;
overflow-y: auto;
}

#achievementsWindow .achvment-icon {
width: 60px;
min-height: 60px;
margin: 10px;
background-size: contain;
background-repeat: no-repeat;
display: inline-block;
cursor: help;
}

#achievementsWindow .achvment-icon[data-achv-awarded="false"] {
opacity: 0.5;
}
1 change: 1 addition & 0 deletions web/files/html/preload.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<img src="//childrenofur.com/assets/staticEntityImages/Spice Plant.png">
<img src="//childrenofur.com/assets/staticEntityImages/Tool Vendor.png">
<img src="//childrenofur.com/assets/staticEntityImages/Uncle Friendly.png">
<img src="//childrenofur.com/assets/staticEntityImages/Uncle Friendly's Emporium.png">
<img src="//childrenofur.com/assets/staticEntityImages/Wood Tree.png">

</div>
21 changes: 21 additions & 0 deletions web/files/html/windows/achievements.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="achievementsWindow" class="window" hidden>
<i class="fa-li fa fa-times close"></i>
<header>
<i class="fa-li fa fa-certificate"></i><span id="achievementsTitle">Achievements</span>
</header>
<article>
<ul id="categories">
<li>Alchemy</li>
<li>Animals</li>
<li>Cooking</li>
<li>Exploring</li>
<li>Giants</li>
<li>Harvesting</li>
<li>Industrial</li>
<li>Player</li>
<li>Trees</li>
<li>Trophies</li>
</ul>
<div id="categoryList"></div>
</article>
</div>
5 changes: 4 additions & 1 deletion web/files/html/windows/rockwindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ <h2 class="text-center">Magic Rock</h2>
<p class="text-center"><em>What can I help you with?</em></p>
<div class="flex-row">
<a class="rwc-button" id="go-motd">Alpha Notice</a>
<a class="rwc-button" id="go-start">Getting Started</a>
</div>
<div class="flex-row">
<a class="rwc-button" id="rock-rescue" hidden>Rescue Me!</a>
</div>
<div class="flex-row">
<a class="rwc-button" id="go-start">Getting Started</a>
<a class="rwc-button" id="open-quests">Quests</a>
<a class="rwc-button" id="open-achievements">Achievements</a>
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions web/files/html/windows/settingswindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
<kbd class="KeyBindingOption" id="QuestLogBindingAlt">Q</kbd>
</div>

<div class="keyboardRow">
<span>Open Quest Log</span>
<kbd class="KeyBindingOption" id="AchievementsBindingPrimary">Y</kbd>
<kbd class="KeyBindingOption" id="AchievementsBindingAlt">Y</kbd>
</div>

<div class="keyboardRow">
<span>Change Focus</span>
<kbd class="KeyBindingOption" id="ChatFocusBindingPrimary">tab</kbd>
Expand Down
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ <h1>The game page is loading...</h1>
<link rel="import" href="files/html/windows/emoticon_picker.html">
<link rel="import" href="files/html/windows/notewindow_template.html">
<link rel="import" href="files/html/windows/questlog.html">
<link rel="import" href="files/html/windows/achievements.html">
</div>

<!-- Mobile Control -->
Expand Down
2 changes: 2 additions & 0 deletions web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ part 'package:couclient/src/display/windows/note_window.dart';

part 'package:couclient/src/display/windows/questlog_window.dart';

part 'package:couclient/src/display/windows/achievements_window.dart';

// OVERLAYS //
part 'package:couclient/src/display/overlays/overlay.dart';

Expand Down

0 comments on commit add0bb8

Please sign in to comment.