MexUI stuff
This commit is contained in:
66
third-party/mexui/mexui.js
vendored
66
third-party/mexui/mexui.js
vendored
@@ -17,7 +17,7 @@ mexui.hoveredComponent = null;
|
||||
// initialization
|
||||
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.startTimers();
|
||||
};
|
||||
@@ -43,7 +43,7 @@ mexui.bindEvents = function()
|
||||
{
|
||||
if(isAbsolute)
|
||||
return;
|
||||
|
||||
|
||||
mexui.triggerEvent('onMouseMove', new Vec2(position.x, position.y), true);
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ mexui.bindEvents = function()
|
||||
addEventHandler('onKeyDown', function(event, key, pkey, mods)
|
||||
{
|
||||
mexui.triggerEvent('onKeyDown', key, mods);
|
||||
|
||||
|
||||
if(key == SDLK_TAB)
|
||||
{
|
||||
mexui.cycleFocusedControl();
|
||||
@@ -65,7 +65,7 @@ mexui.bindEvents = function()
|
||||
addEventHandler('onCharacter', function(event, character)
|
||||
{
|
||||
mexui.triggerEvent('onCharacter', character);
|
||||
|
||||
|
||||
if(character == 't' || character == 'T')
|
||||
{
|
||||
var textInput = mexui.getFocusedTextInput();
|
||||
@@ -75,11 +75,14 @@ mexui.bindEvents = function()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addEventHandler('onDrawnHUD', function(event)
|
||||
|
||||
{
|
||||
mexui.render();
|
||||
});
|
||||
var eventName = gta.game == GAME_GTA_SA ? 'onDrawnHUD' : 'onBeforeDrawHUD';
|
||||
addEventHandler(eventName, function(event)
|
||||
{
|
||||
mexui.render();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
mexui.unbindEvents = function()
|
||||
@@ -90,7 +93,7 @@ mexui.unbindEvents = function()
|
||||
removeEventHandler('onMouseWheel');
|
||||
removeEventHandler('onKeyDown');
|
||||
removeEventHandler('onCharacter');
|
||||
removeEventHandler('onDrawnHUD');
|
||||
removeEventHandler('onBeforeDrawHUD');
|
||||
};
|
||||
|
||||
// timers
|
||||
@@ -118,10 +121,10 @@ mexui.render = function()
|
||||
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)
|
||||
{
|
||||
@@ -135,7 +138,7 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst)
|
||||
if(e.used)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
windows[i][eventName].call(windows[i], e, data);
|
||||
if(e.used)
|
||||
break;
|
||||
@@ -145,7 +148,7 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst)
|
||||
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);
|
||||
@@ -182,15 +185,15 @@ mexui.getShownWindows = function()
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -199,18 +202,18 @@ 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);
|
||||
@@ -219,7 +222,7 @@ mexui.cycleFocusedControl = function()
|
||||
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)
|
||||
@@ -238,10 +241,10 @@ mexui.getFocusedTextInput = function()
|
||||
{
|
||||
if(!mexui.focusedControl)
|
||||
return null;
|
||||
|
||||
|
||||
if(!(mexui.focusedControl instanceof mexui.Control.TextInput))
|
||||
return null;
|
||||
|
||||
|
||||
return mexui.focusedControl;
|
||||
};
|
||||
|
||||
@@ -250,7 +253,7 @@ mexui.toggleTextInputCaretShownForBlink = function()
|
||||
var textInput = mexui.getFocusedTextInput();
|
||||
if(!textInput)
|
||||
return;
|
||||
|
||||
|
||||
textInput.caretShownForBlink = !textInput.caretShownForBlink;
|
||||
};
|
||||
|
||||
@@ -287,13 +290,12 @@ mexui.isAnyWindowShown = function()
|
||||
mexui.setInput = function(showInput)
|
||||
{
|
||||
gui.showCursor(showInput, !showInput);
|
||||
//if(game.game != VRR_GAME_GTA_IV) {
|
||||
// if(localPlayer)
|
||||
// {
|
||||
// if(showInput)
|
||||
// game.setCameraLookAt(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer.position, false);
|
||||
// else
|
||||
// game.restoreCamera(false);
|
||||
// }
|
||||
//}
|
||||
if(localClient.player && gta.game != GAME_GTA_IV)
|
||||
{
|
||||
if(showInput)
|
||||
gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false);
|
||||
else
|
||||
gta.restoreCamera(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user