MexUI stuff

This commit is contained in:
Vortrex
2022-05-15 22:26:31 -05:00
parent c81f511448
commit 4b7f05a482
42 changed files with 423 additions and 398 deletions

View File

@@ -131,3 +131,4 @@ mexui.Component.Control.prototype.unbind = function()
{ {
this.boundTo = null; this.boundTo = null;
}; };

View File

@@ -29,3 +29,4 @@ mexui.Component.Entry.prototype.remove = function()
this.control.axis[this.getAxisKey()].entries.splice(this.getEntryIndex(), 1); this.control.axis[this.getAxisKey()].entries.splice(this.getEntryIndex(), 1);
this.control.checkToShowScrollBars(); this.control.checkToShowScrollBars();
}; };

View File

@@ -3,3 +3,4 @@ mexui.Component.Event = function()
this.used = false; this.used = false;
this.clickedAControl = false; this.clickedAControl = false;
}; };

View File

@@ -355,7 +355,7 @@ mexui.Component.Window.prototype.digits = function(x, y, w, h, text, styles, c
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.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.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.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) { return this.addControl(new mexui.Control.Image(this, x, y, w, h, filePath, styles)); }; 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.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.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.letters = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Letters(this, x, y, w, h, text, styles, callback)); };
@@ -386,3 +386,4 @@ mexui.Component.Window.prototype.tree = function(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.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.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)); }; 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)); };

View File

@@ -127,3 +127,4 @@ mexui.Control.Grid.prototype.getAllEntriesLength = function(axisIndex)
return this.axis.y.getAllEntriesLength2(); return this.axis.y.getAllEntriesLength2();
} }
}; };

View File

@@ -1,6 +1,6 @@
mexui.util.createControlConstructor('Image', false, function(window, x, y, w, h, filePath, styles) 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)); mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Image', styles), callback);
this.image = mexui.native.loadImage(filePath); this.image = mexui.native.loadImage(filePath);
}); });
@@ -8,6 +8,25 @@ mexui.util.createControlConstructor('Image', false, function(window, x, y, w, h,
// default styles // default styles
mexui.util.linkBaseControlStyles('Image', {}); 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 // render
mexui.Control.Image.prototype.render = function() mexui.Control.Image.prototype.render = function()
{ {
@@ -18,13 +37,3 @@ mexui.Control.Image.prototype.render = function()
if(this.isFocused()) 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.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
}; };
// input
mexui.Control.Image.prototype.onMouseDown = function(e)
{
if(e.button == 0 && this.isCursorOverControl())
{
e.used = true;
this.checkToCallCallback();
}
};

View File

@@ -59,3 +59,4 @@ mexui.Control.List.prototype.row = function(text)
this.axis.y.addEntry(entry); this.axis.y.addEntry(entry);
return entry; return entry;
}; };

View File

@@ -113,3 +113,4 @@ mexui.Control.Slider.prototype.clampProgress = function()
else if(this.progress > 1.0) else if(this.progress > 1.0)
this.progress = 1.0; this.progress = 1.0;
}; };

View File

@@ -153,3 +153,4 @@ mexui.Control.Tree.prototype.row = function(text)
this.axis.y.addEntry(entry); this.axis.y.addEntry(entry);
return entry; return entry;
}; };

View File

@@ -197,3 +197,4 @@ mexui.Entity.ControlAxis.prototype.getDisplayedEntryCount = function()
var displayedEntryCount = Math.floor(displayedEntriesLength / this.control.entrySize[this.axisIndex]); var displayedEntryCount = Math.floor(displayedEntriesLength / this.control.entrySize[this.axisIndex]);
return this.entries.length < displayedEntryCount ? this.entries.length : displayedEntryCount; return this.entries.length < displayedEntryCount ? this.entries.length : displayedEntryCount;
}; };

View File

@@ -95,3 +95,4 @@ mexui.Entity.ControlWithEntries.prototype.removeAllEntries = function()
this.axis.x.removeAllEntries(); this.axis.x.removeAllEntries();
this.axis.y.removeAllEntries(); this.axis.y.removeAllEntries();
}; };

View File

@@ -207,3 +207,4 @@ mexui.Entity.StyleableEntity.prototype.getTransitionTimeStyle = function(control
else else
return mexui.Entity.Transition.defaultTransitionTime; return mexui.Entity.Transition.defaultTransitionTime;
}; };

View File

@@ -181,3 +181,4 @@ mexui.Entity.Transition.prototype.clearDelayTimer = function()
clearTimeout(this.delayTimer); clearTimeout(this.delayTimer);
this.delayTimer = null; this.delayTimer = null;
}; };

View File

@@ -10,3 +10,4 @@ mexui.util.extend(mexui.Entry.GridRow, mexui.Component.Entry);
// default styles // default styles
mexui.Entry.GridRow.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, {}); mexui.Entry.GridRow.defaultStyles = mexui.util.linkStyles(mexui.Entity.StyleableEntity.defaultStyles, {});

View File

@@ -6,7 +6,7 @@ mexui.native.loadImage = function(imageFilePath, imageName)
var file = openFile(imageFilePath); var file = openFile(imageFilePath);
if(!file) if(!file)
{ {
logToConsole(LOG_DEBUG|LOG_ERROR, 'ERROR [IMAGE LOAD] - Opening File: '+imageFilePath); console.log('ERROR [IMAGE LOAD] - Opening File: '+imageFilePath);
return false; return false;
} }
@@ -14,19 +14,19 @@ mexui.native.loadImage = function(imageFilePath, imageName)
var parts = imageFilePath.split('.'); var parts = imageFilePath.split('.');
var ext = parts[parts.length - 1].toLowerCase(); var ext = parts[parts.length - 1].toLowerCase();
if(ext == 'png') if(ext == 'png')
image = drawing.loadPNG(file); image = graphics.loadPNG(file);
else if(ext == 'bmp') else if(ext == 'bmp')
image = drawing.loadBMP(file); image = graphics.loadBMP(file);
else else
{ {
logToConsole(LOG_DEBUG|LOG_ERROR, 'ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.'); console.log('ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.');
return false; return false;
} }
if(!image) if(!image)
{ {
file.close(); file.close();
logToConsole(LOG_DEBUG|LOG_ERROR, 'ERROR [IMAGE LOAD] - Reading File: '+imageFilePath); console.log('ERROR [IMAGE LOAD] - Reading File: '+imageFilePath);
return false; return false;
} }
@@ -93,7 +93,7 @@ mexui.native.drawRectangleBackground = function(position, size, styles)
if(backgroundColour == null || backgroundColour == 'none') if(backgroundColour == null || backgroundColour == 'none')
return; return;
drawing.drawRectangle(null, position, size, backgroundColour, backgroundColour, backgroundColour, backgroundColour); graphics.drawRectangle(null, position, size, backgroundColour, backgroundColour, backgroundColour, backgroundColour);
}; };
mexui.native.drawRectangleBorder = function(position, size, styles) mexui.native.drawRectangleBorder = function(position, size, styles)
@@ -133,7 +133,7 @@ mexui.native.drawAALine = function(point1, point2, styles)
if(lineColour == null || lineColour == 'none') if(lineColour == null || lineColour == 'none')
return; return;
drawing.drawRectangle(null, point1, new Vec2((point2.x - point1.x) + styles.lineWeight, (point2.y - point1.y) + styles.lineWeight), lineColour, lineColour, lineColour, lineColour); 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) mexui.native.drawText = function(position, size, text, styles)
@@ -149,5 +149,6 @@ mexui.native.drawText = function(position, size, text, styles)
mexui.native.drawImage = function(position, size, image, styles) mexui.native.drawImage = function(position, size, image, styles)
{ {
drawing.drawRectangle(image, position, size); graphics.drawRectangle(image, position, size);
}; };

View File

@@ -236,7 +236,7 @@ mexui.util.getCenterPosition = function(largerSize, smallerSize)
mexui.util.getWindowSize = function() mexui.util.getWindowSize = function()
{ {
return new Vec2(game.width, game.height); return new Vec2(gta.width, gta.height);
}; };
mexui.util.isRectangleInsideRectangle = function(pos1, size1, pos2, size2) mexui.util.isRectangleInsideRectangle = function(pos1, size1, pos2, size2)
@@ -476,7 +476,7 @@ mexui.util.fromColour = function(colour)
mexui.util.time = function() mexui.util.time = function()
{ {
return sdl.tickCount; return gta.tickCount;
}; };
mexui.util.isIntChar = function(character) mexui.util.isIntChar = function(character)

View File

@@ -17,7 +17,7 @@ mexui.hoveredComponent = null;
// initialization // initialization
mexui.init = function() mexui.init = function()
{ {
mexui.native.loadImage('third-party/mexui/Images/down-arrow.png', 'downArrow'); mexui.native.loadImage('mexui/Images/down-arrow.png', 'downArrow');
mexui.bindEvents(); mexui.bindEvents();
mexui.startTimers(); mexui.startTimers();
}; };
@@ -76,10 +76,13 @@ mexui.bindEvents = function()
} }
}); });
addEventHandler('onDrawnHUD', function(event) {
var eventName = gta.game == GAME_GTA_SA ? 'onDrawnHUD' : 'onBeforeDrawHUD';
addEventHandler(eventName, function(event)
{ {
mexui.render(); mexui.render();
}); });
}
}; };
mexui.unbindEvents = function() mexui.unbindEvents = function()
@@ -90,7 +93,7 @@ mexui.unbindEvents = function()
removeEventHandler('onMouseWheel'); removeEventHandler('onMouseWheel');
removeEventHandler('onKeyDown'); removeEventHandler('onKeyDown');
removeEventHandler('onCharacter'); removeEventHandler('onCharacter');
removeEventHandler('onDrawnHUD'); removeEventHandler('onBeforeDrawHUD');
}; };
// timers // timers
@@ -287,13 +290,12 @@ mexui.isAnyWindowShown = function()
mexui.setInput = function(showInput) mexui.setInput = function(showInput)
{ {
gui.showCursor(showInput, !showInput); gui.showCursor(showInput, !showInput);
//if(game.game != VRR_GAME_GTA_IV) { if(localClient.player && gta.game != GAME_GTA_IV)
// if(localPlayer) {
// { if(showInput)
// if(showInput) gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false);
// game.setCameraLookAt(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer.position, false); else
// else gta.restoreCamera(false);
// game.restoreCamera(false); }
// }
//}
}; };