diff --git a/lib/src/display/windows/achievements_window.dart b/lib/src/display/windows/achievements_window.dart new file mode 100644 index 00000000..4a8320f9 --- /dev/null +++ b/lib/src/display/windows/achievements_window.dart @@ -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 achievements = decode( + JSON.encode(map.values.toList()), type: const TypeHelper>().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; + } +} \ No newline at end of file diff --git a/lib/src/display/windows/windows.dart b/lib/src/display/windows/windows.dart index 58491dd9..e66ce5c6 100644 --- a/lib/src/display/windows/windows.dart +++ b/lib/src/display/windows/windows.dart @@ -10,6 +10,7 @@ class WindowManager { RockWindow rockWindow; EmoticonPicker emoticonPicker; QuestLogWindow questLog; + AchievementsWindow achievements; WindowManager() { // Declaring all the possible popup windows @@ -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); diff --git a/lib/src/game/input.dart b/lib/src/game/input.dart index 76d36e82..0ee55af5 100644 --- a/lib/src/game/input.dart +++ b/lib/src/game/input.dart @@ -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; diff --git a/web/files/css/desktop/_desktop.css b/web/files/css/desktop/_desktop.css index 49a41580..98759d1b 100644 --- a/web/files/css/desktop/_desktop.css +++ b/web/files/css/desktop/_desktop.css @@ -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); diff --git a/web/files/css/desktop/windows/achievements_window.css b/web/files/css/desktop/windows/achievements_window.css new file mode 100644 index 00000000..3e04950a --- /dev/null +++ b/web/files/css/desktop/windows/achievements_window.css @@ -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; +} \ No newline at end of file diff --git a/web/files/html/preload.html b/web/files/html/preload.html index d2be51c6..f3541dd5 100644 --- a/web/files/html/preload.html +++ b/web/files/html/preload.html @@ -101,6 +101,7 @@ + diff --git a/web/files/html/windows/achievements.html b/web/files/html/windows/achievements.html new file mode 100644 index 00000000..d3110fb2 --- /dev/null +++ b/web/files/html/windows/achievements.html @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/web/files/html/windows/rockwindow.html b/web/files/html/windows/rockwindow.html index 89e3a102..263b84af 100644 --- a/web/files/html/windows/rockwindow.html +++ b/web/files/html/windows/rockwindow.html @@ -11,11 +11,14 @@

Magic Rock

What can I help you with?

+ diff --git a/web/files/html/windows/settingswindow.html b/web/files/html/windows/settingswindow.html index 83e11655..2a3588a3 100644 --- a/web/files/html/windows/settingswindow.html +++ b/web/files/html/windows/settingswindow.html @@ -82,6 +82,12 @@ Q +
+ Open Quest Log + Y + Y +
+
Change Focus tab diff --git a/web/index.html b/web/index.html index d142de13..a7b04fbd 100644 --- a/web/index.html +++ b/web/index.html @@ -159,6 +159,7 @@

The game page is loading...

+
diff --git a/web/main.dart b/web/main.dart index 0a0ea9e6..053ba7b5 100644 --- a/web/main.dart +++ b/web/main.dart @@ -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';