diff --git a/assets/button.png b/assets/button.png index f0beb52..5f9fa44 100644 Binary files a/assets/button.png and b/assets/button.png differ diff --git a/assets/sandbox_incdec.png b/assets/sandbox_incdec.png new file mode 100644 index 0000000..cb7adce Binary files /dev/null and b/assets/sandbox_incdec.png differ diff --git a/assets/sandbox_tabs.png b/assets/sandbox_tabs.png index 69fcd36..20544fa 100644 Binary files a/assets/sandbox_tabs.png and b/assets/sandbox_tabs.png differ diff --git a/css/slides.css b/css/slides.css index 791effa..d45d1a0 100644 --- a/css/slides.css +++ b/css/slides.css @@ -129,6 +129,12 @@ body{ background: url(../assets/sandbox_tabs.png); width:500px; height:470px; background-size: auto 100%; + + -webkit-user-select: none; /* Chrome all / Safari all */ + -moz-user-select: none; /* Firefox all */ + -ms-user-select: none; /* IE 10+ */ + user-select: none; + cursor: default; } #sandbox_tabs > div{ position: absolute; @@ -144,6 +150,33 @@ body{ left: 33px; top: 80px; } +.incdec{ + width: 0; height: 0; + position: absolute; +} +.incdec > div{ + position: absolute; +} +.incdec > .incdec_num{ + width:50px; height:50px; + font-size: 25px; + text-align: center; + top: -16px; + left: -25px; + cursor: default; +} +.incdec > .incdec_control{ + left:-10px; + width:20px; height:20px; + background: url(../assets/sandbox_incdec.png); + background-size: auto 100%; + cursor: pointer; +} +.incdec > .incdec_control[arrow=up]{ top:-35px; background-position:0px 0px; } +.incdec > .incdec_control[arrow=up]:hover{ background-position:-20px 0px; } +.incdec > .incdec_control[arrow=down]{ bottom:-35px; background-position:-40px 0px; } +.incdec > .incdec_control[arrow=down]:hover{ background-position:-60px 0px; } + /*************************/ /***** SLIDE SELECT ******/ diff --git a/index.html b/index.html index 69a9fa6..4c0bc97 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@ - + @@ -31,6 +31,7 @@ + diff --git a/js/core/Button.js b/js/core/Button.js index 9624cc6..282aa14 100644 --- a/js/core/Button.js +++ b/js/core/Button.js @@ -25,9 +25,12 @@ function Button(config){ button.style.left = config.x+"px"; button.style.top = config.y+"px"; config.upperCase = (config.upperCase===undefined) ? true : config.upperCase; - var words = Words.get(config.text_id); - if(config.upperCase) words=words.toUpperCase(); - text.innerHTML = words; + self.setText = function(text_id){ + var words = Words.get(text_id); + if(config.upperCase) words=words.toUpperCase(); + text.innerHTML = words; + }; + self.setText(config.text_id); // On hover... hitbox.onmouseover = function(){ @@ -39,7 +42,10 @@ function Button(config){ // On click... hitbox.onclick = function(){ - if(self.active) publish(config.message); + if(self.active){ + if(config.onclick) config.onclick(); + if(config.message) publish(config.message); + } }; // Activate/Deactivate diff --git a/js/core/IncDecNumber.js b/js/core/IncDecNumber.js new file mode 100644 index 0000000..2d141b3 --- /dev/null +++ b/js/core/IncDecNumber.js @@ -0,0 +1,81 @@ +/***************************** + +{ + x:x, y:y, max:5, min:-5, + value: PD.PAYOFFS_DEFAULT[letter], + onchange: function(value){ + publish("pd/editPayoffs/"+letter,[value]); + } +} + +*****************************/ +function IncDecNumber(config){ + + var self = this; + self.id = config.id; + + // Properties + self.value = config.value; + + // Create DOM + var dom = document.createElement("div"); + dom.className = "incdec"; + dom.style.left = config.x+"px"; + dom.style.top = config.y+"px"; + self.dom = dom; + + // Number + var num = document.createElement("div"); + num.className = "incdec_num"; + dom.appendChild(num); + self.setValue = function(value){ + + // Bounds + if(value>config.max) value=config.max; + if(value0) self.agents[0].kill(); // Convert to an array self.agents = _convertCountToArray(AGENTS); @@ -117,11 +117,7 @@ function Tournament(config){ self.createNetwork = function(){ // Clear EVERYTHING - self.connections = []; - self.networkContainer.removeChildren(); - for(var i=0; i0) self.connections[0].kill(); // Connect all of 'em for(var i=0; i0) self.agents[_playIndex-1].dehighlightConnections(); @@ -281,6 +301,7 @@ function Tournament(config){ }else{ self.playOneTournament(); // FOR REAL, NOW. _playIndex = 0; + _tweenTimer = 0; self.STAGE = STAGE_REST; // slideshow.objects._b2.activate(); // activate NEXT button! } @@ -289,7 +310,11 @@ function Tournament(config){ // ELIMINATE! if(self.STAGE == STAGE_ELIMINATE){ self.eliminateBottom(Tournament.SELECTION); - self.STAGE = STAGE_REST; + _tweenTimer++; + if(_tweenTimer==_s(0.3)){ + _tweenTimer = 0; + self.STAGE = STAGE_REST; + } // slideshow.objects._b3.activate(); // activate NEXT button! } @@ -366,6 +391,8 @@ function Tournament(config){ function TournamentConnection(config){ var self = this; + self.config = config; + self.tournament = config.tournament; // Connect from & to self.from = config.from; @@ -419,7 +446,8 @@ function TournamentConnection(config){ self.kill = function(){ if(self.IS_DEAD) return; self.IS_DEAD = true; - if(self.graphics.parent) self.graphics.parent.removeChild(self.graphics); // remove self's graphics + self.graphics.parent.removeChild(self.graphics); // remove self's graphics + self.tournament.actuallyRemoveConnection(self); }; }; @@ -445,6 +473,9 @@ function TournamentAgent(config){ for(var i=0;i The payoffs in a one-on-one game are:

+

+reset payoffs +