From 736b7b1e690221b96088ea69a9452edde83a455e Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 14 Jun 2022 07:34:14 -0500 Subject: [PATCH] Move mexui to new GUI resource --- third-party/mexui/Core/Component/Control.js | 134 ---- third-party/mexui/Core/Component/Entry.js | 32 - third-party/mexui/Core/Component/Event.js | 6 - third-party/mexui/Core/Component/Window.js | 389 ----------- third-party/mexui/Core/Control/Button.js | 40 -- third-party/mexui/Core/Control/Character.js | 11 - third-party/mexui/Core/Control/Characters.js | 11 - third-party/mexui/Core/Control/CheckBox.js | 68 -- third-party/mexui/Core/Control/Date.js | 182 ------ third-party/mexui/Core/Control/Day.js | 16 - third-party/mexui/Core/Control/Digit.js | 11 - third-party/mexui/Core/Control/Digits.js | 11 - third-party/mexui/Core/Control/DropDown.js | 160 ----- third-party/mexui/Core/Control/Grid.js | 130 ---- third-party/mexui/Core/Control/Hour.js | 21 - third-party/mexui/Core/Control/Image.js | 39 -- third-party/mexui/Core/Control/Integer.js | 16 - third-party/mexui/Core/Control/Letter.js | 11 - third-party/mexui/Core/Control/LetterDigit.js | 11 - third-party/mexui/Core/Control/Letters.js | 11 - .../mexui/Core/Control/LettersDigits.js | 11 - third-party/mexui/Core/Control/Line.js | 23 - third-party/mexui/Core/Control/List.js | 62 -- third-party/mexui/Core/Control/Minute.js | 21 - third-party/mexui/Core/Control/Month.js | 16 - third-party/mexui/Core/Control/Number.js | 16 - third-party/mexui/Core/Control/Password.js | 7 - .../mexui/Core/Control/PositiveInteger.js | 16 - .../mexui/Core/Control/PositiveNumber.js | 16 - third-party/mexui/Core/Control/ProgressBar.js | 35 - third-party/mexui/Core/Control/RadioButton.js | 109 ---- .../mexui/Core/Control/RangedInteger.js | 24 - .../mexui/Core/Control/RangedNumber.js | 24 - third-party/mexui/Core/Control/Rectangle.js | 23 - third-party/mexui/Core/Control/ScrollBar.js | 123 ---- third-party/mexui/Core/Control/Second.js | 21 - third-party/mexui/Core/Control/Slider.js | 116 ---- third-party/mexui/Core/Control/TabPanel.js | 88 --- third-party/mexui/Core/Control/Text.js | 20 - third-party/mexui/Core/Control/TextArea.js | 7 - third-party/mexui/Core/Control/TextInput.js | 381 ----------- third-party/mexui/Core/Control/Time.js | 162 ----- third-party/mexui/Core/Control/Tree.js | 156 ----- third-party/mexui/Core/Control/Week.js | 21 - third-party/mexui/Core/Control/WeekDay.js | 16 - third-party/mexui/Core/Control/Year.js | 21 - third-party/mexui/Core/Entity/Component.js | 41 -- third-party/mexui/Core/Entity/ControlAxis.js | 200 ------ .../mexui/Core/Entity/ControlWithEntries.js | 98 --- .../mexui/Core/Entity/StyleableEntity.js | 210 ------ third-party/mexui/Core/Entity/Transition.js | 184 ------ third-party/mexui/Core/Entry/DropDownItem.js | 7 - third-party/mexui/Core/Entry/GridColumn.js | 9 - third-party/mexui/Core/Entry/GridRow.js | 13 - third-party/mexui/Core/Entry/ListRow.js | 7 - third-party/mexui/Core/Entry/Tab.js | 26 - third-party/mexui/Core/Entry/TreeRow.js | 17 - third-party/mexui/Core/Init.js | 2 - third-party/mexui/Core/Native.js | 154 ----- third-party/mexui/Core/Utility.js | 606 ------------------ third-party/mexui/Images/down-arrow.png | Bin 273 -> 0 bytes third-party/mexui/mexui.js | 257 -------- 62 files changed, 4676 deletions(-) delete mode 100644 third-party/mexui/Core/Component/Control.js delete mode 100644 third-party/mexui/Core/Component/Entry.js delete mode 100644 third-party/mexui/Core/Component/Event.js delete mode 100644 third-party/mexui/Core/Component/Window.js delete mode 100644 third-party/mexui/Core/Control/Button.js delete mode 100644 third-party/mexui/Core/Control/Character.js delete mode 100644 third-party/mexui/Core/Control/Characters.js delete mode 100644 third-party/mexui/Core/Control/CheckBox.js delete mode 100644 third-party/mexui/Core/Control/Date.js delete mode 100644 third-party/mexui/Core/Control/Day.js delete mode 100644 third-party/mexui/Core/Control/Digit.js delete mode 100644 third-party/mexui/Core/Control/Digits.js delete mode 100644 third-party/mexui/Core/Control/DropDown.js delete mode 100644 third-party/mexui/Core/Control/Grid.js delete mode 100644 third-party/mexui/Core/Control/Hour.js delete mode 100644 third-party/mexui/Core/Control/Image.js delete mode 100644 third-party/mexui/Core/Control/Integer.js delete mode 100644 third-party/mexui/Core/Control/Letter.js delete mode 100644 third-party/mexui/Core/Control/LetterDigit.js delete mode 100644 third-party/mexui/Core/Control/Letters.js delete mode 100644 third-party/mexui/Core/Control/LettersDigits.js delete mode 100644 third-party/mexui/Core/Control/Line.js delete mode 100644 third-party/mexui/Core/Control/List.js delete mode 100644 third-party/mexui/Core/Control/Minute.js delete mode 100644 third-party/mexui/Core/Control/Month.js delete mode 100644 third-party/mexui/Core/Control/Number.js delete mode 100644 third-party/mexui/Core/Control/Password.js delete mode 100644 third-party/mexui/Core/Control/PositiveInteger.js delete mode 100644 third-party/mexui/Core/Control/PositiveNumber.js delete mode 100644 third-party/mexui/Core/Control/ProgressBar.js delete mode 100644 third-party/mexui/Core/Control/RadioButton.js delete mode 100644 third-party/mexui/Core/Control/RangedInteger.js delete mode 100644 third-party/mexui/Core/Control/RangedNumber.js delete mode 100644 third-party/mexui/Core/Control/Rectangle.js delete mode 100644 third-party/mexui/Core/Control/ScrollBar.js delete mode 100644 third-party/mexui/Core/Control/Second.js delete mode 100644 third-party/mexui/Core/Control/Slider.js delete mode 100644 third-party/mexui/Core/Control/TabPanel.js delete mode 100644 third-party/mexui/Core/Control/Text.js delete mode 100644 third-party/mexui/Core/Control/TextArea.js delete mode 100644 third-party/mexui/Core/Control/TextInput.js delete mode 100644 third-party/mexui/Core/Control/Time.js delete mode 100644 third-party/mexui/Core/Control/Tree.js delete mode 100644 third-party/mexui/Core/Control/Week.js delete mode 100644 third-party/mexui/Core/Control/WeekDay.js delete mode 100644 third-party/mexui/Core/Control/Year.js delete mode 100644 third-party/mexui/Core/Entity/Component.js delete mode 100644 third-party/mexui/Core/Entity/ControlAxis.js delete mode 100644 third-party/mexui/Core/Entity/ControlWithEntries.js delete mode 100644 third-party/mexui/Core/Entity/StyleableEntity.js delete mode 100644 third-party/mexui/Core/Entity/Transition.js delete mode 100644 third-party/mexui/Core/Entry/DropDownItem.js delete mode 100644 third-party/mexui/Core/Entry/GridColumn.js delete mode 100644 third-party/mexui/Core/Entry/GridRow.js delete mode 100644 third-party/mexui/Core/Entry/ListRow.js delete mode 100644 third-party/mexui/Core/Entry/Tab.js delete mode 100644 third-party/mexui/Core/Entry/TreeRow.js delete mode 100644 third-party/mexui/Core/Init.js delete mode 100644 third-party/mexui/Core/Native.js delete mode 100644 third-party/mexui/Core/Utility.js delete mode 100644 third-party/mexui/Images/down-arrow.png delete mode 100644 third-party/mexui/mexui.js diff --git a/third-party/mexui/Core/Component/Control.js b/third-party/mexui/Core/Component/Control.js deleted file mode 100644 index c745e682..00000000 --- a/third-party/mexui/Core/Component/Control.js +++ /dev/null @@ -1,134 +0,0 @@ -mexui.Component.Control = function(window, x, y, w, h, styles, callback) -{ - mexui.Entity.Component.call(this, false); - mexui.Entity.StyleableEntity.call(this, this.linkComponentStyles('Control', styles)); - - this.window = window; - this.position = new Vec2(x, y); - this.size = new Vec2(w, h); - this.callback = callback; - - this.boundTo = null; -}; -mexui.util.extend(mexui.Component.Control, mexui.Entity.Component); - -// default styles -//mexui.Component.Control.defaultStyles = {}; -//mexui.Component.Control.defaultStyles.__proto__ = mexui.Entity.StyleableEntity.defaultStyles; - -mexui.Component.Control.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, {}); - -// input -mexui.Component.Control.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - var hit = this.isCursorOverControl(); - if(hit) - { - e.used = true; - e.clickedAControl = true; - mexui.focusedControl = this; - } - } -}; - -mexui.Component.Control.prototype.onMouseUp = function(e) -{ -}; - -mexui.Component.Control.prototype.onMouseMove = function(e, offset) -{ - if(this.isCursorOverControl()) - { - if(!this.isHovered()) - { - mexui.setHoveredComponent(this); - this.onMouseEnter(); - } - e.used = true; - } - else if(e.wasHovered) - { - mexui.clearHoveredComponent(); - this.onMouseExit(); - } -}; - -mexui.Component.Control.prototype.onMouseWheel = function(e, data) -{ -}; - -mexui.Component.Control.prototype.onKeyDown = function(e, key, mods) -{ -}; - -mexui.Component.Control.prototype.onCharacter = function(e, character) -{ -}; - -// render -mexui.Component.Control.prototype.render = function() -{ -}; - -mexui.Component.Control.prototype.renderAfter = function() -{ -}; - -// model -mexui.Component.Control.prototype.checkToCallCallback = function() -{ - if(this.callback) - this.callback.call(this); -}; - -mexui.Component.Control.prototype.getScreenPosition = function() -{ - var pos = mexui.util.addVec2(this.window.position, this.position); - if(this.boundTo) - pos = mexui.util.addVec2(pos, new Vec2(-this.boundTo.axis.x.getScrolledOffsetFixedStart(), -this.boundTo.axis.y.getScrolledOffsetFixedStart())); - return pos; -}; - -mexui.Component.Control.prototype.isCursorOverControl = function() -{ - return mexui.util.isCursorInRectangle(this.getScreenPosition(), this.getSizeForInput ? this.getSizeForInput() : this.size); -}; - -mexui.Component.Control.prototype.isCursorOverItem = function() -{ - return this.isCursorOverControl(); -}; - -mexui.Component.Control.prototype.isInsideBoundControl = function() -{ - if(this.boundTo instanceof mexui.Entity.ControlWithEntries) - return this.isInsideBoundControlEntries(); - else - return mexui.util.isRectangleInsideRectangle(this.getScreenPosition(), this.size, this.boundTo.getScreenPosition(), this.boundTo.size); -}; - -mexui.Component.Control.prototype.isInsideBoundControlEntries = function() -{ - var boundToControlPosition = mexui.util.addVec2(this.boundTo.getScreenPosition(), this.boundTo.entriesPositionOffset); - var boundToControlSize = new Vec2(this.boundTo.size.x, this.boundTo.axis.y.getDisplayedEntriesLength()); - return mexui.util.isRectangleInsideRectangle(this.getScreenPosition(), this.size, boundToControlPosition, boundToControlSize); -}; - -// api -mexui.Component.Control.prototype.remove = function() -{ - this.window.controls.splice(this.window.controls.indexOf(this), 1); -}; - -mexui.Component.Control.prototype.bindTo = function(control) -{ - this.boundTo = control; -}; - -mexui.Component.Control.prototype.unbind = function() -{ - this.boundTo = null; -}; - diff --git a/third-party/mexui/Core/Component/Entry.js b/third-party/mexui/Core/Component/Entry.js deleted file mode 100644 index c9706808..00000000 --- a/third-party/mexui/Core/Component/Entry.js +++ /dev/null @@ -1,32 +0,0 @@ -mexui.Component.Entry = function(control, axisIndex, text, styles) -{ - mexui.Entity.Component.call(this, false); - mexui.Entity.StyleableEntity.call(this, this.linkComponentStyles('Entry', styles)); - - this.control = control; - this.axisIndex = axisIndex; - this.text = text; -}; -mexui.util.extend(mexui.Component.Entry, mexui.Entity.Component); - -// default styles -mexui.Component.Entry.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, {}); - -// model -mexui.Component.Entry.prototype.getEntryIndex = function() -{ - return this.control.axis[this.getAxisKey()].entries.indexOf(this); -}; - -mexui.Component.Entry.prototype.getAxisKey = function() -{ - return this.axisIndex == 0 ? 'x' : 'y'; -}; - -// api -mexui.Component.Entry.prototype.remove = function() -{ - this.control.axis[this.getAxisKey()].entries.splice(this.getEntryIndex(), 1); - this.control.checkToShowScrollBars(); -}; - diff --git a/third-party/mexui/Core/Component/Event.js b/third-party/mexui/Core/Component/Event.js deleted file mode 100644 index 38d4630c..00000000 --- a/third-party/mexui/Core/Component/Event.js +++ /dev/null @@ -1,6 +0,0 @@ -mexui.Component.Event = function() -{ - this.used = false; - this.clickedAControl = false; -}; - diff --git a/third-party/mexui/Core/Component/Window.js b/third-party/mexui/Core/Component/Window.js deleted file mode 100644 index 9d518e27..00000000 --- a/third-party/mexui/Core/Component/Window.js +++ /dev/null @@ -1,389 +0,0 @@ -mexui.Component.Window = function(x, y, w, h, title, styles) -{ - mexui.Entity.Component.call(this, true); - mexui.Entity.StyleableEntity.call(this, this.linkComponentStyles('Window', styles)); - - this.position = new Vec2(x, y); - this.size = new Vec2(w, h); - this.title = title || ''; - - this.controls = []; - this.titleBarShown = true; - this.titleBarHeight = 30; - this.titleBarIconShown = true; - this.titleBarIconSize = new Vec2(30, 30); -}; -mexui.util.extend(mexui.Component.Window, mexui.Entity.Component); - -// default styles -mexui.Component.Window.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, { - main: - { - backgroundColour: toColour(0, 0, 0, 190), - textColour: toColour(255, 255, 255, 255), - - hover: - { - backgroundColour: toColour(0, 0, 0, 170) - } - }, - title: - { - backgroundColour: toColour(79, 161, 246, 190), - textColour: toColour(0, 0, 0, 255) - }, - icon: - { - backgroundColour: toColour(245, 5, 5, 190), - textColour: toColour(0, 0, 0, 255), - textSize: 21, - textAlign: 0.5, - textIndent: 0 - } -}); - -// input -mexui.Component.Window.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.titleBarShown && this.titleBarIconShown && this.isCursorOverCloseIcon()) - { - this.shown = false; - mexui.setInput(false); - e.used = true; - return; - } - - if(this.isCursorOverWindow()) - { - this.setTop(); - } - - this.triggerEvent('onMouseDown', e); -}; - -mexui.Component.Window.prototype.onMouseUp = function(e) -{ - this.triggerEvent('onMouseUp', e); -}; - -mexui.Component.Window.prototype.onMouseMove = function(e, offset) -{ - //var wasHovered = this.isHovered(); - //e.wasHovered = wasHovered; - - if(mexui.hoveredComponent && !mexui.hoveredComponent.isCursorOverItem()) - { - mexui.hoveredComponent.onMouseExit(); - mexui.clearHoveredComponent(); - } - - this.triggerEvent('onMouseMove', e, offset); - - if(e.used) - { - /* - if(wasHovered) - { - mexui.clearHoveredComponent(); - this.onMouseExit(); - } - */ - return; - } - - if(this.isCursorOverWindow()) - { - if(!this.isHovered()) - { - mexui.setHoveredComponent(this); - this.onMouseEnter(); - } - e.used = true; - } - /* - else if(wasHovered) - { - mexui.clearHoveredComponent(); - this.onMouseExit(); - } - */ -}; - -mexui.Component.Window.prototype.onMouseWheel = function(e, data) -{ - this.triggerEvent('onMouseWheel', e, data); -}; - -mexui.Component.Window.prototype.onKeyDown = function(e, key, mods) -{ - this.triggerEvent('onKeyDown', e, key, mods); -}; - -mexui.Component.Window.prototype.onCharacter = function(e, character) -{ - this.triggerEvent('onCharacter', e, character); -}; - -// render -mexui.Component.Window.prototype.render = function() -{ - // window background - mexui.native.drawRectangleBackground(this.position, this.size, this.getStyles('main')); - - if(this.titleBarShown) - { - // window title bar - mexui.native.drawRectangle(this.position, new Vec2(this.size.x, this.titleBarHeight), this.getStyles('title')); - mexui.native.drawText(this.position, new Vec2(this.size.x, this.titleBarHeight), this.title, this.getStyles('title')); - - if(this.titleBarIconShown) - { - // window title bar icons - var iconPos = this.getCloseIconPosition(); - mexui.native.drawRectangle(iconPos, this.titleBarIconSize, this.getStyles('icon')); - mexui.native.drawText(iconPos, this.titleBarIconSize, 'X', this.getStyles('icon')); - } - } - - // window border - mexui.native.drawRectangleBorder(this.position, this.size, this.getStyles('main')); - - // window controls - var show, control; - for(var i in this.controls) - { - control = this.controls[i]; - show = false; - - if(control.shown) - { - show = true; - if(control.boundTo) - { - if(!control.isInsideBoundControl()) - show = false; - } - } - - if(show) - control.render.call(control); - } -}; - -mexui.Component.Window.prototype.renderAfter = function() -{ - for(var i in this.controls) - { - if(this.controls[i].shown) - { - this.controls[i].renderAfter.call(this.controls[i]); - - for(var i2 in this.controls[i].scrollBars) - { - if(this.controls[i].scrollBars[i2].shown) - this.controls[i].scrollBars[i2].renderAfter(this.controls[i].scrollBars[i2]); - } - } - } -}; - -// model -mexui.Component.Window.prototype.center = function() -{ - this.position = mexui.util.getCenterPosition(mexui.util.getWindowSize(), this.size); -}; - -mexui.Component.Window.prototype.setTop = function() -{ - mexui.windows.splice(mexui.windows.indexOf(this), 1); - mexui.windows.push(this); -}; - -mexui.Component.Window.prototype.remove = function() -{ - mexui.windows.splice(mexui.windows.indexOf(this), 1); -}; - -mexui.Component.Window.prototype.isCursorOverCloseIcon = function() -{ - return mexui.util.isCursorInRectangle(this.getCloseIconPosition(), this.titleBarIconSize); -}; - -mexui.Component.Window.prototype.getCloseIconPosition = function() -{ - return new Vec2(this.position.x + (this.size.x - this.titleBarIconSize.x), this.position.y); -}; - -mexui.Component.Window.prototype.triggerEvent = function(eventName, e, data, callBaseMethodFirst) -{ - for(var i in this.controls) - { - var control = this.controls[i]; - - if(!control.shown) - continue; - - if(callBaseMethodFirst) - { - if(mexui.Entity.Component.prototype[eventName]) - { - mexui.Entity.Component.prototype[eventName].call(control, e, data); - if(e.used) - break; - } - - this.controls[i][eventName].call(control, e, data); - if(e.used) - break; - } - else - { - this.controls[i][eventName].call(control, e, data); - if(e.used) - { - if(e.button == 0 && eventName == 'onMouseDown') - { - mexui.focusedControl = this.controls[i]; - e.clickedAControl = true; - } - break; - } - - if(mexui.Entity.Component.prototype[eventName]) - { - mexui.Entity.Component.prototype[eventName].call(control, e, data); - if(e.used) - break; - } - } - } -}; - -mexui.Component.Window.prototype.addControl = function(control) -{ - this.controls.push(control); - return control; -}; - -mexui.Component.Window.prototype.setShown = function(shown) -{ - //var anyWindowShownBefore = mexui.isAnyWindowShown(); - - this.shown = shown; - - if(mexui.focusedControl && this.isControlInWindow(mexui.focusedControl)) - { - if(!shown) - { - mexui.focusedControl = null; - } - } - - /* - if(shown) - { - if(!anyWindowShownBefore) - mexui.bindEvents(); - } - else - { - if(!mexui.isAnyWindowShown()) - mexui.unbindEvents(); - } - */ -}; - -mexui.Component.Window.prototype.isShown = function() -{ - return this.shown; -}; - -mexui.Component.Window.prototype.isControlInWindow = function(control) -{ - for(var i in this.controls) - { - if(control == this.controls[i]) - return true; - } - return false; -}; - -mexui.Component.Window.prototype.isCursorOverWindow = function() -{ - return mexui.util.isCursorInRectangle(this.position, this.size); -}; - -mexui.Component.Window.prototype.isCursorOverItem = function() -{ - return this.isCursorOverWindow(); -}; - -mexui.Component.Window.prototype.getScreenPosition = function() -{ - return this.position; -}; - -mexui.Component.Window.prototype.getFirstShownControl = function() -{ - for(var i in this.controls) - { - if(this.controls[i].shown) - return this.controls[i]; - } - return null; -}; - -mexui.Component.Window.prototype.getNextShownControl = function(afterControl) -{ - var controlIndex = this.controls.indexOf(afterControl); - - if(this.controls[controlIndex + 1]) - return this.controls[controlIndex + 1]; - else - return null; -}; - -// api -mexui.Component.Window.prototype.button = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Button(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.character = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Character(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.characters = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Characters(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.checkBox = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.CheckBox(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.day = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Day(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.date = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Date(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.digit = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Digit(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.digits = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Digits(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.dropDown = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.DropDown(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.grid = function(x, y, w, h, styles) { return this.addControl(new mexui.Control.Grid(this, x, y, w, h, styles)); }; -mexui.Component.Window.prototype.hour = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Hour(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.image = function(x, y, w, h, filePath, styles, callback) { return this.addControl(new mexui.Control.Image(this, x, y, w, h, filePath, styles, callback)); }; -mexui.Component.Window.prototype.integer = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Integer(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.letter = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Letter(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.letters = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Letters(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.letterDigit = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.LetterDigit(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.lettersDigits = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.LettersDigits(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.line = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.Line(this, x, y, w, h, styles, callback)); }; -mexui.Component.Window.prototype.list = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.List(this, x, y, w, h, styles, callback)); }; -mexui.Component.Window.prototype.minute = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Minute(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.month = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Month(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.number = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Number(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.password = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Password(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.positiveInteger = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.PositiveInteger(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.positiveNumber = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.PositiveNumber(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.progressBar = function(x, y, w, h, text, styles) { return this.addControl(new mexui.Control.ProgressBar(this, x, y, w, h, text, styles)); }; -mexui.Component.Window.prototype.radioButton = function(x, y, w, h, text, groupId, styles, callback) { return this.addControl(new mexui.Control.RadioButton(this, x, y, w, h, text, groupId, styles, callback)); }; -mexui.Component.Window.prototype.rangedInteger = function(x, y, w, h, text, min, max, styles, callback) { return this.addControl(new mexui.Control.RangedInteger(this, x, y, w, h, text, min, max, styles, callback)); }; -mexui.Component.Window.prototype.rangedNumber = function(x, y, w, h, text, min, max, styles, callback) { return this.addControl(new mexui.Control.RangedNumber(this, x, y, w, h, text, min, max, styles, callback)); }; -mexui.Component.Window.prototype.rectangle = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.Rectangle(this, x, y, w, h, styles, callback)); }; -mexui.Component.Window.prototype.scrollBar = function(x, y, w, h, isVertical, styles, callback) { return this.addControl(new mexui.Control.ScrollBar(this, x, y, w, h, isVertical, styles, callback)); }; -mexui.Component.Window.prototype.second = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Second(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.slider = function(x, y, w, h, isVertical, text, minText, maxText, styles, callback) { return this.addControl(new mexui.Control.Slider(this, x, y, w, h, isVertical, text, minText, maxText, styles, callback)); }; -mexui.Component.Window.prototype.tabPanel = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.TabPanel(this, x, y, w, h, styles, callback)); }; -mexui.Component.Window.prototype.text = function(x, y, w, h, text, styles) { return this.addControl(new mexui.Control.Text(this, x, y, w, h, text, styles)); }; -mexui.Component.Window.prototype.textArea = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.TextArea(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.textInput = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.TextInput(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.time = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Time(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.tree = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.Tree(this, x, y, w, h, styles, callback)); }; -mexui.Component.Window.prototype.week = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Week(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.weekDay = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.WeekDay(this, x, y, w, h, text, styles, callback)); }; -mexui.Component.Window.prototype.year = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Year(this, x, y, w, h, text, styles, callback)); }; - diff --git a/third-party/mexui/Core/Control/Button.js b/third-party/mexui/Core/Control/Button.js deleted file mode 100644 index ef89836c..00000000 --- a/third-party/mexui/Core/Control/Button.js +++ /dev/null @@ -1,40 +0,0 @@ -mexui.util.createControlConstructor('Button', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Button', styles), callback); - - this.text = text; -}); - -// default styles -mexui.util.linkBaseControlStyles('Button', {}); - -// input -mexui.Control.Button.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverControl()) - { - e.used = true; - this.checkToCallCallback(); - } -}; - -mexui.Control.Button.prototype.onKeyDown = function(e, key, mods) -{ - if(this.isFocused() && (key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE)) - { - e.used = true; - this.checkToCallCallback(); - } -}; - -// render -mexui.Control.Button.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - mexui.native.drawText(pos, this.size, this.text, this.getStyles('main')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Character.js b/third-party/mexui/Core/Control/Character.js deleted file mode 100644 index 410298c0..00000000 --- a/third-party/mexui/Core/Control/Character.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Character', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Character', styles), callback, true, false); -}); -mexui.util.extend(mexui.Control.Character, mexui.Control.TextInput); - -// model -mexui.Control.Character.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isCharacterInOctetRange(character, 32, 126); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Characters.js b/third-party/mexui/Core/Control/Characters.js deleted file mode 100644 index f35aa1d8..00000000 --- a/third-party/mexui/Core/Control/Characters.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Characters', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Characters', styles), callback, false, true); -}); -mexui.util.extend(mexui.Control.Characters, mexui.Control.TextInput); - -// model -mexui.Control.Characters.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isCharacterInOctetRange(character, 32, 126); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/CheckBox.js b/third-party/mexui/Core/Control/CheckBox.js deleted file mode 100644 index 9404463a..00000000 --- a/third-party/mexui/Core/Control/CheckBox.js +++ /dev/null @@ -1,68 +0,0 @@ -mexui.util.createControlConstructor('CheckBox', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('CheckBox', styles), callback); - - this.text = text; - - this.checked = false; - this.textMarginLeft = 5; -}); - -// default styles -mexui.util.linkBaseControlStyles('CheckBox', { - innerBox: - { - backgroundColour: toColour(0, 255, 0, 255) - } -}); - -// input -mexui.Control.CheckBox.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverControl()) - { - e.used = true; - this.toggleChecked(); - } -}; - -mexui.Control.CheckBox.prototype.onKeyDown = function(e, key, mods) -{ - if(this.isFocused()) - { - if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE) - { - e.used = true; - this.toggleChecked(); - } - } -}; - -// render -mexui.Control.CheckBox.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - if(this.checked) - mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(1, 1)), new Vec2(this.size.x - 2, this.size.y - 2), this.getStyles('innerBox')); - - mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -// model -mexui.Control.CheckBox.prototype.getSizeForInput = function() -{ - var textWidth = mexui.native.getTextWidth(this.text, this.getStyles('main')); - return new Vec2(this.size.x + this.textMarginLeft + textWidth, this.size.y); -}; - -mexui.Control.CheckBox.prototype.toggleChecked = function() -{ - this.checked = !this.checked; - this.checkToCallCallback(); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Date.js b/third-party/mexui/Core/Control/Date.js deleted file mode 100644 index 585a045d..00000000 --- a/third-party/mexui/Core/Control/Date.js +++ /dev/null @@ -1,182 +0,0 @@ -mexui.util.createControlConstructor('Date', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Date', styles), callback, false, false); - - this.day = 1; - this.month = 1; - this.year = 2019; - - this.inputShown = false; - this.valueBoxSize = new Vec2(50, 30); - this.arrowBoxSize = new Vec2(25, 22); - - this.maxYearOffset = 10; - this.minYearCallback = ()=>{ return 1900; }; - this.maxYearCallback = ()=>{ return new Date().getFullYear() + this.maxYearOffset; } - this.twoDigitYearCapOffset = 10; -}); -mexui.util.extend(mexui.Control.Date, mexui.Control.TextInput); - -// static -mexui.Control.Date.units = ['day', 'month', 'year']; - -// default styles -mexui.util.linkBaseControlStyles('Date', { - arrow: - { - backgroundColour: toColour(90, 90, 80, 230), - textColour: toColour(0, 0, 0, 255) - } -}); - -// input -mexui.Control.Date.prototype.onMouseDown = function(e) -{ - if(this.inputShown) - { - var arrowIndex = this.getArrowIndexByCursor(); - if(arrowIndex !== false) - { - var propIndex = (Math.ceil((arrowIndex + 1) / 2)) - 1; - var propName = mexui.Control.Date.units[propIndex]; - var isIncrease = (arrowIndex % 2) == 1; - - if(isIncrease) - this[propName]++; - else - this[propName]--; - - if(this.day == 0) - this.day = 31; - else if(this.day == 32) - this.day = 1; - - if(this.month == 0) - this.month = 12; - else if(this.month == 13) - this.month = 1; - - var minYear = this.minYearCallback(); - var maxYear = this.maxYearCallback(); - if(this.year < minYear) - this.year = minYear; - else if(this.year > maxYear) - this.year = maxYear; - - this.generateText(); - - return; - } - } - - if(this.isCursorOverControl()) - { - this.inputShown = !this.inputShown; - e.used = true; - return; - } - - if(this.inputShown) - { - this.inputShown = false; - e.used = true; - return; - } -}; - -// render -mexui.Control.Date.prototype.renderAfter = function() -{ - if(!this.inputShown) - return; - - var screenPos = this.getScreenPosition(); - - var pos = new Vec2(screenPos.x, screenPos.y); - for(var i=0; i<3; i++) - { - mexui.native.drawRectangle(pos, this.valueBoxSize, this.getStyles('main')); - mexui.native.drawText(pos, this.valueBoxSize, this[mexui.Control.Date.units[i]], this.getStyles('main')); - - pos.x += this.valueBoxSize.x; - } - - pos = new Vec2(screenPos.x, screenPos.y); - pos.y += this.valueBoxSize.y; - for(var i=0; i<3; i++) - { - for(var i2=0; i2<2; i2++) - { - var text = (i2 % 2) == 0 ? '<' : '>'; - - mexui.native.drawRectangle(pos, this.arrowBoxSize, this.getStyles('main')); - mexui.native.drawText(pos, this.arrowBoxSize, text, this.getStyles('main')); - - pos.x += this.arrowBoxSize.x; - } - } -}; - -// model -mexui.Control.Date.prototype.generateText = function() -{ - this.setText((this.day < 10 ? '0'+this.day : this.day) - +'/'+(this.month < 10 ? '0'+this.month : this.month) - +'/'+(this.year < 10 ? '0'+this.year : this.year)); -}; - -mexui.Control.Date.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character) || character == '/'; -}; - -mexui.Control.Date.prototype.validateValueCallback = function(e) -{ - var parts = this.getText().split('/'); - - if(parts.length != 3) - return false; - - for(var i in parts) - { - var partAsStr = parts[i]; - if(partAsStr === '') - return false; - - if(i == 0) - { - if(!mexui.util.isDayIdWithOptionalSuffix(partAsStr)) - return false; - } - else if(i == 1) - { - if(!mexui.util.isMonthIdOrName(partAsStr)) - return false; - } - else if(i == 2) - { - if(!mexui.util.isYear(partAsStr, this.minYearCallback(), this.maxYearCallback(), this.twoDigitYearCapOffset)) - return false; - } - } - - return true; -}; - -mexui.Control.Date.prototype.getArrowIndexByCursor = function() -{ - var cursorPos = gui.cursorPosition; - - var screenPos = this.getScreenPosition(); - var firstArrowStartPos = new Vec2(screenPos.x, screenPos.y + this.valueBoxSize.y); - var lastArrowEndPos = new Vec2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y); - - if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y) - { - return Math.floor((cursorPos.x - firstArrowStartPos.x) / this.arrowBoxSize.x); - } - else - { - return false; - } -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Day.js b/third-party/mexui/Core/Control/Day.js deleted file mode 100644 index 6fd76806..00000000 --- a/third-party/mexui/Core/Control/Day.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('Day', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Day', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Day, mexui.Control.TextInput); - -// model -mexui.Control.Day.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character); -}; - -mexui.Control.Day.prototype.validateValueCallback = function(e) -{ - return mexui.util.isDayIdWithOptionalSuffix(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Digit.js b/third-party/mexui/Core/Control/Digit.js deleted file mode 100644 index f4d655cd..00000000 --- a/third-party/mexui/Core/Control/Digit.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Digit', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Digit', styles), callback, true, false); -}); -mexui.util.extend(mexui.Control.Digit, mexui.Control.TextInput); - -// model -mexui.Control.Digit.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isDigit(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Digits.js b/third-party/mexui/Core/Control/Digits.js deleted file mode 100644 index 61b9c63b..00000000 --- a/third-party/mexui/Core/Control/Digits.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Digits', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Digits', styles), callback, false, true); -}); -mexui.util.extend(mexui.Control.Digits, mexui.Control.TextInput); - -// model -mexui.Control.Digits.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isDigit(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/DropDown.js b/third-party/mexui/Core/Control/DropDown.js deleted file mode 100644 index ac394e3e..00000000 --- a/third-party/mexui/Core/Control/DropDown.js +++ /dev/null @@ -1,160 +0,0 @@ -mexui.util.createControlConstructor('DropDown', true, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('DropDown', styles), callback); - mexui.Entity.ControlWithEntries.call(this, true, true, new Vec2(0, h), new Vec2(w + 120, 25)); - - this.axis.y.entriesShown = false; - - this.text = text; - - this.arrowShown = true; - this.selectedEntryIndex = -1; - this.hoveredEntryIndex = -1; -}); - -// default styles -mexui.util.linkBaseControlStyles('DropDown', { - item: - { - backgroundColour: toColour(255, 255, 255, 255), - textColour: toColour(0, 0, 0, 255), - - hover: - { - backgroundColour: toColour(80, 80, 80, 255), - textColour: toColour(0, 0, 0, 255) - } - } -}); - -// input -mexui.Control.DropDown.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - if(this.axis.y.entries.length == 0) - return; - - var hitButton = this.isCursorOverControl(); - if(hitButton) - { - e.used = true; - this.setListShown(!this.axis.y.entriesShown); - } - else if(this.isListShown()) - { - var selectedEntryIndex = this.axis.y.getEntryIndexByCursor(); - if(selectedEntryIndex != null) - { - this.selectEntryByIndex(selectedEntryIndex); - e.used = true; - } - } - } - - if(!e.used) - mexui.Entity.ControlWithEntries.prototype.onMouseDown.call(this, e); -}; - -mexui.Control.DropDown.prototype.onKeyDown = function(e, key, mods) -{ - if(this.isFocused()) - { - if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE) - { - var selectedEntryIndex = this.axis.y.getEntryIndexByCursor(); - if(selectedEntryIndex == null) - { - this.setListShown(!this.isListShown()); - e.used = true; - } - else - { - this.selectEntryByIndex(selectedEntryIndex); - e.used = true; - } - } - } -}; - -// render -mexui.Control.DropDown.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - var text = this.selectedEntryIndex == -1 ? this.text : this.axis.y.entries[this.selectedEntryIndex].text; - mexui.native.drawText(pos, this.size, text, this.getStyles('main')); - - if(this.arrowShown) - { - var pos2 = new Vec2(pos.x + this.size.x - (25 + 3), pos.y + 0); - mexui.native.drawImage(pos2, new Vec2(25, 25), mexui.images.downArrow, this.getStyles('main')); - } - - mexui.Entity.ControlWithEntries.prototype.render.call(this); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -mexui.Control.DropDown.prototype.renderAfter = function() -{ - if(this.axis.y.entriesShown) - { - var pos = this.getScreenPosition(); - var pos2 = new Vec2(pos.x, pos.y); - - pos.x += this.entriesPositionOffset.x; - pos.y += this.entriesPositionOffset.y; - - pos2.x += this.entriesPositionOffset.x; - pos2.y += this.entriesPositionOffset.y; - - for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i maxColumnHeight) - { - maxColumnHeight = column.height; - } - } - - var startY = pos.y + maxColumnHeight; - mexui.native.drawAALine(new Vec2(pos.x, startY), new Vec2(pos.x + this.size.x, startY), this.getStyles('row')); - - for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i 23) - return false; - - return true; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Image.js b/third-party/mexui/Core/Control/Image.js deleted file mode 100644 index 6f08b71b..00000000 --- a/third-party/mexui/Core/Control/Image.js +++ /dev/null @@ -1,39 +0,0 @@ -mexui.util.createControlConstructor('Image', false, function(window, x, y, w, h, filePath, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Image', styles), callback); - - this.image = mexui.native.loadImage(filePath); -}); - -// default styles -mexui.util.linkBaseControlStyles('Image', {}); - -// input -mexui.Control.Image.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverControl()) - { - e.used = true; - this.checkToCallCallback(); - } -}; - -mexui.Control.Image.prototype.onKeyDown = function(e, key, mods) -{ - if(this.isFocused() && (key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE)) - { - e.used = true; - this.checkToCallCallback(); - } -}; - -// render -mexui.Control.Image.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawImage(pos, this.size, this.image, this.getStyles('main')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Integer.js b/third-party/mexui/Core/Control/Integer.js deleted file mode 100644 index ec00e46c..00000000 --- a/third-party/mexui/Core/Control/Integer.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('Integer', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Integer', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Integer, mexui.Control.TextInput); - -// model -mexui.Control.Integer.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isIntChar(character); -}; - -mexui.Control.Integer.prototype.validateValueCallback = function(e) -{ - return mexui.util.isInt(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Letter.js b/third-party/mexui/Core/Control/Letter.js deleted file mode 100644 index e64ad846..00000000 --- a/third-party/mexui/Core/Control/Letter.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Letter', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Letter', styles), callback, true, false); -}); -mexui.util.extend(mexui.Control.Letter, mexui.Control.TextInput); - -// model -mexui.Control.Letter.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isLetter(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/LetterDigit.js b/third-party/mexui/Core/Control/LetterDigit.js deleted file mode 100644 index a8ddd067..00000000 --- a/third-party/mexui/Core/Control/LetterDigit.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('LetterDigit', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('LetterDigit', styles), callback, true, false); -}); -mexui.util.extend(mexui.Control.LetterDigit, mexui.Control.TextInput); - -// model -mexui.Control.LetterDigit.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isLetterOrDigit(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Letters.js b/third-party/mexui/Core/Control/Letters.js deleted file mode 100644 index c812f859..00000000 --- a/third-party/mexui/Core/Control/Letters.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('Letters', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Letters', styles), callback, false, true); -}); -mexui.util.extend(mexui.Control.Letters, mexui.Control.TextInput); - -// model -mexui.Control.Letters.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isLetter(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/LettersDigits.js b/third-party/mexui/Core/Control/LettersDigits.js deleted file mode 100644 index c5584abe..00000000 --- a/third-party/mexui/Core/Control/LettersDigits.js +++ /dev/null @@ -1,11 +0,0 @@ -mexui.util.createControlConstructor('LettersDigits', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('LettersDigits', styles), callback, false, true); -}); -mexui.util.extend(mexui.Control.LettersDigits, mexui.Control.TextInput); - -// model -mexui.Control.LettersDigits.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isLetterOrDigit(character); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Line.js b/third-party/mexui/Core/Control/Line.js deleted file mode 100644 index bc66f26d..00000000 --- a/third-party/mexui/Core/Control/Line.js +++ /dev/null @@ -1,23 +0,0 @@ -mexui.util.createControlConstructor('Line', false, function(window, x, y, w, h, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Line', styles), callback); -}); - -// default styles -mexui.util.linkBaseControlStyles('Line', {}); - -// input -mexui.Control.Line.prototype.onMouseDown = function(e) -{ - if(this.isCursorOverControl()) - { - this.checkToCallCallback(); - } -}; - -// render -mexui.Control.Line.prototype.render = function() -{ - var pos = this.getScreenPosition(); - mexui.native.drawAALine(pos, this.size, this.getStyles('main')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/List.js b/third-party/mexui/Core/Control/List.js deleted file mode 100644 index 4c6b82a6..00000000 --- a/third-party/mexui/Core/Control/List.js +++ /dev/null @@ -1,62 +0,0 @@ -mexui.util.createControlConstructor('List', true, function(window, x, y, w, h, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('List', styles), callback); - mexui.Entity.ControlWithEntries.call(this, false, false); - - this.activeRow = null; - this.rowHeight = 25; -}); - -// default styles -mexui.util.linkBaseControlStyles('List', { - row: - { - backgroundColour: toColour(255, 255, 255, 255), - textColour: toColour(0, 0, 0, 255) - }, - rowLine: - { - lineColour: toColour(0, 0, 0, 150) - } -}); - -// input -mexui.Control.List.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverControl()) - { - this.activeRow = this.axis.y.getEntryByCursor(); - this.checkToCallCallback(); - } -}; - -// render -mexui.Control.List.prototype.render = function() -{ - var pos = this.getScreenPosition(); - var pos2 = new Vec2(pos.x, pos.y); - - for(var i in this.axis.y.entries) - { - var row = this.axis.y.entries[i]; - var rowText = row.text; - - mexui.native.drawRectangle(pos, new Vec2(this.size.x, this.rowHeight), this.getStyles('row')); - mexui.native.drawText(pos, new Vec2(this.size.x, this.rowHeight), rowText, this.getStyles('row')); - - pos.y += this.rowHeight; - mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine')); - } - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -// model -mexui.Control.List.prototype.row = function(text) -{ - var entry = new mexui.Entry.ListRow(this, text); - this.axis.y.addEntry(entry); - return entry; -}; - diff --git a/third-party/mexui/Core/Control/Minute.js b/third-party/mexui/Core/Control/Minute.js deleted file mode 100644 index 432f5227..00000000 --- a/third-party/mexui/Core/Control/Minute.js +++ /dev/null @@ -1,21 +0,0 @@ -mexui.util.createControlConstructor('Minute', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Minute', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Minute, mexui.Control.TextInput); - -// model -mexui.Control.Minute.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character); -}; - -mexui.Control.Minute.prototype.validateValueCallback = function(e) -{ - var _int = parseInt(this.getText()); - - if(_int < 1 || _int > 59) - return false; - - return true; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Month.js b/third-party/mexui/Core/Control/Month.js deleted file mode 100644 index c23a1da4..00000000 --- a/third-party/mexui/Core/Control/Month.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('Month', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Month', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Month, mexui.Control.TextInput); - -// model -mexui.Control.Month.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character); -}; - -mexui.Control.Month.prototype.validateValueCallback = function(e) -{ - return mexui.util.isMonthIdOrName(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Number.js b/third-party/mexui/Core/Control/Number.js deleted file mode 100644 index f7e4ed28..00000000 --- a/third-party/mexui/Core/Control/Number.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('Number', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Number', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Number, mexui.Control.TextInput); - -// model -mexui.Control.Number.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isFloatChar(character); -}; - -mexui.Control.Number.prototype.validateValueCallback = function(e) -{ - return mexui.util.isFloat(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Password.js b/third-party/mexui/Core/Control/Password.js deleted file mode 100644 index 0aaa3019..00000000 --- a/third-party/mexui/Core/Control/Password.js +++ /dev/null @@ -1,7 +0,0 @@ -mexui.util.createControlConstructor('Password', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Password', styles), callback, false, true); - - this.masked = true; -}); -mexui.util.extend(mexui.Control.Password, mexui.Control.TextInput); \ No newline at end of file diff --git a/third-party/mexui/Core/Control/PositiveInteger.js b/third-party/mexui/Core/Control/PositiveInteger.js deleted file mode 100644 index 6cb46e86..00000000 --- a/third-party/mexui/Core/Control/PositiveInteger.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('PositiveInteger', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('PositiveInteger', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.PositiveInteger, mexui.Control.TextInput); - -// model -mexui.Control.PositiveInteger.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character); -}; - -mexui.Control.PositiveInteger.prototype.validateValueCallback = function(e) -{ - return mexui.util.isPositiveInt(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/PositiveNumber.js b/third-party/mexui/Core/Control/PositiveNumber.js deleted file mode 100644 index 626d25ad..00000000 --- a/third-party/mexui/Core/Control/PositiveNumber.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('PositiveNumber', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('PositiveNumber', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.PositiveNumber, mexui.Control.TextInput); - -// model -mexui.Control.PositiveNumber.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveFloatChar(character); -}; - -mexui.Control.PositiveNumber.prototype.validateValueCallback = function(e) -{ - return mexui.util.isPositiveFloat(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/ProgressBar.js b/third-party/mexui/Core/Control/ProgressBar.js deleted file mode 100644 index a0321d5e..00000000 --- a/third-party/mexui/Core/Control/ProgressBar.js +++ /dev/null @@ -1,35 +0,0 @@ -mexui.util.createControlConstructor('ProgressBar', false, function(window, x, y, w, h, text, styles) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('ProgressBar', styles)); - - this.text = text; - - this.progress = 0.0; -}); - -// default styles -mexui.util.linkBaseControlStyles('ProgressBar', { - innerBar: - { - backgroundColour: toColour(0, 255, 0, 255), - - hover: - { - backgroundColour: toColour(80, 255, 0, 255) - } - } -}); - -// render -mexui.Control.ProgressBar.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - var innerBarSize = new Vec2(this.size.x * this.progress, this.size.y); - mexui.native.drawRectangle(pos, innerBarSize, this.getStyles('innerBar')); - - if(this.text != '') - mexui.native.drawText(pos, this.size, this.text, this.getStyles('main')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/RadioButton.js b/third-party/mexui/Core/Control/RadioButton.js deleted file mode 100644 index 87d686c8..00000000 --- a/third-party/mexui/Core/Control/RadioButton.js +++ /dev/null @@ -1,109 +0,0 @@ -mexui.util.createControlConstructor('RadioButton', false, function(window, x, y, w, h, groupId, text, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('RadioButton', styles), callback); - - this.groupId = groupId; - this.text = text; - - this.checked = this.isFirstRadioInGroup(); - this.textMarginLeft = 5; -}); - -// default styles -mexui.util.linkBaseControlStyles('RadioButton', { - innerBox: - { - backgroundColour: toColour(0, 255, 0, 255) - } -}); - -// input -mexui.Control.RadioButton.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverControl()) - { - this.setChecked(); - } -}; - -mexui.Control.RadioButton.prototype.onKeyDown = function(e, key, mods) -{ - if(this.isFocused()) - { - if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE) - { - e.used = true; - this.setChecked(); - } - } -}; - -// render -mexui.Control.RadioButton.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - if(this.checked) - mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(2, 2)), new Vec2(this.size.x - 4, this.size.y - 4), this.getStyles('innerBox')); - - mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -// model -mexui.Control.RadioButton.prototype.getSizeForInput = function() -{ - var textWidth = mexui.native.getTextWidth(this.text, this.getStyles('main')); - return new Vec2(this.size.x + this.textMarginLeft + textWidth, this.size.y); -}; - -mexui.Control.RadioButton.prototype.getGroupRadios = function() -{ - var radios = []; - var windows = mexui.windows; - for(var i in windows) - { - var window = mexui.windows[i]; - - for(var i2 in window.controls) - { - var control = window.controls[i2]; - - if((control instanceof mexui.Control.RadioButton) && this.groupId == control.groupId) - { - radios.push(control); - } - } - } - return radios; -}; - -mexui.Control.RadioButton.prototype.getCheckedRadio = function() -{ - var radios = this.getGroupRadios(); - for(var i in radios) - { - if(radios[i].checked) - return radios[i]; - } - return null; -}; - -mexui.Control.RadioButton.prototype.isFirstRadioInGroup = function() -{ - return this.getGroupRadios().length == 0; -}; - -mexui.Control.RadioButton.prototype.setChecked = function() -{ - var checkedRadio = this.getCheckedRadio(); - if(checkedRadio != this.checked) - checkedRadio.checked = false; - - this.checked = !this.checked; - this.checkToCallCallback(); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/RangedInteger.js b/third-party/mexui/Core/Control/RangedInteger.js deleted file mode 100644 index dafa0946..00000000 --- a/third-party/mexui/Core/Control/RangedInteger.js +++ /dev/null @@ -1,24 +0,0 @@ -mexui.util.createControlConstructor('RangedInteger', false, function(window, x, y, w, h, min, max, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('RangedInteger', styles), callback, false, false); - - this.min = min === undefined ? 0 : min; - this.max = max === undefined ? 100 : max; -}); -mexui.util.extend(mexui.Control.RangedInteger, mexui.Control.TextInput); - -// model -mexui.Control.RangedInteger.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isIntChar(character); -}; - -mexui.Control.RangedInteger.prototype.validateValueCallback = function(e) -{ - var text = this.getText(); - if(!mexui.util.isInt(text)) - return false; - - var _int = parseInt(text); - return _int >= this.min && _int <= this.max; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/RangedNumber.js b/third-party/mexui/Core/Control/RangedNumber.js deleted file mode 100644 index 45e16b05..00000000 --- a/third-party/mexui/Core/Control/RangedNumber.js +++ /dev/null @@ -1,24 +0,0 @@ -mexui.util.createControlConstructor('RangedNumber', false, function(window, x, y, w, h, min, max, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('RangedNumber', styles), callback, false, false); - - this.min = min === undefined ? 0.0 : min; - this.max = max === undefined ? 100.0 : max; -}); -mexui.util.extend(mexui.Control.RangedNumber, mexui.Control.TextInput); - -// model -mexui.Control.RangedNumber.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isFloatChar(character); -}; - -mexui.Control.RangedNumber.prototype.validateValueCallback = function(e) -{ - var text = this.getText(); - if(!mexui.util.isFloat(text)) - return false; - - var number = parseFloat(text); - return number >= this.min && number <= this.max; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Rectangle.js b/third-party/mexui/Core/Control/Rectangle.js deleted file mode 100644 index 618a4da2..00000000 --- a/third-party/mexui/Core/Control/Rectangle.js +++ /dev/null @@ -1,23 +0,0 @@ -mexui.util.createControlConstructor('Rectangle', false, function(window, x, y, w, h, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Rectangle', styles), callback); -}); - -// default styles -mexui.util.linkBaseControlStyles('Rectangle', {}); - -// input -mexui.Control.Rectangle.prototype.onMouseDown = function(e) -{ - if(this.isCursorOverControl()) - { - this.checkToCallCallback(); - } -}; - -// render -mexui.Control.Rectangle.prototype.render = function() -{ - var pos = this.getScreenPosition(); - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/ScrollBar.js b/third-party/mexui/Core/Control/ScrollBar.js deleted file mode 100644 index 579fb037..00000000 --- a/third-party/mexui/Core/Control/ScrollBar.js +++ /dev/null @@ -1,123 +0,0 @@ -mexui.util.createControlConstructor('ScrollBar', false, function(window, x, y, w, h, isVertical, styles, callback) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('ScrollBar', styles), callback); - - this.isVertical = isVertical; - this.axisIndex = isVertical ? 1 : 0; - this.otherAxisIndex = isVertical ? 0 : 1; - - this.barHigherLength = 50; - this.scrolledRatio = 0.0; - this.isScrolling = false; -}); - -// default styles -mexui.util.linkBaseControlStyles('ScrollBar', { - main: - { - backgroundColour: toColour(0, 0, 0, 190), - - hover: - { - backgroundColour: toColour(0, 0, 0, 150) - } - }, - innerBar: - { - backgroundColour: toColour(79, 161, 246, 190), - - hover: - { - backgroundColour: toColour(79, 161, 246, 150) - } - } -}); - -// input -mexui.Control.ScrollBar.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - if(mexui.util.isCursorInRectangle(this.getInnerBarPosition(), this.getInnerBarSize())) - { - e.used = true; - this.isScrolling = true; - } - else if(this.isCursorOverControl()) - { - e.used = true; - this.scrolledRatio += this.getScrolledRatioOuterBarClickIncrease(); - this.clampScrolledRatio(); - } - } -}; - -mexui.Control.ScrollBar.prototype.onMouseUp = function(e) -{ - if(e.button == 0 && this.isScrolling) - { - this.isScrolling = false; - e.used = true; - } -}; - -mexui.Control.ScrollBar.prototype.onMouseMove = function(e, offset) -{ - if(this.isScrolling) - { - this.scrolledRatio += offset.y * 0.002; - this.clampScrolledRatio(); - e.used = true; - } - - if(!e.used) - mexui.Component.Control.prototype.onMouseMove.call(this, e, offset); -}; - -mexui.Control.ScrollBar.prototype.onMouseWheel = function(e, offset) -{ - this.scrolledRatio -= offset.y * 0.12; - this.clampScrolledRatio(); -}; - -// render -mexui.Control.ScrollBar.prototype.renderAfter = function() -{ - mexui.native.drawRectangle(this.getScreenPosition(), this.size, this.getStyles('main')); - mexui.native.drawRectangle(this.getInnerBarPosition(), this.getInnerBarSize(), this.getStyles('innerBar')); -}; - -// model -mexui.Control.ScrollBar.prototype.clampScrolledRatio = function() -{ - if(this.scrolledRatio < 0.0) - this.scrolledRatio = 0.0; - else if(this.scrolledRatio > 1.0) - this.scrolledRatio = 1.0; -}; - -mexui.Control.ScrollBar.prototype.getInnerBarPosition = function() -{ - var screenPos = this.getScreenPosition(); - var pos = new Vec2(screenPos.x, screenPos.y); - - var minPos = pos[this.axisIndex] + 1; - var maxPos = pos[this.axisIndex] + this.size[this.axisIndex] - 2; - pos[this.axisIndex] = minPos + (this.scrolledRatio * (maxPos - minPos - this.barHigherLength)); - pos[this.otherAxisIndex] += 1; - return pos; -}; - -mexui.Control.ScrollBar.prototype.getInnerBarSize = function() -{ - var size = new Vec2(this.size.x, this.size.y); - size[this.axisIndex] = this.barHigherLength; - size[this.otherAxisIndex] -= 2; - return size; -}; - -mexui.Control.ScrollBar.prototype.getScrolledRatioOuterBarClickIncrease = function() -{ - var direction = gui.cursorPosition.y < this.getInnerBarPosition().y ? -1.0 : 1.0; - return direction * 0.05; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Second.js b/third-party/mexui/Core/Control/Second.js deleted file mode 100644 index 650e8125..00000000 --- a/third-party/mexui/Core/Control/Second.js +++ /dev/null @@ -1,21 +0,0 @@ -mexui.util.createControlConstructor('Second', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Second', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Second, mexui.Control.TextInput); - -// model -mexui.Control.Second.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character); -}; - -mexui.Control.Second.prototype.validateValueCallback = function(e) -{ - var _int = parseInt(this.getText()); - - if(_int < 1 || _int > 59) - return false; - - return true; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Slider.js b/third-party/mexui/Core/Control/Slider.js deleted file mode 100644 index 1abfebc6..00000000 --- a/third-party/mexui/Core/Control/Slider.js +++ /dev/null @@ -1,116 +0,0 @@ -mexui.util.createControlConstructor('Slider', false, function(window, x, y, w, h, isVertical, text, minText, maxText, styles, callback) -{ - isVertical = isVertical === undefined ? false : isVertical; - text = text === undefined ? '' : text; - minText = minText === undefined ? '' : minText; - maxText = maxText === undefined ? '' : maxText; - - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Slider', styles), callback); - - this.isVertical = isVertical; - this.text = text; - this.minText = minText; - this.maxText = maxText; - - this.progress = 0.0; - this.axisIndex = isVertical ? 1 : 0; - this.innerBarSize = new Vec2(30, 25); -}); - -// default styles -mexui.util.linkBaseControlStyles('Slider', { - innerBar: - { - backgroundColour: toColour(0, 255, 0, 255) - }, - minText: - { - textColour: toColour(0, 0, 0, 255) - }, - maxText: - { - textColour: toColour(0, 0, 0, 255) - } -}); - -// input -mexui.Control.Slider.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.isCursorOverInnerBar()) - { - this.sliding = true; - e.used = true; - } -}; - -mexui.Control.Slider.prototype.onMouseUp = function(e) -{ - if(e.button == 0 && this.sliding) - { - this.sliding = false; - this.checkToCallCallback(); - e.used = true; - } -}; - -mexui.Control.Slider.prototype.onMouseMove = function(e, offset) -{ - if(!this.sliding) - return false; - - this.progress += this.getProgressIncreaseByPixels(offset); - this.clampProgress(); - e.used = true; -}; - -// render -mexui.Control.Slider.prototype.render = function() -{ - var pos = this.getScreenPosition(); - var pos2 = new Vec2(pos.x, pos.y); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - mexui.native.drawRectangle(this.getInnerBarPosition(), this.innerBarSize, this.getStyles('innerBar')); - - pos.y += this.size.y; - mexui.native.drawText(pos, this.size, this.minText, this.getStyles('minText')); - - var offset = (this.size.x - mexui.native.getTextWidth(this.text, this.getStyles('main'))) / 2; - pos.x += offset; - mexui.native.drawText(pos, this.size, this.text, this.getStyles('main')); - pos.x -= offset; - - pos.x += this.size.x - mexui.native.getTextWidth(this.maxText, this.getStyles('maxText')); - mexui.native.drawText(pos, this.size, this.maxText, this.getStyles('maxText')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -// model -mexui.Control.Slider.prototype.isCursorOverInnerBar = function() -{ - return mexui.util.isCursorInRectangle(this.getInnerBarPosition(), this.innerBarSize); -}; - -mexui.Control.Slider.prototype.getInnerBarPosition = function() -{ - var pos = this.getScreenPosition(); - pos[this.axisIndex] = mexui.util.interpolateScalar(pos.x, (pos.x + this.size.x) - this.innerBarSize.x, this.progress); - pos.y -= 3; - return new Vec2(pos.x, pos.y); -}; - -mexui.Control.Slider.prototype.getProgressIncreaseByPixels = function(offset) -{ - return offset.x / this.size.x; -}; - -mexui.Control.Slider.prototype.clampProgress = function() -{ - if(this.progress < 0.0) - this.progress = 0.0; - else if(this.progress > 1.0) - this.progress = 1.0; -}; - diff --git a/third-party/mexui/Core/Control/TabPanel.js b/third-party/mexui/Core/Control/TabPanel.js deleted file mode 100644 index aa83369c..00000000 --- a/third-party/mexui/Core/Control/TabPanel.js +++ /dev/null @@ -1,88 +0,0 @@ -mexui.util.createControlConstructor('TabPanel', true, function(window, x, y, w, h, styles) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('TabPanel', styles)); - mexui.Entity.ControlWithEntries.call(this, false, false); - - this.activeTabIndex = 0; -}); - -// default styles -mexui.util.linkBaseControlStyles('TabPanel', { - tab: - { - backgroundColour: toColour(240, 20, 20, 200), - borderColour: toColour(120, 20, 20, 225), - textColour: toColour(0, 0, 0, 255), - - hover: - { - backgroundColour: toColour(240, 20, 20, 150), - borderColour: toColour(120, 20, 20, 120), - textColour: toColour(0, 0, 0, 255) - } - } -}); - -// input -mexui.Control.TabPanel.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - var pos = this.getScreenPosition(); - - var tabX = pos.x; - for(var i in this.axis.x.entries) - { - var tab = this.axis.x.entries[i]; - - var tabPos = new Vec2(tabX, pos.y); - var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25); - - if(mexui.util.isCursorInRectangle(tabPos, tabSize)) - { - tab.setActive(); - break; - } - - tabX += tabSize.x; - } - - /* - var tab = this.axis.x.getEntryByCursor(); - if(tab) - tab.setActive(); - */ - } -}; - -// render -mexui.Control.TabPanel.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - var tabX = pos.x; - for(var i in this.axis.x.entries) - { - var tab = this.axis.x.entries[i]; - - var tabPos = new Vec2(tabX, pos.y); - var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25); - mexui.native.drawRectangle(tabPos, tabSize, this.getStyles('tab')); - mexui.native.drawText(tabPos, tabSize, tab.text, this.getStyles('tab')); - - tabX += tabSize.x; - } - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -// model -mexui.Control.TabPanel.prototype.tab = function(text) -{ - var entry = new mexui.Entry.Tab(this, text); - this.axis.x.addEntry(entry); - return entry; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Text.js b/third-party/mexui/Core/Control/Text.js deleted file mode 100644 index 92532fc6..00000000 --- a/third-party/mexui/Core/Control/Text.js +++ /dev/null @@ -1,20 +0,0 @@ -mexui.util.createControlConstructor('Text', false, function(window, x, y, w, h, text, styles) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Text', styles)); - - this.text = text; -}); - -// default styles -mexui.util.linkBaseControlStyles('Text', {}); - -// render -mexui.Control.Text.prototype.render = function() -{ - var pos = this.getScreenPosition(); - - mexui.native.drawText(pos, this.size, this.text, this.getStyles('main')); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/TextArea.js b/third-party/mexui/Core/Control/TextArea.js deleted file mode 100644 index 0d3d1b0a..00000000 --- a/third-party/mexui/Core/Control/TextArea.js +++ /dev/null @@ -1,7 +0,0 @@ -mexui.util.createControlConstructor('TextArea', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('TextArea', styles), callback, false, true); - - this.multiLine = true; -}); -mexui.util.extend(mexui.Control.TextArea, mexui.Control.TextInput); \ No newline at end of file diff --git a/third-party/mexui/Core/Control/TextInput.js b/third-party/mexui/Core/Control/TextInput.js deleted file mode 100644 index ea1e445b..00000000 --- a/third-party/mexui/Core/Control/TextInput.js +++ /dev/null @@ -1,381 +0,0 @@ -mexui.util.createControlConstructor('TextInput', false, function(window, x, y, w, h, text, styles, callback, singleCharacter, multiLineSupported) -{ - text = text || ''; - if(singleCharacter) - multiLineSupported = false; - - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('TextInput', styles), callback); - - this.lines = text ? mexui.util.splitLines(text) : ['']; - - this.caretPosition = new Vec2(0, 0); - this.multiLineSupported = multiLineSupported === undefined ? true : multiLineSupported; - this.multiLine = this.multiLineSupported ? mexui.util.doesContainEOLChar(text) : false; - this.masked = false; - this.singleCharacter = singleCharacter === undefined ? false : singleCharacter; - this.placeholder = ''; - this.caretShownForBlink = true; - this.lineHeight = 25; - this.maxLength = this.singleCharacter ? 1 : false; - - this.validValue = true; -}); - -// default styles -mexui.util.linkBaseControlStyles('TextInput', { - caret: - { - lineColour: toColour(0, 0, 0, 255) - }, - placeholder: - { - textColour: toColour(100, 100, 100, 255) - } -}); - -// input -mexui.Control.TextInput.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - var hit = this.isCursorOverControl(); - if(hit) - { - this.caretPosition = this.getCaretPositionByCursor(); - } - } - - mexui.Component.Control.prototype.onMouseDown.call(this, e); -}; - -mexui.Control.TextInput.prototype.onCharacter = function(e, character) -{ - if(mexui.focusedControl == this) - { - /* - var isValid1 = this.callback ? this.callback(character) : true; - if(!isValid1 && isValid1 !== undefined) - return; - */ - - var isValid2 = this.validateInputCallback ? this.validateInputCallback(e, character) : true; - if(!isValid2) - return; - - if(this.singleCharacter) - { - this.resetText(); - this.lines = [character]; - this.caretPosition.x = this.caretPosition.x < 2 ? this.caretPosition.x : 0; - } - else if(this.canAddCharacter()) - { - this.lines[this.caretPosition.y] = this.getTextWithNewCharacter(character); - this.caretPosition.x++; - } - - this.checkToCallCallback(); - this.validateValue(e); - } -}; - -mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods) -{ - if(mexui.focusedControl != this) - return; - - var controlIsDown = (mods & KMOD_CTRL) == KMOD_CTRL; - - switch(key) - { - case SDLK_LEFT: - if(this.caretPosition.x != 0) - { - this.caretPosition.x--; - } - else if(this.caretPosition.y != 0) - { - this.caretPosition.y--; - this.caretPosition.x = this.getCaretLine().length; - } - break; - case SDLK_RIGHT: - if(this.caretPosition.x != this.getCaretLine().length) - { - this.caretPosition.x++; - } - else if(this.caretPosition.y != (this.lines.length - 1)) - { - this.caretPosition.y++; - this.caretPosition.x = 0; - } - break; - case SDLK_HOME: - if(controlIsDown) - { - this.caretPosition.y = 0; - this.caretPosition.x = 0; - } - else - this.caretPosition.x = 0; - break; - case SDLK_END: - if(controlIsDown) - { - this.caretPosition.y = this.lines.length - 1; - this.caretPosition.x = this.getCaretLine().length; - } - else - this.caretPosition.x = this.getCaretLine().length; - break; - case SDLK_DELETE: - if(this.caretPosition.x != this.getCaretLine().length) - { - this.deleteCharacter(this.caretPosition); - this.checkToCallCallback(); - } - else if(this.caretPosition.y != (this.lines.length - 1)) - { - this.mergeLines(this.caretPosition.y); - this.checkToCallCallback(); - } - break; - case SDLK_BACKSPACE: - if(this.caretPosition.x != 0) - { - this.deleteCharacter(new Vec2(this.caretPosition.x - 1, this.caretPosition.y)); - this.caretPosition.x--; - this.checkToCallCallback(); - } - else if(this.caretPosition.y != 0) - { - this.caretPosition.y--; - this.caretPosition.x = this.getCaretLine().length; - this.mergeLines(this.caretPosition.y); - this.checkToCallCallback(); - } - break; - } - - if(this.multiLine) - { - switch(key) - { - case SDLK_RETURN: - case SDLK_KP_ENTER: - if(this.canAddCharacter()) - { - if(this.caretPosition.x == this.getCaretLine().length) - { - this.addLine(this.caretPosition.y + 1); - this.caretPosition.y++; - this.caretPosition.x = 0; - this.checkToCallCallback(); - } - else - { - this.splitLine(this.caretPosition.y); - this.caretPosition.y++; - this.caretPosition.x = 0; - this.checkToCallCallback(); - } - } - break; - case SDLK_UP: - if(this.caretPosition.y != 0) - { - this.caretPosition.y--; - if(this.caretPosition.x > this.getCaretLine().length) - this.caretPosition.x = this.getCaretLine().length; - } - break; - case SDLK_DOWN: - if(this.caretPosition.y != (this.lines.length - 1)) - { - this.caretPosition.y++; - if(this.caretPosition.x > this.getCaretLine().length) - this.caretPosition.x = this.getCaretLine().length; - } - break; - } - } - - this.validateValue(e); -}; - -// render -mexui.Control.TextInput.prototype.render = function() -{ - var pos = this.getScreenPosition(); - var pos2 = new Vec2(pos.x, pos.y); - - mexui.native.drawRectangle(pos, this.size, this.getStyles('main')); - - if(this.isEmpty()) - { - mexui.native.drawText(pos, this.size, this.placeholder, this.getStyles('placeholder')); - } - else - { - var lineSize = new Vec2(this.size.x, this.lineHeight); - for(var i=0,j=this.lines.length; i (this.lines.length - 1)) - this.caretPosition.y = this.lines.length - 1; - - if(this.caretPosition.x < 0) - this.caretPosition.x = 0; - else if(this.caretPosition.x > this.lines[this.caretPosition.y].length) - this.caretPosition.x = this.lines[this.caretPosition.y].length; -}; - -mexui.Control.TextInput.prototype.getCaretPositionByCursor = function() -{ - var lineIndex = this.getCaretLineIndexByCursor(); - var charIndex = this.getCharIndexByCursor(lineIndex); - return new Vec2(charIndex, lineIndex); -}; - -mexui.Control.TextInput.prototype.getCaretLineIndexByCursor = function() -{ - var yPos = gui.cursorPosition.y - this.getScreenPosition().y; - var lineIndex = Math.floor(yPos / this.lineHeight); - - if(lineIndex < 0) - return 0; - else if(lineIndex > (this.lines.length - 1)) - return this.lines.length - 1; - else - return lineIndex; -}; - -mexui.Control.TextInput.prototype.getCharIndexByCursor = function(lineIndex) -{ - var xPos = gui.cursorPosition.x - this.getScreenPosition().x; - var line = this.lines[lineIndex]; - var lineStyles = this.getStyles('caret'); - - for(var i=0,j=line.length; i'; - - mexui.native.drawRectangle(pos, this.arrowBoxSize, this.getStyles('main')); - mexui.native.drawText(pos, this.arrowBoxSize, text, this.getStyles('main')); - - pos.x += this.arrowBoxSize.x; - } - } -}; - -// model -mexui.Control.Time.prototype.generateText = function() -{ - this.setText((this.hour < 10 ? '0'+this.hour : this.hour) - +':'+(this.minute < 10 ? '0'+this.minute : this.minute) - +':'+(this.second < 10 ? '0'+this.second : this.second)); -}; - -mexui.Control.Time.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character) || character == ':'; -}; - -mexui.Control.Time.prototype.validateValueCallback = function(e) -{ - var parts = this.getText().split(':'); - - if(parts.length != 3) - return false; - - for(var i in parts) - { - var partAsStr = parts[i]; - if(partAsStr === '') - return false; - - var part = parseInt(partAsStr); - - if(partAsStr.length == 2 && partAsStr.substr(0, 1) == '0') - partAsStr = partAsStr.substr(1); - - if(!mexui.util.isPositiveInt(partAsStr)) - return false; - - if(part < 0) - return false; - - if(part > (i == 0 ? 23 : 59)) - return false; - } - - return true; -}; - -mexui.Control.Time.prototype.getArrowIndexByCursor = function() -{ - var cursorPos = gui.cursorPosition; - - var screenPos = this.getScreenPosition(); - var firstArrowStartPos = new Vec2(screenPos.x, screenPos.y + this.valueBoxSize.y); - var lastArrowEndPos = new Vec2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y); - - if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y) - { - return Math.floor((cursorPos.x - firstArrowStartPos.x) / this.arrowBoxSize.x); - } - else - { - return false; - } -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Tree.js b/third-party/mexui/Core/Control/Tree.js deleted file mode 100644 index a6e5d56b..00000000 --- a/third-party/mexui/Core/Control/Tree.js +++ /dev/null @@ -1,156 +0,0 @@ -mexui.util.createControlConstructor('Tree', true, function(window, x, y, w, h, styles) -{ - mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Tree', styles)); - mexui.Entity.ControlWithEntries.call(this, false, false); - - this.rowHeight = 25; - this.rowLevelIndentation = 10; - this.scrollMultiplier = 10.0; -}); - -// default styles -mexui.util.linkBaseControlStyles('Tree', { - row: - { - backgroundColour: toColour(255, 255, 255, 255), - textColour: toColour(0, 0, 0, 255) - }, - rowIcon: - { - textColour: toColour(230, 130, 0, 190) - }, - rowLine: - { - lineColour: toColour(0, 0, 0, 150) - } -}); - -// input -mexui.Control.Tree.prototype.onMouseDown = function(e) -{ - if(e.button == 0) - { - var pos = this.getScreenPosition(); - pos.y -= this.axis.y.getScrolledOffset(); - - this.testRowClick(e, this.axis.y.entries, pos); - } - - if(!e.used) - mexui.Entity.ControlWithEntries.prototype.onMouseDown.call(this, e); -}; - -// render -mexui.Control.Tree.prototype.render = function() -{ - var pos = this.getScreenPosition(); - pos.y -= this.axis.y.getScrolledOffset(); - - this.renderRows(this.axis.y.entries, 0, pos); - - if(this.isFocused()) - mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused')); -}; - -mexui.Control.Tree.prototype.renderRows = function(rows, level, pos) -{ - for(var i in rows) - { - var row = rows[i]; - var shouldDraw = pos.y >= this.getScreenPosition().y && pos.y <= (this.getScreenPosition().y + this.size.y); - - if(shouldDraw) - { - if(row.rows.length > 0) - mexui.native.drawText(new Vec2(pos.x - (this.rowLevelIndentation * 2), pos.y), new Vec2(this.size.x, this.rowHeight), row.open ? '-' : '+', this.getStyles('rowIcon')); - - mexui.native.drawRectangle(pos, new Vec2(this.size.x - (this.rowLevelIndentation * level), this.rowHeight), this.getStyles('row')); - mexui.native.drawText(pos, new Vec2(this.size.x, this.rowHeight), row.text, this.getStyles('row')); - } - - pos.y += this.rowHeight; - - if(shouldDraw) - { - mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine')); - } - - if(row.rows.length > 0 && row.open) - { - pos.x += this.rowLevelIndentation; - this.renderRows(row.rows, level + 1, pos); - pos.x -= this.rowLevelIndentation; - } - } -}; - -// model -mexui.Control.Tree.prototype.getAllEntriesLength = function(axisIndex) -{ - return this.getRowsLength(this.axis.y.entries); -}; - -mexui.Control.Tree.prototype.getRowsLength = function(rows) -{ - var length = rows.length * this.entrySize.y; - for(var i in rows) - { - if(rows[i].open) - length += this.getRowsLength(rows[i].rows); - } - return length; -}; - -mexui.Control.Tree.prototype.testRowClick = function(e, rows, pos) -{ - for(var i in rows) - { - var row = rows[i]; - - var rowPos = new Vec2(pos.x - (this.rowLevelIndentation * 2), pos.y); - var rowSize = new Vec2(this.size.x + (this.rowLevelIndentation * 2), this.rowHeight); - if(mexui.util.isCursorInRectangle(rowPos, rowSize)) - { - this.onClickRow(row); - e.used = true; - return; - } - - pos.y += this.rowHeight; - - if(row.rows.length > 0 && row.open) - { - this.testRowClick(e, row.rows, pos); - if(e.used) - return; - } - } -}; - -mexui.Control.Tree.prototype.onClickRow = function(row) -{ - if(row.rows.length > 0) - { - //var scrollableLengthBefore = this.axis.y.getScrollableLength(); - - row.open = !row.open; - this.checkToShowScrollBars(); - - /* - if(this.scrollBars[1].shown) - { - var scrollableLengthAfter = this.axis.y.getScrollableLength(); - this.scrollBars[1].scrolledRatio += (scrollableLengthAfter - scrollableLengthBefore) / scrollableLengthAfter; - } - */ - } -}; - -// api -mexui.Control.Tree.prototype.row = function(text) -{ - var entry = new mexui.Entry.TreeRow(this, text); - this.axis.y.addEntry(entry); - return entry; -}; - diff --git a/third-party/mexui/Core/Control/Week.js b/third-party/mexui/Core/Control/Week.js deleted file mode 100644 index a141b319..00000000 --- a/third-party/mexui/Core/Control/Week.js +++ /dev/null @@ -1,21 +0,0 @@ -mexui.util.createControlConstructor('Week', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Week', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.Week, mexui.Control.TextInput); - -// model -mexui.Control.Week.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character); -}; - -mexui.Control.Week.prototype.validateValueCallback = function(e) -{ - var _int = parseInt(this.getText()); - - if(_int < 1 || _int > 52) - return false; - - return true; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/WeekDay.js b/third-party/mexui/Core/Control/WeekDay.js deleted file mode 100644 index 2e4115b2..00000000 --- a/third-party/mexui/Core/Control/WeekDay.js +++ /dev/null @@ -1,16 +0,0 @@ -mexui.util.createControlConstructor('WeekDay', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('WeekDay', styles), callback, false, false); -}); -mexui.util.extend(mexui.Control.WeekDay, mexui.Control.TextInput); - -// model -mexui.Control.WeekDay.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character); -}; - -mexui.Control.WeekDay.prototype.validateValueCallback = function(e) -{ - return mexui.util.isWeekDayIdOrName(this.getText()); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Control/Year.js b/third-party/mexui/Core/Control/Year.js deleted file mode 100644 index b1921ec4..00000000 --- a/third-party/mexui/Core/Control/Year.js +++ /dev/null @@ -1,21 +0,0 @@ -mexui.util.createControlConstructor('Year', false, function(window, x, y, w, h, text, styles, callback) -{ - mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Year', styles), callback, false, false); - - this.maxYearOffset = 10; - this.minYearCallback = ()=>{ return 1900; }; - this.maxYearCallback = ()=>{ return new Date().getFullYear() + this.maxYearOffset; } - this.twoDigitYearCapOffset = 10; -}); -mexui.util.extend(mexui.Control.Year, mexui.Control.TextInput); - -// model -mexui.Control.Year.prototype.validateInputCallback = function(e, character) -{ - return mexui.util.isPositiveIntChar(character); -}; - -mexui.Control.Year.prototype.validateValueCallback = function(e) -{ - return mexui.util.isYear(this.getText(), this.minYearCallback(), this.maxYearCallback(), this.twoDigitYearCapOffset); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Entity/Component.js b/third-party/mexui/Core/Entity/Component.js deleted file mode 100644 index e0afae23..00000000 --- a/third-party/mexui/Core/Entity/Component.js +++ /dev/null @@ -1,41 +0,0 @@ -mexui.Entity.Component = function(moveable) -{ - this.moveable = moveable; - - this.moving = false; -}; -mexui.util.extend(mexui.Entity.Component, mexui.Entity.StyleableEntity); - -// input -mexui.Entity.Component.prototype.onMouseDown = function(e) -{ - if(e.button == 0 && this.moveable && this.isCursorOverComponent()) - { - this.moving = true; - e.used = true; - } -}; - -mexui.Entity.Component.prototype.onMouseUp = function(e) -{ - if(e.button == 0 && this.moving) - { - this.moving = false; - e.used = true; - } -}; - -mexui.Entity.Component.prototype.onMouseMove = function(e, offset) -{ - if(this.moving) - { - this.position = new Vec2(this.position.x + offset.x, this.position.y + offset.y); - e.used = true; - } -}; - -// model -mexui.Entity.Component.prototype.isCursorOverComponent = function() -{ - return mexui.util.isCursorInRectangle(this.getScreenPosition(), this.size); -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Entity/ControlAxis.js b/third-party/mexui/Core/Entity/ControlAxis.js deleted file mode 100644 index 4bddcdec..00000000 --- a/third-party/mexui/Core/Entity/ControlAxis.js +++ /dev/null @@ -1,200 +0,0 @@ -mexui.Entity.ControlAxis = function(control, isVertical, manualScrollBar, entriesPositionOffset) -{ - this.control = control; - this.isVertical = isVertical; - this.manualScrollBar = manualScrollBar; - - this.axisIndex = isVertical ? 1 : 0; - this.entriesShown = true; - this.entryCountShown = 15; - this.hoveredEntryIndex = -1; - this.entries = []; - this.scrollBar = []; -}; - -// model - -// scroll bar initialization -mexui.Entity.ControlAxis.prototype.initScrollBar = function() -{ - if(this.isVertical) - { - var pos = mexui.util.addVec2(this.control.position, new Vec2(this.control.entrySize.x, this.control.entriesPositionOffset.y)); - this.scrollBar = new mexui.Control.ScrollBar(this.control.window, pos.x, pos.y, 25, this.getDisplayedEntriesLength(), true, this.control.styles.scrollBar); - } - else - { - var pos = mexui.util.addVec2(this.control.position, new Vec2(this.control.entriesPositionOffset.x, this.control.size.y)); - this.scrollBar = new mexui.Control.ScrollBar(this.control.window, pos.x, pos.y, this.getDisplayedEntriesLength(), 25, false, this.control.styles.scrollBar); - } - - if(this.manualScrollBar) - this.scrollBar.shown = false; -}; - -// add/remove entries -mexui.Entity.ControlAxis.prototype.addEntry = function(entry) -{ - this.entries.push(entry); - this.checkToShowScrollBar(); -}; - -mexui.Entity.ControlAxis.prototype.removeAllEntries = function() -{ - this.entries = []; - this.checkToShowScrollBar(); -}; - -// fetch entry by position -mexui.Entity.ControlAxis.prototype.getEntryByCursor = function() -{ - return this.getEntryByPoint(gui.cursorPosition); -}; - -mexui.Entity.ControlAxis.prototype.getEntryIndexByCursor = function() -{ - return this.getEntryIndexByPoint(gui.cursorPosition); -}; - -mexui.Entity.ControlAxis.prototype.getEntryByPoint = function(point) -{ - var index = this.getEntryIndexByPoint(point); - if(index == null) - return null; - return this.entries[index]; -}; - -mexui.Entity.ControlAxis.prototype.getEntryIndexByPoint = function(point) -{ - var screenPos = this.control.getScreenPosition(); - if(this.axisIndex == 1) - { - if(point.x < screenPos.x || point.x > (screenPos.x + this.control.entrySize.x)) - { - return null; - } - - var pos = new Vec2(screenPos.x + this.control.entriesPositionOffset.x, screenPos.y + this.control.entriesPositionOffset.y); - var index = Math.floor((point.y - pos.y) / this.control.entrySize[this.axisIndex]); - index += this.getEntryStartIndex(); - - if(index < 0 || index >= this.entries.length) - return null; - - return index; - } - else - { - - } -}; - -// entries sizing -mexui.Entity.ControlAxis.prototype.getOutsideEntriesLength = function() -{ - return this.control.entrySize[this.axisIndex] * this.entryCountShown; -}; - -mexui.Entity.ControlAxis.prototype.getAllEntriesLength = function() -{ - if(this.control.getAllEntriesLength) - return this.control.getAllEntriesLength(this.axisIndex); - else - return this.getAllEntriesLength2(); -}; - -mexui.Entity.ControlAxis.prototype.getAllEntriesLength2 = function() -{ - return this.entries.length * this.control.entrySize[this.axisIndex]; -}; - -mexui.Entity.ControlAxis.prototype.getDisplayedEntriesLength = function() -{ - var sizeOffset = this.control.entriesSizeOffset[this.axisIndex]; - if(this.control.entriesOutsideControl) - return this.getOutsideEntriesLength() + sizeOffset; - else - return this.control.size[this.axisIndex] + sizeOffset; -}; - -// entry scrolling -mexui.Entity.ControlAxis.prototype.setScrollBarManual = function(manual) -{ - this.manualScrollBar = manual; - - if(manual) - { - this.setScrollBarShown(false); - } -}; - -mexui.Entity.ControlAxis.prototype.setScrollBarShown = function(shown) -{ - //if(axisIndex != this.axisIndex) - // shown = false; - - this.scrollBar.shown = shown; - if(!shown) - this.scrollBar.scrolledRatio = 0.0; -}; - -mexui.Entity.ControlAxis.prototype.shouldDisplayScrollBar = function() -{ - //if(axisIndex != this.axisIndex) - // return false; - - return this.getAllEntriesLength() > this.scrollBar.size[this.axisIndex]; -}; - -mexui.Entity.ControlAxis.prototype.checkToShowScrollBar = function() -{ - if(this.manualScrollBar) - return; - - this.setScrollBarShown(this.shouldDisplayScrollBar(), true); -}; - -mexui.Entity.ControlAxis.prototype.getScrolledOffset = function() -{ - if(this.axisIndex == 1) - { - if(!this.scrollBar.shown) - return 0; - - return this.scrollBar.scrolledRatio * this.getScrollableLength(); - } - else - { - return 0; - } -}; - -mexui.Entity.ControlAxis.prototype.getScrolledOffsetFixedStart = function() -{ - var entryLength = this.control.entrySize[this.axisIndex]; - return Math.floor(this.getScrolledOffset() / entryLength) * entryLength; -}; - -mexui.Entity.ControlAxis.prototype.getScrollableLength = function() -{ - return this.getAllEntriesLength() - this.getOutsideEntriesLength(); -}; - -// entry iteration -mexui.Entity.ControlAxis.prototype.getEntryStartIndex = function() // inclusive -{ - return Math.floor(this.getScrolledOffset() / this.control.entrySize[this.axisIndex]); -}; - -mexui.Entity.ControlAxis.prototype.getEntryEndIndex = function() // exclusive -{ - return this.getEntryStartIndex() + this.getDisplayedEntryCount(); -}; - -mexui.Entity.ControlAxis.prototype.getDisplayedEntryCount = function() -{ - var displayedEntriesLength = this.getDisplayedEntriesLength(); - var displayedEntryCount = Math.floor(displayedEntriesLength / this.control.entrySize[this.axisIndex]); - return this.entries.length < displayedEntryCount ? this.entries.length : displayedEntryCount; -}; - diff --git a/third-party/mexui/Core/Entity/ControlWithEntries.js b/third-party/mexui/Core/Entity/ControlWithEntries.js deleted file mode 100644 index 732014ff..00000000 --- a/third-party/mexui/Core/Entity/ControlWithEntries.js +++ /dev/null @@ -1,98 +0,0 @@ -mexui.Entity.ControlWithEntries = function(entriesOutsideControl, manualScrollBar, entriesPositionOffset, entrySize, entriesSizeOffset) -{ - this.entriesOutsideControl = entriesOutsideControl; - this.entriesPositionOffset = entriesPositionOffset || new Vec2(0, 0); - this.entrySize = entrySize || new Vec2(this.size.x, 25); - this.entriesSizeOffset = entriesSizeOffset || new Vec2(0, 0); - - this.axis = {}; - this.axis.x = new mexui.Entity.ControlAxis(this, false, manualScrollBar, entriesPositionOffset); - this.axis.y = new mexui.Entity.ControlAxis(this, true, manualScrollBar, entriesPositionOffset); - - this.axis.x.initScrollBar(); - this.axis.y.initScrollBar(); - - this.checkToShowScrollBars(); -}; -mexui.util.extend(mexui.Entity.ControlWithEntries, mexui.Component.Control); - -// input -mexui.Entity.ControlWithEntries.prototype.onMouseDown = function(e) -{ - this.triggerEvent('onMouseDown', e); -}; - -mexui.Entity.ControlWithEntries.prototype.onMouseUp = function(e) -{ - this.triggerEvent('onMouseUp', e); -}; - -mexui.Entity.ControlWithEntries.prototype.onMouseMove = function(e, offset) -{ - for(var k in this.axis) - { - if(this.axis[k].entriesShown) - { - var hoveredEntryIndex = this.axis[k].getEntryIndexByCursor(); - if(hoveredEntryIndex == null) - { - this.axis[k].hoveredEntryIndex = -1; - } - else - { - e.used = true; - this.axis[k].hoveredEntryIndex = hoveredEntryIndex; - break; - } - } - } - - if(!e.used) - this.triggerEvent('onMouseMove', e, offset); -}; - -mexui.Entity.ControlWithEntries.prototype.onMouseWheel = function(e, data) -{ - this.triggerEvent('onMouseWheel', e, data); -}; - -// render -mexui.Entity.ControlWithEntries.prototype.renderAfter = function() -{ - this.triggerEvent('renderAfter'); -}; - -// model -mexui.Entity.ControlWithEntries.prototype.triggerEvent = function(eventName, e, data) -{ - for(var k in this.axis) - { - if(this.axis[k].scrollBar.shown) - { - this.axis[k].scrollBar[eventName].call(this.axis[k].scrollBar, e, data); - if(e && e.used) - return; - } - } - - mexui.Component.Control.prototype[eventName].call(this, e, data); -}; - -mexui.Entity.ControlWithEntries.prototype.checkToShowScrollBars = function() -{ - this.axis.x.checkToShowScrollBar(); - this.axis.y.checkToShowScrollBar(); -}; - -mexui.Entity.ControlWithEntries.prototype.setScrollBarsManual = function(manual) -{ - this.axis.x.setScrollBarManual(manual); - this.axis.y.setScrollBarManual(manual); -}; - -mexui.Entity.ControlWithEntries.prototype.removeAllEntries = function() -{ - this.axis.x.removeAllEntries(); - this.axis.y.removeAllEntries(); -}; - diff --git a/third-party/mexui/Core/Entity/StyleableEntity.js b/third-party/mexui/Core/Entity/StyleableEntity.js deleted file mode 100644 index ea25df16..00000000 --- a/third-party/mexui/Core/Entity/StyleableEntity.js +++ /dev/null @@ -1,210 +0,0 @@ -mexui.Entity.StyleableEntity = function(styles) -{ - this.styles = styles; - - this.shown = true; - //this.hovered = false; - - this.transitions = {}; // string controlPartName => Transition transition - - /* - this.transitionDelayTimer = null; - this.transitionStartTime = 0; - this.transitionEndTime = 0; - this.transitionIsProcessing = false; - this.transitionIsReverting = false; - this.transitionProgressReached = 0.0; - */ -}; - -// default styles -mexui.Entity.StyleableEntity.globalDefaultStyles = { - all: - { - textFont: 'Arial', - textSize: 14.0, - textAlign: 0.0, - textIndent: 5, - textColour: toColour(0, 0, 0, 255), - - backgroundColour: toColour(255, 255, 255, 255), - - lineWeight: 1 - } -}; - -mexui.Entity.StyleableEntity.defaultStyles = mexui.util.linkGlobalStyles(mexui.Entity.StyleableEntity.globalDefaultStyles, { - main: - { - backgroundColour: toColour(255, 255, 255, 255), - borderColour: 'none', - textColour: toColour(0, 0, 0, 255), - - hover: - { - backgroundColour: toColour(220, 220, 220, 255), - borderColour: 'none', - textColour: toColour(0, 0, 0, 255) - }/*, - - focus: - { - borderColour: toColour(255, 128, 0, 230), - textColour: toColour(0, 0, 0, 255) - } - */ - }, - focused: - { - borderColour: toColour(28, 119, 198, 255) - }, - invalidValue: - { - borderColour: toColour(250, 5, 5, 255) - } -}); - -// model -mexui.Entity.StyleableEntity.prototype.linkControlStyles = function(controlName, styles) -{ - return mexui.util.linkStyles(mexui.Control[controlName].defaultStyles, styles); -}; - -mexui.Entity.StyleableEntity.prototype.linkComponentStyles = function(componentName, styles) -{ - return mexui.util.linkStyles(mexui.Component[componentName].defaultStyles, styles); -}; - -mexui.Entity.StyleableEntity.prototype.linkEntryStyles = function(entryName, styles) -{ - return mexui.util.linkStyles(mexui.Entry[entryName].defaultStyles, styles); -}; - -mexui.Entity.StyleableEntity.prototype.isFocused = function() -{ - return this == mexui.focusedControl; -}; - -mexui.Entity.StyleableEntity.prototype.isHovered = function() -{ - //return this.hovered; - return this == mexui.hoveredComponent; -}; - -mexui.Entity.StyleableEntity.prototype.getStyles = function(controlPartName) -{ - var isFocused = this.isFocused(); - var isHovered = this.isHovered(); - var styles = this.styles[controlPartName]; - - var transition = this.getTransition(controlPartName); - - if(transition.isProcessing()) - { - return mexui.util.getTransitionStyles(styles, ['hover'], transition.getMainToPseudoProgress()); - } - - if(isHovered) - { - return mexui.util.mergeStyles(styles, ['hover']); - } - - return styles; -}; - -mexui.Entity.StyleableEntity.prototype.getEntryStyles = function(data) -{ - var styles = {}; - - for(var i in data) - { - var baseStyles = data[i][0].getStyles(data[i][1]); - - for(var k in baseStyles) - { - if(baseStyles.hasOwnProperty(k) && styles[k] === undefined) - { - styles[k] = baseStyles[k]; - } - } - } - - for(var i in data) - { - var baseStyles = data[i][0].getStyles(data[i][1]); - - for(var k in baseStyles) - { - if(styles[k] === undefined) - { - styles[k] = baseStyles[k]; - } - } - } - - return styles; -}; - -// custom events -mexui.Entity.StyleableEntity.prototype.onMouseEnter = function() -{ - var controlParts = this.getControlPartsWithTransition(); - for(var i in controlParts) - { - var transition = this.getTransition(controlParts[i]); - - var delay = this.getTransitionDelayStyle(controlParts[i]); - var time = this.getTransitionTimeStyle(controlParts[i]); - - transition.onMouseEnter(delay, time); - } -}; - -mexui.Entity.StyleableEntity.prototype.onMouseExit = function() -{ - var controlParts = this.getControlPartsWithTransition(); - for(var i in controlParts) - { - var transition = this.getTransition(controlParts[i]); - - transition.onMouseExit(); - } -}; - -// transitions -mexui.Entity.StyleableEntity.prototype.getTransition = function(controlPartName) -{ - if(!this.transitions[controlPartName]) - this.transitions[controlPartName] = new mexui.Entity.Transition; - return this.transitions[controlPartName]; -}; - -mexui.Entity.StyleableEntity.prototype.getControlPartsWithTransition = function() -{ - var controlParts = []; - for(var k in this.styles) - { - if(this.styles[k].hover && (this.styles[k].hover.transitionTime != null || this.styles[k].hover.transitionDelay != null)) - { - controlParts.push(k); - } - } - return controlParts; -}; - -mexui.Entity.StyleableEntity.prototype.getTransitionDelayStyle = function(controlPartName) -{ - if(this.styles[controlPartName].hover.transitionDelay != null) - return this.styles[controlPartName].hover.transitionDelay; - else - return mexui.Entity.Transition.defaultTransitionDelay; -}; - -mexui.Entity.StyleableEntity.prototype.getTransitionTimeStyle = function(controlPartName) -{ - if(this.styles[controlPartName].hover.transitionTime != null) - return this.styles[controlPartName].hover.transitionTime; - else - return mexui.Entity.Transition.defaultTransitionTime; -}; - diff --git a/third-party/mexui/Core/Entity/Transition.js b/third-party/mexui/Core/Entity/Transition.js deleted file mode 100644 index b72bcffd..00000000 --- a/third-party/mexui/Core/Entity/Transition.js +++ /dev/null @@ -1,184 +0,0 @@ -mexui.Entity.Transition = function() -{ - this.processing = false; - this.interpolating = false; - this.mainToPseudoProgress = 0.0; - this.delayTimer = null; - this.transitionDelay = mexui.Entity.Transition.defaultTransitionDelay; - this.transitionTime = mexui.Entity.Transition.defaultTransitionTime; - this.mouseIsEntered = false; - this.lastUpdateTime = mexui.util.time(); - this.direction = true; -}; - -// static -mexui.Entity.Transition.defaultTransitionDelay = 0; -mexui.Entity.Transition.defaultTransitionTime = 1000;//400; - -// custom events -mexui.Entity.Transition.prototype.onMouseEnter = function(transitionDelay, transitionTime) -{ - if(this.isMouseEntered()) - return; - this.setMouseEntered(true); - - this.transitionDelay = transitionDelay; - this.transitionTime = transitionTime; - - if(transitionDelay > 0) - { - this.startDelay(); - } - else if(this.isInterpolating()) - { - this.revertInterpolationDirection(); - } - else - { - this.startEnterInterpolation(); - } -}; - -mexui.Entity.Transition.prototype.onMouseExit = function() -{ - if(!this.isMouseEntered()) - return; - this.setMouseEntered(false); - - if(this.isDelayActive()) - { - this.clearDelayTimer(); - } - else if(this.isInterpolating()) - { - this.revertInterpolationDirection(); - } - else - { - this.startExitInterpolation(); - } -}; - -// model -mexui.Entity.Transition.prototype.setMouseEntered = function(status) -{ - this.mouseIsEntered = status; -}; - -mexui.Entity.Transition.prototype.isMouseEntered = function() -{ - return this.mouseIsEntered; -}; - -// processing -mexui.Entity.Transition.prototype.isProcessing = function() -{ - return this.processing; -}; - -mexui.Entity.Transition.prototype.stopProcessing = function() -{ - if(this.isInterpolating()) - { - this.stopInterpolation(); - } - - this.delayTimer = null; - this.processing = false; -}; - -// interpolation status -mexui.Entity.Transition.prototype.startEnterInterpolation = function() -{ - this.lastUpdateTime = mexui.util.time(); - this.processing = true; - this.interpolating = true; - this.direction = true; - this.mainToPseudoProgress = 0.0; -}; - -mexui.Entity.Transition.prototype.startExitInterpolation = function() -{ - this.lastUpdateTime = mexui.util.time(); - this.processing = true; - this.interpolating = true; - this.direction = false; - this.mainToPseudoProgress = 1.0; -}; - -mexui.Entity.Transition.prototype.stopInterpolation = function() -{ - this.interpolating = false; -}; - -mexui.Entity.Transition.prototype.isInterpolating = function() -{ - return this.interpolating; -}; - -// interpolation direction -mexui.Entity.Transition.prototype.revertInterpolationDirection = function() -{ - this.lastUpdateTime = mexui.util.time(); - this.direction = !this.direction; -}; - -// progress -mexui.Entity.Transition.prototype.increaseMainToPseudoProgress = function() -{ - var timeDiff = mexui.util.time() - this.lastUpdateTime; - this.lastUpdateTime = mexui.util.time(); - var progressDiff = timeDiff / this.transitionTime; - - if(this.direction) - this.mainToPseudoProgress += progressDiff; - else - this.mainToPseudoProgress -= progressDiff; - - if(this.mainToPseudoProgress < 0.0) - { - this.mainToPseudoProgress = 0.0; - this.stopProcessing(); - } - else if(this.mainToPseudoProgress > 1.0) - { - this.mainToPseudoProgress = 1.0; - } -}; - -mexui.Entity.Transition.prototype.getMainToPseudoProgress = function() -{ - this.increaseMainToPseudoProgress(); - - return this.mainToPseudoProgress; -}; - -mexui.Entity.Transition.prototype.getCompletionProgress = function() -{ - if(this.direction) - return this.mainToPseudoProgress; - else - return 1.0 - this.mainToPseudoProgress; -}; - -mexui.Entity.Transition.prototype.startDelay = function() -{ - var that = this; - this.delayTimer = setTimeout(function() - { - that.delayTimer = null; - that.startEnterInterpolation.call(that); - }, this.transitionDelay); -}; - -mexui.Entity.Transition.prototype.isDelayActive = function() -{ - return this.delayTimer != null; -}; - -mexui.Entity.Transition.prototype.clearDelayTimer = function() -{ - clearTimeout(this.delayTimer); - this.delayTimer = null; -}; - diff --git a/third-party/mexui/Core/Entry/DropDownItem.js b/third-party/mexui/Core/Entry/DropDownItem.js deleted file mode 100644 index e8c7ed01..00000000 --- a/third-party/mexui/Core/Entry/DropDownItem.js +++ /dev/null @@ -1,7 +0,0 @@ -mexui.Entry.DropDownItem = function(dropDown, text) -{ - mexui.Component.Entry.call(this, dropDown, 1); - - this.text = text; -}; -mexui.util.extend(mexui.Entry.DropDownItem, mexui.Component.Entry); \ No newline at end of file diff --git a/third-party/mexui/Core/Entry/GridColumn.js b/third-party/mexui/Core/Entry/GridColumn.js deleted file mode 100644 index a2135ee0..00000000 --- a/third-party/mexui/Core/Entry/GridColumn.js +++ /dev/null @@ -1,9 +0,0 @@ -mexui.Entry.GridColumn = function(grid, text, width, height) -{ - mexui.Component.Entry.call(this, grid, 0); - - this.text = text || 'Column'; - this.width = width || 100; - this.height = height || 25; -}; -mexui.util.extend(mexui.Entry.GridColumn, mexui.Component.Entry); \ No newline at end of file diff --git a/third-party/mexui/Core/Entry/GridRow.js b/third-party/mexui/Core/Entry/GridRow.js deleted file mode 100644 index 11419eff..00000000 --- a/third-party/mexui/Core/Entry/GridRow.js +++ /dev/null @@ -1,13 +0,0 @@ -mexui.Entry.GridRow = function(grid, cells, styles) -{ - mexui.Component.Entry.call(this, grid, 1); - mexui.Entity.StyleableEntity.call(this, this.linkEntryStyles('GridRow', styles)); - - this.cells = cells; - this.rowHeight = 25; -}; -mexui.util.extend(mexui.Entry.GridRow, mexui.Component.Entry); - -// default styles -mexui.Entry.GridRow.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, {}); - diff --git a/third-party/mexui/Core/Entry/ListRow.js b/third-party/mexui/Core/Entry/ListRow.js deleted file mode 100644 index 438ec65e..00000000 --- a/third-party/mexui/Core/Entry/ListRow.js +++ /dev/null @@ -1,7 +0,0 @@ -mexui.Entry.ListRow = function(list, text) -{ - mexui.Component.Entry.call(this, list, 1); - - this.text = text; -}; -mexui.util.extend(mexui.Entry.ListRow, mexui.Component.Entry); \ No newline at end of file diff --git a/third-party/mexui/Core/Entry/Tab.js b/third-party/mexui/Core/Entry/Tab.js deleted file mode 100644 index 436833bb..00000000 --- a/third-party/mexui/Core/Entry/Tab.js +++ /dev/null @@ -1,26 +0,0 @@ -mexui.Entry.Tab = function(tabPanel, text) -{ - mexui.Component.Entry.call(this, tabPanel, 0); - - this.text = text; - this.controls = []; -}; -mexui.util.extend(mexui.Entry.Tab, mexui.Component.Entry); - -// model -mexui.Entry.Tab.prototype._control = function(control) -{ - control.shown = this.control.activeTabIndex == this.getEntryIndex(); - this.controls.push(control); -}; - -mexui.Entry.Tab.prototype.setActive = function() -{ - for(var i in this.control.entries[this.control.activeTabIndex].controls) - this.control.entries[this.control.activeTabIndex].controls[i].shown = false; - - this.control.activeTabIndex = this.getEntryIndex(); - - for(var i in this.control.entries[this.control.activeTabIndex].controls) - this.control.entries[this.control.activeTabIndex].controls[i].shown = true; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Entry/TreeRow.js b/third-party/mexui/Core/Entry/TreeRow.js deleted file mode 100644 index 51ed8617..00000000 --- a/third-party/mexui/Core/Entry/TreeRow.js +++ /dev/null @@ -1,17 +0,0 @@ -mexui.Entry.TreeRow = function(tree, text) -{ - mexui.Component.Entry.call(this, tree, 1); - - this.open = true; - this.text = text; - this.rows = []; -}; -mexui.util.extend(mexui.Entry.TreeRow, mexui.Component.Entry); - -// model -mexui.Entry.TreeRow.prototype.row = function(text) -{ - var entry = new mexui.Entry.TreeRow(this.control, text); - this.rows.push(entry); - return entry; -}; \ No newline at end of file diff --git a/third-party/mexui/Core/Init.js b/third-party/mexui/Core/Init.js deleted file mode 100644 index d19a6b89..00000000 --- a/third-party/mexui/Core/Init.js +++ /dev/null @@ -1,2 +0,0 @@ -mexui.init(); - diff --git a/third-party/mexui/Core/Native.js b/third-party/mexui/Core/Native.js deleted file mode 100644 index 55c24764..00000000 --- a/third-party/mexui/Core/Native.js +++ /dev/null @@ -1,154 +0,0 @@ -mexui.native = {}; - -// images -mexui.native.loadImage = function(imageFilePath, imageName) -{ - var file = openFile(imageFilePath); - if(!file) - { - console.log('ERROR [IMAGE LOAD] - Opening File: '+imageFilePath); - return false; - } - - var image = null; - var parts = imageFilePath.split('.'); - var ext = parts[parts.length - 1].toLowerCase(); - if(ext == 'png') - image = graphics.loadPNG(file); - else if(ext == 'bmp') - image = graphics.loadBMP(file); - else - { - console.log('ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.'); - return false; - } - - if(!image) - { - file.close(); - console.log('ERROR [IMAGE LOAD] - Reading File: '+imageFilePath); - return false; - } - - file.close(); - - if(imageName) - mexui.images[imageName] = image; - - return image; -}; - -// fonts -mexui.native.getFont = function(textSize, textFont) -{ - var textSizeStr = textSize + ''; - - if(!mexui.fonts[textSizeStr]) - { - mexui.fonts[textSizeStr] = {}; - } - - if(!mexui.fonts[textSizeStr][textFont]) - { - mexui.fonts[textSizeStr][textFont] = lucasFont.createDefaultFont(textSize, textFont); - } - - return mexui.fonts[textSizeStr][textFont]; -}; - -// text size -mexui.native.getTextSize = function(text, styles, font) -{ - if(!font) - font = mexui.native.getFont(styles.textSize, styles.textFont); - - var size = font.measure(text + '', 10000, styles.textAlign, 0.0, styles.textSize, false, false); - - //if(text[text.length - 1] == ' ') - // width += mexui.util.getStringCount(text, ' ') * spaceWidth; - - return size; -}; - -mexui.native.getTextWidth = function(text, styles, font) -{ - return mexui.native.getTextSize(text, styles, font).x; -}; - -mexui.native.getTextHeight = function(text, styles, font) -{ - return mexui.native.getTextSize(text, styles, font).y; -}; - -// render -mexui.native.drawRectangle = function(position, size, styles) -{ - mexui.native.drawRectangleBackground(position, size, styles); - mexui.native.drawRectangleBorder(position, size, styles); -}; - -mexui.native.drawRectangleBackground = function(position, size, styles) -{ - var backgroundColour = styles.backgroundColour != null ? styles.backgroundColour : styles.backgroundColor; - if(backgroundColour == null || backgroundColour == 'none') - return; - - graphics.drawRectangle(null, position, size, backgroundColour, backgroundColour, backgroundColour, backgroundColour); -}; - -mexui.native.drawRectangleBorder = function(position, size, styles) -{ - var borderColour = styles.borderColour || styles.borderColor; - if(borderColour == null || borderColour == 'none') - return; - - var rightXPosition = position.x + size.x; - var bottomYPosition = position.y + size.y; - - var topLeftPosition = new Vec2(position.x, position.y); - var topRightPosition = new Vec2(rightXPosition, position.y); - var bottomLeftPosition = new Vec2(position.x, bottomYPosition); - var bottomRightPosition = new Vec2(rightXPosition, bottomYPosition); - - var original = styles.lineColour; - - styles.lineColour = styles.topBorderColour != null ? styles.topBorderColour : (styles.topBorderColor != null ? styles.topBorderColor : borderColour); - mexui.native.drawAALine(topLeftPosition, topRightPosition, styles); - - styles.lineColour = styles.leftBorderColour != null ? styles.leftBorderColour : (styles.leftBorderColor != null ? styles.leftBorderColor : borderColour); - mexui.native.drawAALine(topLeftPosition, bottomLeftPosition, styles); - - styles.lineColour = styles.bottomBorderColour != null ? styles.bottomBorderColour : (styles.bottomBorderColor != null ? styles.bottomBorderColor : borderColour); - mexui.native.drawAALine(bottomLeftPosition, bottomRightPosition, styles); - - styles.lineColour = styles.rightBorderColour != null ? styles.rightBorderColour : (styles.rightBorderColor != null ? styles.rightBorderColor : borderColour); - mexui.native.drawAALine(topRightPosition, bottomRightPosition, styles); - - styles.lineColour = original; -}; - -mexui.native.drawAALine = function(point1, point2, styles) -{ - var lineColour = styles.lineColour != null ? styles.lineColour : styles.lineColor; - if(lineColour == null || lineColour == 'none') - return; - - graphics.drawRectangle(null, point1, new Vec2((point2.x - point1.x) + styles.lineWeight, (point2.y - point1.y) + styles.lineWeight), lineColour, lineColour, lineColour, lineColour); -}; - -mexui.native.drawText = function(position, size, text, styles) -{ - var font = mexui.native.getFont(styles.textSize, styles.textFont); - - var textHeight = mexui.native.getTextHeight(text, styles, font); - var textIndent = styles.textAlign == 0.0 || styles.textAlign == 1.0 ? styles.textIndent : 0; - var textPos = new Vec2(position.x + textIndent, position.y + ((size.y - textHeight) / 2.0)); - - font.render(text + '', textPos, size.x, styles.textAlign, 0.0, styles.textSize, styles.textColour != null ? styles.textColour : styles.textColor); -}; - -mexui.native.drawImage = function(position, size, image, styles) -{ - graphics.drawRectangle(image, position, size); -}; - diff --git a/third-party/mexui/Core/Utility.js b/third-party/mexui/Core/Utility.js deleted file mode 100644 index 052b4ea5..00000000 --- a/third-party/mexui/Core/Utility.js +++ /dev/null @@ -1,606 +0,0 @@ -mexui.util = {}; - -// static -mexui.util.monthNames = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; -mexui.util.weekDayNames = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; - -// functions -mexui.util.extend = function (d, b) { - d.prototype = Object.create(b.prototype); - d.prototype.constructor = b; -}; - -mexui.util.isPointInRectangle = function (point, position, size) { - if (!point) - return false; // temp bug fix - - return point.x >= position.x && point.y >= position.y && point.x <= (position.x + size.x) && point.y <= (position.y + size.y); -}; - -mexui.util.isCursorInRectangle = function (position, size) { - return mexui.util.isPointInRectangle(gui.cursorPosition, position, size); -}; - -mexui.util.addVec2 = function (vec2a, vec2b) { - return new Vec2(vec2a.x + vec2b.x, vec2a.y + vec2b.y); -}; - -mexui.util.subtractVec2 = function (vec2a, vec2b) { - return new Vec2(vec2a.x - vec2b.x, vec2a.y - vec2b.y); -}; - -mexui.util.addVec3 = function (vec3a, vec3b) { - return new Vec3(vec3a.x + vec3b.x, vec3a.y + vec3b.y, vec3a.z + vec3b.z); -}; - -mexui.util.createControlConstructor = function (controlName, hasEntries, constructor) { - mexui.Control[controlName] = constructor; - mexui.util.extend(mexui.Control[controlName], hasEntries ? mexui.Entity.ControlWithEntries : mexui.Component.Control); -}; - -mexui.util.linkBaseControlStyles = function (controlName, derivedStyles) { - mexui.Control[controlName].defaultStyles = mexui.util.linkStyles(mexui.Component.Control.defaultStyles, derivedStyles); -}; - -mexui.util.linkStyles = function (baseStyles, derivedStyles) { - derivedStyles = derivedStyles || {}; - - for (var k in baseStyles) { - switch (k) { - case 'focus': - case 'hover': - continue; - } - - if (!derivedStyles[k]) - derivedStyles[k] = {}; - if (!(derivedStyles[k].__proto__ instanceof Object)) - derivedStyles[k].__proto__ = baseStyles[k]; - - /* - var hoverBaseStyles = JSON.parse(JSON.stringify(baseStyles[k])); - if(!derivedStyles[k].hover) - derivedStyles[k].hover = {}; - if(!(derivedStyles[k].hover.__proto__ instanceof Object)) - derivedStyles[k].hover.__proto__ = hoverBaseStyles; - */ - } - - return mexui.util.linkGlobalStyles(mexui.Entity.StyleableEntity.globalDefaultStyles, derivedStyles); - //return derivedStyles; -}; - -mexui.util.linkGlobalStyles = function (baseStyles, derivedStyles) { - derivedStyles = derivedStyles || {}; - - for (var k in derivedStyles) { - switch (k) { - case 'focus': - case 'hover': - continue; - } - - if (!(derivedStyles[k].__proto__ instanceof Object)) { - derivedStyles[k].__proto__ = baseStyles.all; - } - } - - for (var k in derivedStyles) { - switch (k) { - case 'focus': - case 'hover': - continue; - } - - /* - if(!derivedStyles[k].hasOwnProperty('hover')) - { - derivedStyles[k].hover = {}; - derivedStyles[k].hover.__proto__ = derivedStyles[k]; - } - */ - - if (derivedStyles[k].focus) { - if (!(derivedStyles[k].focus.__proto__ instanceof Object)) { - derivedStyles[k].focus.__proto__ = baseStyles.all; - } - - if (derivedStyles[k].focus.hover) { - if (!(derivedStyles[k].focus.hover.__proto__ instanceof Object)) { - derivedStyles[k].focus.hover.__proto__ = baseStyles.all; - } - } - } - - if (derivedStyles[k].hover) { - if (!(derivedStyles[k].hover.__proto__ instanceof Object)) { - derivedStyles[k].hover.__proto__ = baseStyles.all; - } - } - } - - return derivedStyles; -}; - -String.prototype.repeat = function (count) { - return Array(count + 1).join(this); -}; - -mexui.util.isLetter = function (character) { - var ord = character.charCodeAt(0); - return (ord >= 65 && ord <= 90) || (ord >= 97 && ord <= 122); -}; - -mexui.util.isDigit = function (character) { - var ord = character.charCodeAt(0); - return ord >= 48 && ord <= 57; -}; - -mexui.util.isLetterOrDigit = function (character) { - return mexui.util.isLetter(character) || mexui.util.isDigit(character); -}; - -mexui.util.isCharacterInOctetRange = function (character, min, max) { - var ord = character.charCodeAt(0); - return ord >= min && ord <= max; -}; - -mexui.util.interpolateScalar = function (a, b, f) { - return a + ((b - a) * f); -}; - -mexui.util.doesContainEOLChar = function (text) { - return text.indexOf("\n") != -1 || text.indexOf("\r") != -1; -}; - -mexui.util.splitLines = function (text) { - text = text.replace("\r\n", "\n"); - text = text.replace("\r", "\n"); - return text.split("\n"); -}; - -mexui.util.getStringCount = function (text, find) { - var count = 0; - var index = 0; - for (; ;) { - index = text.indexOf(find, index); - if (index == -1) - break; - count++; - index += find.length; - } - return count; -}; - -mexui.util.stack = function () { - var err = new Error(); - console.log(err.stack); -}; - -mexui.util.deg = function (rad) { - return rad * (180 / Math.PI); -}; - -mexui.util.rad = function (deg) { - return deg * (Math.PI / 180); -}; - -mexui.util.round = function (x, n) { - return parseFloat(Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toFixed(n); -}; - -mexui.util.getCenterPosition = function (largerSize, smallerSize) { - return new Vec2( - (largerSize.x - smallerSize.x) / 2.0, - (largerSize.y - smallerSize.y) / 2.0 - ); -}; - -mexui.util.getWindowSize = function () { - return new Vec2(game.width, game.height); -}; - -mexui.util.isRectangleInsideRectangle = function (pos1, size1, pos2, size2) { - return !(pos2.x > (pos1.x + size1.x) || - (pos2.x + size2.x) < pos1.x || - pos2.y > (pos1.y + size1.y) || - (pos2.y + size2.y) < pos1.y); -}; - -mexui.util.mergeStyles = function (styles, pseudoPartNames) { - var styles3 = {}; - var styles2 = [styles]; - while (styles2[0]) { - styles2 = [styles2[0]]; - for (var i in pseudoPartNames) { - var pseudoPartName = pseudoPartNames[i]; - - if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) - styles2.push(styles2[0][pseudoPartName]); - } - - for (var i = styles2.length - 1; i >= 0; i--) { - if (styles2[i] == null) - continue; - - for (var k in styles2[i]) { - switch (k) { - case 'focus': - case 'hover': - - case 'transitionTime': - case 'transitionDelay': - - case 'transitionDelayStartTime': - case 'transitionStartTime': - case 'transitionStarted': - case 'transitionEnded': - case 'transitionReverting': - - continue; - } - if (styles2[i].hasOwnProperty(k) && styles3[k] == null) { - var styleValue = styles2[i][k]; - - /* - if(i > 0 && (styles2[i].transitionTime != null || styles2[i].transitionDelay != null)) - { - var timeNow = mexui.util.time(); - if(styles2[i].transitionReverting) - { - var transitionTime = styles2[i].transitionTime == null ? 400 : styles2[i].transitionTime; - var progress = (timeNow - styles2[i].transitionStartTime) / transitionTime; - if(progress > 1.0) - { - styles2[i].transitionEnded = true; - styleValue = styles2[0][k]; - - delete styles2[i].transitionDelayStartTime; - delete styles2[i].transitionStartTime; - delete styles2[i].transitionStarted; - delete styles2[i].transitionEnded; - delete styles2[i].transitionReverting; - } - else - { - styleValue = mexui.util.interpolateStyle(k, progress, styles2[i][k], styles2[0][k]); - } - } - else if(styles2[i].transitionEnded) - { - styleValue = styles2[i][k]; - } - else if(styles2[i].transitionStarted) - { - var transitionTime = styles2[i].transitionTime == null ? 400 : styles2[i].transitionTime; - var progress = (timeNow - styles2[i].transitionStartTime) / transitionTime; - if(progress > 1.0) - { - styles2[i].transitionEnded = true; - styleValue = styles2[i][k]; - } - else - { - styleValue = mexui.util.interpolateStyle(k, progress, styles2[0][k], styles2[i][k]); - } - } - else if(styles2[i].transitionDelayStartTime) - { - var transitionDelay = styles2[i].transitionDelay == null ? 0 : styles2[i].transitionDelay; - if(timeNow >= (styles2[i].transitionDelayStartTime + transitionDelay)) - { - styles2[i].transitionStarted = true; - styles2[i].transitionStartTime = timeNow; - styleValue = styles2[0][k]; - } - } - else - { - styles2[i].transitionDelayStartTime = timeNow; - styleValue = styles2[0][k]; - } - } - */ - - styles3[k] = styleValue; - } - } - } - - for (var i in styles2) { - if (styles2[i]) - styles2[i] = styles2[i].__proto__; - } - } - - return styles3; -}; - -mexui.util.getTransitionStyles = function (styles, pseudoPartNames, progress) { - var styles3 = {}; - var styles2 = [styles]; - while (styles2[0]) { - styles2 = [styles2[0]]; - for (var i in pseudoPartNames) { - var pseudoPartName = pseudoPartNames[i]; - - if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) - styles2.push(styles2[0][pseudoPartName]); - } - - for (var i = styles2.length - 1; i >= 0; i--) { - if (styles2[i] == null) - continue; - - for (var k in styles2[i]) { - switch (k) { - case 'focus': - case 'hover': - - case 'transitionTime': - case 'transitionDelay': - - continue; - } - if (styles2[i].hasOwnProperty(k) && styles3[k] == null) { - var styleValue = styles2[i][k]; - - if (i > 0) { - var mainStyleValue = styles2[0][k]; - var pseudoStyleValue = styles2[i][k]; - - //console.log(mainStyleValue+' '+pseudoStyleValue); - - styleValue = mexui.util.interpolateStyle(k, progress, mainStyleValue, pseudoStyleValue); - } - - styles3[k] = styleValue; - } - } - } - - for (var i in styles2) { - if (styles2[i]) - styles2[i] = styles2[i].__proto__; - } - } - - return styles3; -}; - -mexui.util.interpolateStyle = function (styleName, progress, styleValueFrom, styleValueTo) { - switch (styleName) { - case 'backgroundColour': - case 'backgroundColor': - case 'textColour': - case 'textColor': - case 'lineColour': - case 'lineColor': - case 'borderColour': - case 'borderColor': - if (styleValueFrom == 'none') - styleValueFrom = toColour(255, 255, 255, 0); - if (styleValueTo == 'none') - styleValueTo = toColour(255, 255, 255, 0); - return mexui.util.interpolateColour(progress, styleValueFrom, styleValueTo); - default: - return mexui.util.interpolateScalar(progress, styleValueFrom, styleValueTo); - } -}; - -mexui.util.interpolateColour = function (progress, styleValueFrom, styleValueTo) { - var rgbFrom = mexui.util.fromColour(styleValueFrom); - var rgbTo = mexui.util.fromColour(styleValueTo); - var rgba = []; - for (var i = 0; i < 4; i++) { - rgba[i] = mexui.util.interpolateScalar(progress, rgbFrom[i], rgbTo[i]); - } - return toColour.apply(null, rgba); -}; - -mexui.util.interpolateScalar = function (progress, valueFrom, valueTo) { - return valueFrom + ((valueTo - valueFrom) * progress); -}; - -mexui.util.fromColour = function (colour) { - return [ - (colour >> 16) & 0xFF, - (colour >> 8) & 0xFF, - colour & 0xFF, - (colour >> 24) & 0xFF - ]; -}; - -mexui.util.time = function () { - return sdl.ticks; -}; - -mexui.util.isIntChar = function (character) { - return mexui.util.isPositiveIntChar(character); -}; - -mexui.util.isPositiveIntChar = function (character) { - return mexui.util.isDigit(character) || character == '-' || character == '+' || character == 'e' || character == 'E'; -}; - -mexui.util.isFloatChar = function (character) { - return mexui.util.isIntChar(character) || character == '.'; -}; - -mexui.util.isPositiveFloatChar = function (character) { - return mexui.util.isPositiveIntChar(character) || character == '.'; -}; - -mexui.util.isInt = function (str) { - var strInt = parseInt(str); - return !isNaN(strInt) && str.length == (strInt + '').length; -}; - -mexui.util.isPositiveInt = function (str) { - var strInt = parseInt(str); - return !isNaN(strInt) && strInt >= 0 && str.length == (strInt + '').length; -}; - -mexui.util.isFloat = function (str) { - var strFloat = parseFloat(str); - var firstDot = str.indexOf('.'); - var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0; - if (firstDot == 0) - addOffset--; - return !isNaN(strFloat) && str.length == ((strFloat + '').length + addOffset); -}; - -mexui.util.isPositiveFloat = function (str) { - var strFloat = parseFloat(str); - var firstDot = str.indexOf('.'); - var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0; - if (firstDot == 0) - addOffset--; - return !isNaN(strFloat) && strFloat >= 0.0 && str.length == ((strFloat + '').length + addOffset); -}; - -mexui.util.isMonthName = function (text) { - return mexui.util.inArrayOrStartsWithInArray(text, mexui.util.monthNames, 3); -}; - -mexui.util.isWeekDayName = function (text) { - return mexui.util.inArrayOrStartsWithInArray(text, mexui.util.weekDayNames, 3); -}; - -mexui.util.isDayIdSuffix = function (text) { - switch (text.toLowerCase()) { - case 'st': - case 'nd': - case 'rd': - case 'th': - return true; - } - return false; -}; - -mexui.util.isDayIdSuffixForDayId = function (dayId, text) { - switch (text.toLowerCase()) { - case 'st': return dayId == 1 || dayId == 21 || dayId == 31; - case 'nd': return dayId == 2 || dayId == 22; - case 'rd': return dayId == 3 || dayId == 23; - case 'th': return !(dayId >= 1 && dayId <= 3) && !(dayId >= 21 && dayId <= 23) && dayId != 31; - default: return false; - } -}; - -mexui.util.isDayId = function (text) { - if (text.length == 2 && text.substr(0, 1) == '0') - text = text.substr(1); - - if (mexui.util.isPositiveInt(text)) { - var _int = parseInt(text); - if (_int >= 1 && _int <= 31) - return true; - } - - return false; -}; - -mexui.util.isDayIdWithOptionalSuffix = function (text) { - if (mexui.util.isDayId(text)) - return true; - - if (text.length > 2) { - var last2Chars = text.substr(text.length - 2, 2); - if (mexui.util.isDayIdSuffix(last2Chars)) { - var textWithoutLast2Chars = text.substr(0, text.length - 2); - if (mexui.util.isDayId(textWithoutLast2Chars) && mexui.util.isDayIdSuffixForDayId(parseInt(textWithoutLast2Chars), last2Chars)) { - return true; - } - } - } - - return false; -}; - -mexui.util.inArrayOrStartsWithInArray = function (text, arr, startsWithCharCount) { - text = text.toLowerCase(); - - for (var i in arr) { - if (text === arr[i]) { - return true; - } - } - - if (text.length == startsWithCharCount) { - for (var i in arr) { - if (text === arr[i].substr(0, startsWithCharCount)) { - return true; - } - } - } - - return false; -}; - -mexui.util.isMonthIdOrName = function (text) { - var text2 = text; - if (text2.length == 2 && text2.substr(0, 1) == '0') - text2 = text2.substr(1); - - if (mexui.util.isPositiveInt(text2)) { - var _int = parseInt(text2); - if (_int >= 1 && _int <= 12) - return true; - } - - return mexui.util.isMonthName(text); -}; - -mexui.util.isWeekDayId = function (text) { - var text2 = text; - if (text2.length == 2 && text2.substr(0, 1) == '0') - text2 = text2.substr(1); - - if (mexui.util.isPositiveInt(text2)) { - var _int = parseInt(text2); - if (_int >= 1 && _int <= 7) - return true; - } - - return false; -}; - -mexui.util.isWeekDayIdOrName = function (text) { - var text2 = text; - if (text2.length == 2 && text2.substr(0, 1) == '0') - text2 = text2.substr(1); - - if (mexui.util.isPositiveInt(text2)) { - var _int = parseInt(text2); - if (_int >= 1 && _int <= 7) - return true; - } - - return mexui.util.isWeekDayName(text); -}; - -mexui.util.expand2DigitYear = function (year, twoDigitYearCapOffset) { - var currentFullYear = new Date().getFullYear(); - var currentTwoDigitYearPlusCapOffset = parseInt((currentFullYear + '').substr(2, 2)) + twoDigitYearCapOffset; - if (year <= currentTwoDigitYearPlusCapOffset) - year += currentFullYear - (currentFullYear % 100); - else - year += (currentFullYear - (currentFullYear % 100)) - 100; - return year; -}; - -mexui.util.isYear = function (text, minYear, maxYear, twoDigitYearCapOffset) { - var _int = parseInt(text); - - if (isNaN(_int)) - return false; - - if (_int >= 0 && _int <= 99) - _int = mexui.util.expand2DigitYear(_int, twoDigitYearCapOffset); - - if (_int < minYear || _int > maxYear) - return false; - - return true; -}; \ No newline at end of file diff --git a/third-party/mexui/Images/down-arrow.png b/third-party/mexui/Images/down-arrow.png deleted file mode 100644 index 63fe7a5724d4ad5512a1f985ddc3cfb49215f943..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~%1|*NXY)uAIEa{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7?o@t7E1jyumPZ!4! z5AVHa9l06|1e^ok*RPe!QR!}+RJYNqI3L{4B~pp9)ugZcKogeQb@DpG9BkMwRpnM}SUa@O1TaS?83{ F1OQs7V*UUC diff --git a/third-party/mexui/mexui.js b/third-party/mexui/mexui.js deleted file mode 100644 index 186c3bf8..00000000 --- a/third-party/mexui/mexui.js +++ /dev/null @@ -1,257 +0,0 @@ -var mexui = {}; - -// data initialization -mexui.Entity = {}; -mexui.Component = {}; -mexui.Control = {}; -mexui.Entry = {}; - -mexui.windows = []; - -mexui.fonts = {}; -mexui.images = {}; - -mexui.focusedControl = null; -mexui.hoveredComponent = null; - -// initialization -mexui.init = function () { - mexui.native.loadImage('mexui/Images/down-arrow.png', 'downArrow'); - mexui.bindEvents(); - mexui.startTimers(); -}; - -// events -mexui.bindEvents = function () { - addEventHandler('onMouseDown', function (event, mouse, button) { - var e = mexui.triggerEvent('onMouseDown', { button: button }); - if (!e.clickedAControl) { - mexui.focusedControl = null; - } - }); - - addEventHandler('onMouseUp', function (event, mouse, button) { - mexui.triggerEvent('onMouseUp', { button: button }); - }); - - addEventHandler('onMouseMove', function (event, mouse, isAbsolute, position) { - if (isAbsolute) - return; - - mexui.triggerEvent('onMouseMove', new Vec2(position.x, position.y), true); - }); - - addEventHandler('onMouseWheel', function (event, mouse, offset, flipped) { - mexui.triggerEvent('onMouseWheel', offset); - }); - - addEventHandler('onKeyDown', function (event, key, pkey, mods) { - mexui.triggerEvent('onKeyDown', key, mods); - - if (key == SDLK_TAB) { - mexui.cycleFocusedControl(); - } - }); - - addEventHandler('onCharacter', function (event, character) { - mexui.triggerEvent('onCharacter', character); - - if (character == 't' || character == 'T') { - var textInput = mexui.getFocusedTextInput(); - if (textInput) { - //event.preventDefault(); - } - } - }); - - { - var eventName = (game.game == VRR_GAME_GTA_SA || game.game == VRR_GAME_MAFIA_ONE) ? 'onDrawnHUD' : 'onBeforeDrawHUD'; - addEventHandler(eventName, function (event) { - mexui.render(); - }); - } -}; - -mexui.unbindEvents = function () { - removeEventHandler('onMouseDown'); - removeEventHandler('onMouseUp'); - removeEventHandler('onMouseMove'); - removeEventHandler('onMouseWheel'); - removeEventHandler('onKeyDown'); - removeEventHandler('onCharacter'); - removeEventHandler('onBeforeDrawHUD'); -}; - -// timers -mexui.startTimers = function () { - setInterval(mexui.toggleTextInputCaretShownForBlink, 400); -}; - -// render -mexui.render = function () { - for (var i in mexui.windows) { - if (mexui.windows[i].shown) - mexui.windows[i].render.call(mexui.windows[i]); - } - for (var i in mexui.windows) { - if (mexui.windows[i].shown) - mexui.windows[i].renderAfter.call(mexui.windows[i]); - } -}; - -// model -mexui.triggerEvent = function (eventName, data, callBaseMethodFirst) { - var e = new mexui.Component.Event(); - - if (data.button !== undefined) - e.button = data.button; - - var windows = mexui.windows.slice(0, mexui.windows.length).reverse(); - for (var i in windows) { - if (windows[i].shown) { - if (callBaseMethodFirst) { - if (mexui.Entity.Component.prototype[eventName]) { - mexui.Entity.Component.prototype[eventName].call(windows[i], e, data); - if (e.used) - break; - } - - windows[i][eventName].call(windows[i], e, data); - if (e.used) - break; - } - else { - windows[i][eventName].call(windows[i], e, data); - if (e.used) - break; - - if (mexui.Entity.Component.prototype[eventName]) { - mexui.Entity.Component.prototype[eventName].call(windows[i], e, data); - if (e.used) - break; - } - } - } - } - return e; -}; - -mexui.getTopWindow = function () { - for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) { - if (mexui.windows[i].shown) - return mexui.windows[i]; - } - return null; -}; - -mexui.getShownWindows = function () { - var shownWindows = []; - for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) { - if (mexui.windows[i].shown) - shownWindows.push(mexui.windows[i]); - } - return shownWindows; -}; - -mexui.getNextShownWindows = function (afterWindow) { - var shownWindows = mexui.getShownWindows(); - - var windowIndex = shownWindows.indexOf(afterWindow); - - var windows2 = shownWindows.splice(0, windowIndex + 1); - var args = windows2; - args.unshift(0); - args.unshift(shownWindows.length); - shownWindows.splice.apply(shownWindows, args); - - return shownWindows; -}; - -mexui.cycleFocusedControl = function () { - // no windows are created - if (mexui.windows.length == 0) - return; - - // no control is focused - if (!mexui.focusedControl) { - var topWindow = mexui.getTopWindow(); - if (!topWindow) - return; - - mexui.focusedControl = topWindow.getFirstShownControl(); - return; - } - - // a control is focused - var focusedControlWindow = mexui.focusedControl.window; - var nextControl = focusedControlWindow.getNextShownControl(mexui.focusedControl); - if (nextControl) { - mexui.focusedControl = nextControl; - return; - } - - // set focus to first control on next window that has a control shown - var shownWindows = mexui.getNextShownWindows(focusedControlWindow); - for (var i in shownWindows) { - var window = shownWindows[i]; - var firstControl = window.getFirstShownControl(); - if (firstControl) { - mexui.focusedControl = firstControl; - return; - } - } -}; - -mexui.getFocusedTextInput = function () { - if (!mexui.focusedControl) - return null; - - if (!(mexui.focusedControl instanceof mexui.Control.TextInput)) - return null; - - return mexui.focusedControl; -}; - -mexui.toggleTextInputCaretShownForBlink = function () { - var textInput = mexui.getFocusedTextInput(); - if (!textInput) - return; - - textInput.caretShownForBlink = !textInput.caretShownForBlink; -}; - -mexui.setHoveredComponent = function (component) { - //component.hovered = true; - mexui.hoveredComponent = component; -}; - -mexui.clearHoveredComponent = function () { - //mexui.hoveredComponent.hovered = false; - mexui.hoveredComponent = null; -}; - -// api -mexui.window = function (x, y, w, h, title, styles) { - var window = new mexui.Component.Window(x, y, w, h, title, styles); - mexui.windows.push(window); - return window; -}; - -mexui.isAnyWindowShown = function () { - for (var i in mexui.windows) { - if (mexui.windows[i].shown) - return true; - } - return false; -}; - -mexui.setInput = function (showInput) { - gui.showCursor(showInput, !showInput); - - if (localClient.player && game.game >= GAME_GTA_IV) { - if (showInput) - game.setCameraLookAtEntity(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer, false); - else - game.restoreCamera(false); - } -};