My first step toward fumbling my way through adding a GUI class to OversimplifiedJS.
This commit is contained in:
		
							parent
							
								
									193f643c82
								
							
						
					
					
						commit
						7012f201ab
					
				
					 1 changed files with 51 additions and 0 deletions
				
			
		|  | @ -1061,6 +1061,57 @@ Oversimplified.Animation = function (name, width, height, options) { | |||
| } | ||||
| Oversimplified.Animation.prototype.type = "Animation"; | ||||
| 
 | ||||
| Oversimplified.GUIs = {}; | ||||
| Oversimplified.GUIs.Add = function (guiName, guiOptions) { | ||||
|     if (typeof Oversimplified.GUIs[guiName] === 'undefined') { | ||||
|         Oversimplified.GUIs[guiName] = new Oversimplified.Animation(guiName, guiOptions); | ||||
|         return Oversimplified.GUIs[guiName]; | ||||
|     } else { | ||||
|         if (Oversimplified.DEBUG.showMessages) console.log("An GUI with the name \"" + guiName + "\" already exists!"); | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Oversimplified.GUI = function (name, options) { | ||||
|     this.id = OS.nextID++; | ||||
|     this.name = name; | ||||
| 
 | ||||
|     this.x = (typeof options.x !== 'undefined') ? options.x : 0; | ||||
|     this.y = (typeof options.y !== 'undefined') ? options.y : 0; | ||||
|     this.width = (typeof options.width !== 'undefined') ? options.width : 0; | ||||
|     this.height = (typeof options.height !== 'undefined') ? options.height : 0; | ||||
|     this.xScroll = (typeof options.xScroll !== 'undefined') ? options.xScroll : 0; | ||||
|     this.yScroll = (typeof options.yScroll !== 'undefined') ? options.yScroll : 0; | ||||
| 
 | ||||
|     // Borders are amount of space in pixels left of x, above y, right of width, and below height
 | ||||
|     // that an element can scroll to before becoming invisible.
 | ||||
|     this.leftBorder = (typeof options.leftBorder !== 'undefined') ? options.leftBorder : 0; | ||||
|     this.rightBorder = (typeof options.rightBorder !== 'undefined') ? options.rightBorder : 0; | ||||
|     this.topBorder = (typeof options.topBorder !== 'undefined') ? options.topBorder : 0; | ||||
|     this.bottomBorder = (typeof options.bottomBorder !== 'undefined') ? options.bottomBorder : 0; | ||||
| 
 | ||||
|     this.elements = []; | ||||
| 
 | ||||
|     this.show = (typeof options.show !== 'undefined') ? options.show : false; | ||||
| } | ||||
| 
 | ||||
| Oversimplified.GUI.prototype.AddElement = function (options) { | ||||
|     var newElement = { | ||||
|         GUI: this, | ||||
|         index: this.elements.length++, | ||||
|         x: (typeof options.x !== 'undefined') ? options.x : 0, | ||||
|         y: (typeof options.y !== 'undefined') ? options.y : 0, | ||||
|         width: (typeof options.width !== 'undefined') ? options.width : 0, | ||||
|         height: (typeof options.height !== 'undefined') ? options.height : 0 | ||||
|     }; | ||||
|     this.elements.push(newElement); | ||||
| 
 | ||||
|     return this.elements[newElement.index]; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*  Effects namespace | ||||
| */ | ||||
| Oversimplified.Effects = { | ||||
|     Sounds: [], | ||||
|     Tunes: [], | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue