From a1c7218f37d341c147a3dc9f5efaed956fdda766 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Sun, 6 Nov 2011 01:24:42 +0000 Subject: [PATCH] Adding play/pause button to replays. --- .../gemp-lotr-web/src/main/webapp/game.html | 6 +-- .../src/main/webapp/images/play.png | Bin 0 -> 1257 bytes .../src/main/webapp/js/gameAnimations.js | 5 -- .../src/main/webapp/js/gameUi.js | 47 +++++++++++++----- 4 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-web/src/main/webapp/images/play.png diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html index 5725f5f9e..ace13788c 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html @@ -33,7 +33,7 @@ body { text-align: center; vertical-align: middle; background-color: #7a6a53; - opacity: 0.7; + opacity: 1; font-weight: bolder; color: #ffffff; } @@ -42,7 +42,7 @@ body { text-align: center; vertical-align: middle; background-color: #8a1f0d; - opacity: 0.7; + opacity: 1; font-weight: bolder; color: #ffffff; } @@ -51,7 +51,7 @@ body { text-align: center; vertical-align: middle; background-color: #877a4e; - opacity: 0.7; + opacity: 1; font-weight: bolder; color: #ffffff; } diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/images/play.png b/gemp-lotr/gemp-lotr-web/src/main/webapp/images/play.png new file mode 100644 index 0000000000000000000000000000000000000000..614ce41d202053f6b08aad1b6b6bea329b64301d GIT binary patch literal 1257 zcmV=P)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipq< z04y_LcOp3e0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~000C) zNklp7-b6?m2+N;cz${<-lAF zm88BLCFz7DBp_FU*c1YCA&5;U!WuDjB5V=E9Em6zte9(MM@T=xsVXQIY)DQ>nIOb+ z-lA=^_- zLPSiz>15dQzZImHt~nXz=8$gxjwX;1G8S|)Y?0EcYT*i;TG+%|6Rd_*ppLJSws<}1 zf$2`D`1v;^4d$wbkTEK>SfJ;ROWG%ibs;4?<~uz8zNF=@k_4=)JC5a~mZ0&9l^6AY zyp*)2?kXwWWmVZ(6#VyZ05B@)q@;Ou?Yd}T2%IKlvWK6H0oX?Jb=`)=R%&&W#A*Pq zBn?ZNUniB&!WKyhh5R*80@zOSQ5{s$%1|A%u@t~VNf#t7$Xz8pDpD!Y4w`>GQmzvZC38JI#70saSQcD8^9$1cO@;$#ppT{ z@&}s%e3En|hwT>@l~c(2QDIU4A6@|1LGrzY6g5{&TSn?fETwJ)Fed4Qh3%I)NlMx7 z&RDYzU_5d>MgeRk`PNeV+k_g@32Onok#xq=_Ddm!gq}YVDP$%-V`}^5N$NV%WQEMc zG60Vyolm{};tKf}KQOiZa>o^70|NkVOS&Ryzz0J+*ahI5q}@)49kcD(_Fd;Q~Vbu-8 z0G5!v8Ztczali0QLYFiCwTurL3BNmUarjQj#|_`z$&kCIK7=u*w=4QRa|9Dk -1)); }; + if (this.replayMode) { + var replayDiv = $("
"); + replayDiv.append(""); + $("#main").append(replayDiv); + replayDiv.css({"z-index": 1000}); + $("#replayButton").button(); + } + this.shadowAssignGroups = {}; this.freePeopleAssignGroups = {}; this.assignGroupDivs = new Array(); @@ -602,6 +610,10 @@ var GempLotrGameUI = Class.extend({ } this.tabPane.css({ position: "absolute", left: padding, top: height - padding - chatHeight, width: specialUiWidth + advPathWidth - padding, height: chatHeight - padding}); this.chatBox.setBounds(4, 4 + 25, specialUiWidth + advPathWidth - 8, chatHeight - 8 - 25); + + if (this.replayMode) { + $(".replay").css({position: "absolute", left: width - 50 - 4 - padding, top: height - 50 - 2 - padding, width: 50, height: 50, "z-index": 1000}); + } }, startGameSession: function() { @@ -655,31 +667,40 @@ var GempLotrGameUI = Class.extend({ replayGameEvents: null, processXmlReplay: function(xml, animate) { + var that = this; log(xml); var root = xml.documentElement; if (root.tagName == 'gameReplay') { this.replayGameEvents = root.getElementsByTagName("ge"); this.replayGameEventNextIndex = 0; - if (this.shouldPlay()) - this.playNextReplayEvent(); + $("label", $(".replay")).click( + function() { + that.playNextReplayEvent(); + }); + + this.playNextReplayEvent(); } }, shouldPlay: function() { - return true; + return $("label", $(".replay")).hasClass("ui-state-active"); }, playNextReplayEvent: function() { - var that = this; - if (this.replayGameEventNextIndex < this.replayGameEvents.length) { - var gameEvent = this.replayGameEvents[this.replayGameEventNextIndex]; - this.processGameEvent(gameEvent, true); - this.replayGameEventNextIndex++; - if (this.shouldPlay()) { - // After the event is resolved if play is pressed, execute next event - // If it's not pressed, UI should wait, once it's gonna be pressed, the UI should call this method - // again + if (this.shouldPlay()) { + var that = this; + if (this.replayGameEventNextIndex < this.replayGameEvents.length) { + $("#main").queue( + function(next) { + that.cleanupDecision(); + next(); + }); + var gameEvent = this.replayGameEvents[this.replayGameEventNextIndex]; + this.processGameEvent(gameEvent, true); + + this.replayGameEventNextIndex++; + $("#main").queue( function(next) { that.playNextReplayEvent(); @@ -815,7 +836,7 @@ var GempLotrGameUI = Class.extend({ var index = this.getPlayerIndex(this.bottomPlayerId); if (index == -1) { - this.bottomPlayerId = this.allPlayerIds[0]; + this.bottomPlayerId = this.allPlayerIds[1]; this.spectatorMode = true; } else { this.spectatorMode = false;