This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added an achievements interface (default keybind = y)
- Loading branch information
1 parent
10482ce
commit add0bb8
Showing
11 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters