OSDN Git Service

辛夷祭初日の緊急修正多数。
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / BreadItemWidgetClass.js
index f1c00c2..5b31b30 100644 (file)
-var BreadItemWidgetClass = function(manager, args)
-{
-       BreadItemWidgetClass.base.apply(this, arguments);
-       this.manager = manager;
-       
-       this.size = new Point2D(320, 32);
-       this.origin = new Point2D(5, 37);
-       
-       this.updateInterval = 10;
-       this.updateCount = 999;
-       this.wBox = null;
-       
-       this.selectedBorder = "3px orange solid";
-       
-       this.numberKeyPressed = [false, false, false, false, false, false, false, false, false, false];
-       this.selectedIndex = -1;        //Selected Bread
-       this.elementList = [];
-       
-       manager.breadItemWidget = this;
-       
-}.extend(WidgetClass, {
-       generateBreadImage: function(score){
-               if(score <= 0)
-               {
-                       return "burntbread.png";
-               }
-               if(score <=10)
-               {
-                       return "KOPPE.png";
-               }else if(score <=20)
-               {
-                       return "bread.png";
-               }else if(score <= 40)
-               {
-                       return "curypan.png";
-               }else
-               {
-                       return "crosand.png";
-               }
-       },
-       attach : function(){},
-       update: function(){
-               if(this.wBox != null)
-               {
-                       this.manager.mainArea.removeChild(this.wBox);
-               }
-               var element = document.createElement('div');
-               with(element)
-               {
-                       style.top = this.origin.y + "px";
-                       style.left = this.origin.x + "px";
-                       style.width = this.size.x + "px";
-                       style.height = this.size.y + "px";
-                       //style.overflow = "hidden";
-                       style.position = "absolute";
-                       style.zIndex = "500";
-               }
-               
-               var maxItems = 10;
-               var items = this.manager.userManager.breadList;
-               
-               var xloc = 0;
-               this.elementList = [];
-               for(var i = 0; i < maxItems && i < items.length; i++)
-               {
-                       var img = document.createElement('img');
-                       with(img)
-                       {
-                               style.position = "absolute";
-                               style.top = "0px";
-                               style.left = xloc + "px";
-                               style.width = this.size.y + "px";
-                               style.height = this.size.y + "px";
-                               src = "images/" + BreadItemWidgetClass.prototype.generateBreadImage(items[i]);
-                               //src = "images/012.png";
-                               style.borderRadius = "4px";
-                       }
-                       if(i == this.selectedIndex)
-                       {
-                               img.style.border = this.selectedBorder;
-                       }
-                       element.appendChild(img);
-                       var div = document.createElement('div');
-                       with(div)
-                       {
-                               style.position = "absolute";
-                               style.top = this.size.y + "px";
-                               style.left = xloc + "px";
-                               style.width = this.size.y + "px";
-                               style.height = this.size.y + "px";
-                               style.textAlign = "center";
-                       }
-                       var k = i + 1;
-                       if(k == 10) k = 0;
-                       div.innerText = k;
-                       element.appendChild(div);
-                       var div2 = document.createElement('div');
-                       with(div2)
-                       {
-                               style.position = "absolute";
-                               style.bottom = "0px";
-                               style.left = xloc + "px";
-                               style.width = this.size.y + "px";
-                               style.textAlign = "center";
-                       }
-                       div2.innerText = items[i] + "pt";
-                       element.appendChild(div2);
-                       
-                       xloc += this.size.y;
-                       this.elementList.push(div);
-               }
-
-               this.manager.mainArea.appendChild(element);
-               this.wBox = element;
-       },
-       detach : function()
-       {
-               if(this.wBox != null)
-               {
-                       this.manager.mainArea.removeChild(this.wBox);
-               }
-       },
-       tick : function()
-       {
-               this.updateCount++;
-               if(this.updateCount > this.updateInterval)
-               {
-                       this.update();
-                       this.updateCount = 0;
-               }
-               
-               for(var i = 0; i < 10; i++)
-               {
-                       if(this.manager.UIManager.keyState.numbers[i])
-                       {
-                               if(!this.numberKeyPressed[i])
-                               {
-                                       var k = i - 1;
-                                       if(k == -1) k = 9;
-                                       this.keyPressed(k);
-                                       this.numberKeyPressed[i] = true;
-                               }
-                       }else
-                       {
-                               this.numberKeyPressed[i] = false;
-                       }
-               }
-               
-               return true;
-       },
-       keyPressed : function(index)
-       {
-               if(index < this.elementList.length)
-               {
-                       this.selectedIndex = index;
-               }else
-               {
-                       showAlert(this.manager, "そのキーに武器は割り当てられていません");
-               }
-       },
-       getLastSelectedBreadIndex : function()
-       {
-               if(this.selectedIndex == -1) return -1;
-               var items = this.manager.userManager.breadList;
-               var score = this.manager.userManager.breadList[this.selectedIndex];
-               this.manager.userManager.breadList.splice(this.selectedIndex, 1);
-               this.selectedIndex = -1;
-               return score;
-       }
-});
-
+var BreadItemWidgetClass = function(manager, args)\r
+{\r
+       BreadItemWidgetClass.base.apply(this, arguments);\r
+       this.manager = manager;\r
+       \r
+       this.size = new Point2D(320, 32);\r
+       this.origin = new Point2D(5, 37);\r
+       \r
+       this.updateInterval = 10;\r
+       this.updateCount = 999;\r
+       this.wBox = null;\r
+       \r
+       this.selectedBorder = "3px orange solid";\r
+       \r
+       this.numberKeyPressed = [false, false, false, false, false, false, false, false, false, false];\r
+       this.selectedIndex = -1;        //Selected Bread\r
+       this.elementList = [];\r
+       \r
+       manager.breadItemWidget = this;\r
+       \r
+}.extend(WidgetClass, {\r
+       generateBreadImage: function(score){\r
+               if(score <= 0)\r
+               {\r
+                       return "burntbread.png";\r
+               }\r
+               if(score <=10)\r
+               {\r
+                       return "KOPPE.png";\r
+               }else if(score <=20)\r
+               {\r
+                       return "bread.png";\r
+               }else if(score <= 40)\r
+               {\r
+                       return "curypan.png";\r
+               }else\r
+               {\r
+                       return "crosand.png";\r
+               }\r
+       },\r
+       attach : function(){},\r
+       update: function(){\r
+               if(this.wBox != null)\r
+               {\r
+                       this.manager.mainArea.removeChild(this.wBox);\r
+               }\r
+               var element = document.createElement('div');\r
+               with(element)\r
+               {\r
+                       style.top = this.origin.y + "px";\r
+                       style.left = this.origin.x + "px";\r
+                       style.width = this.size.x + "px";\r
+                       style.height = this.size.y + "px";\r
+                       //style.overflow = "hidden";\r
+                       style.position = "absolute";\r
+                       style.zIndex = "500";\r
+               }\r
+               \r
+               var maxItems = 10;\r
+               var items = this.manager.userManager.breadList;\r
+               \r
+               var xloc = 0;\r
+               this.elementList = [];\r
+               for(var i = 0; i < maxItems && i < items.length; i++)\r
+               {\r
+                       var img = document.createElement('img');\r
+                       with(img)\r
+                       {\r
+                               style.position = "absolute";\r
+                               style.top = "0px";\r
+                               style.left = xloc + "px";\r
+                               style.width = this.size.y + "px";\r
+                               style.height = this.size.y + "px";\r
+                               src = "images/" + BreadItemWidgetClass.prototype.generateBreadImage(items[i]);\r
+                               //src = "images/012.png";\r
+                               style.borderRadius = "4px";\r
+                       }\r
+                       if(i == this.selectedIndex)\r
+                       {\r
+                               img.style.border = this.selectedBorder;\r
+                       }\r
+                       element.appendChild(img);\r
+                       var div = document.createElement('div');\r
+                       with(div)\r
+                       {\r
+                               style.position = "absolute";\r
+                               style.top = this.size.y + "px";\r
+                               style.left = xloc + "px";\r
+                               style.width = this.size.y + "px";\r
+                               style.height = this.size.y + "px";\r
+                               style.textAlign = "center";\r
+                       }\r
+                       var k = i + 1;\r
+                       if(k == 10) k = 0;\r
+                       div.innerText = k;\r
+                       element.appendChild(div);\r
+                       var div2 = document.createElement('div');\r
+                       with(div2)\r
+                       {\r
+                               style.position = "absolute";\r
+                               style.bottom = "0px";\r
+                               style.left = xloc + "px";\r
+                               style.width = this.size.y + "px";\r
+                               style.textAlign = "center";\r
+                       }\r
+                       div2.innerText = items[i] + "pt";\r
+                       element.appendChild(div2);\r
+                       \r
+                       xloc += this.size.y;\r
+                       this.elementList.push(div);\r
+               }\r
+\r
+               this.manager.mainArea.appendChild(element);\r
+               this.wBox = element;\r
+       },\r
+       detach : function()\r
+       {\r
+               if(this.wBox != null)\r
+               {\r
+                       this.manager.mainArea.removeChild(this.wBox);\r
+               }\r
+       },\r
+       tick : function()\r
+       {\r
+               this.updateCount++;\r
+               if(this.updateCount > this.updateInterval)\r
+               {\r
+                       this.update();\r
+                       this.updateCount = 0;\r
+               }\r
+               \r
+               for(var i = 0; i < 10; i++)\r
+               {\r
+                       if(this.manager.UIManager.keyState.numbers[i])\r
+                       {\r
+                               if(!this.numberKeyPressed[i])\r
+                               {\r
+                                       var k = i - 1;\r
+                                       if(k == -1) k = 9;\r
+                                       this.keyPressed(k);\r
+                                       this.numberKeyPressed[i] = true;\r
+                               }\r
+                       }else\r
+                       {\r
+                               this.numberKeyPressed[i] = false;\r
+                       }\r
+               }\r
+               \r
+               return true;\r
+       },\r
+       keyPressed : function(index)\r
+       {\r
+               if(index < this.elementList.length)\r
+               {\r
+                       this.selectedIndex = index;\r
+               }else\r
+               {\r
+                       showAlert(this.manager, "そのキーに武器は割り当てられていません");\r
+               }\r
+       },\r
+       getLastSelectedBreadIndex : function()\r
+       {\r
+               if(this.selectedIndex == -1) return -1;\r
+               var items = this.manager.userManager.breadList;\r
+               var score = this.manager.userManager.breadList[this.selectedIndex];\r
+               this.manager.userManager.breadList.splice(this.selectedIndex, 1);\r
+               this.selectedIndex = -1;\r
+               return score;\r
+       }\r
+});\r
+\r