OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/h58pcdgame/GameScriptCore...
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / PickedItemWidgetClass.js
1 var PickedItemWidgetClass = function(manager, args)
2 {
3         PickedItemWidgetClass.base.apply(this, arguments);
4         this.manager = manager;
5         
6         this.size = new Point2D(256, 32);
7         this.origin = new Point2D(5, 5);
8         
9         this.updateInterval = 10;
10         this.updateCount = 999;
11         
12         this.wBox = null;
13 }.extend(WidgetClass, {
14         attach : function(){},
15         update: function(){
16                 if(this.wBox != null)
17                 {
18                         this.manager.mainArea.removeChild(this.wBox);
19                 }
20                 console.log(9);
21                 var element = document.createElement('div');
22                 with(element)
23                 {
24                         style.top = this.origin.y + "px";
25                         style.left = this.origin.x + "px";
26                         style.width = this.size.x + "px";
27                         style.height = this.size.y + "px";
28                         style.overflow = "hidden";
29                         style.position = "absolute";
30                         style.zIndex = "500";
31                 }
32                 
33                 var maxItems = Math.floor(this.size.x / this.size.y);
34                 var items = this.manager.userManager.ingredientList;
35                 var showDots = false;
36                 if(maxItems < items.length)
37                 {
38                         maxItems--;
39                         showDots = true;
40                 }
41                 
42                 var xloc = 0;
43                 for(var i = 0; i < maxItems && i < items.length; i++)
44                 {
45                         var img = document.createElement('img');
46                         with(img)
47                         {
48                                 style.position = "absolute";
49                                 style.top = "0px";
50                                 style.left = xloc + "px";
51                                 style.width = this.size.y + "px";
52                                 style.height = this.size.y + "px";
53                                 src = "images/" + items[i].value;
54                         }
55                         element.appendChild(img);
56                         xloc += this.size.y;
57                 }
58                 
59                 if(showDots)
60                 {
61                         var div = document.createElement('div');
62                         with(div)
63                         {
64                                 style.position = "absolute";
65                                 style.top = "0px";
66                                 style.left = xloc + "px";
67                                 style.width = this.size.y + "px";
68                                 style.height = this.size.y + "px";
69                         }
70                         div.innerText = "...";
71                         element.appendChild(div);
72                 }
73                 this.manager.mainArea.appendChild(element);
74                 this.wBox = element;
75         },
76         detach : function()
77         {
78                 if(this.wBox != null)
79                 {
80                         this.manager.mainArea.removeChild(this.wBox);
81                 }
82         },
83         tick : function()
84         {
85                 this.updateCount++;
86                 if(this.updateCount > this.updateInterval)
87                 {
88                         this.update();
89                         this.updateCount = 0;
90                 }
91                 return true;
92         }
93 });
94