Tons of Emote/Emoji changes

This commit is contained in:
Zach Fox 2019-08-23 14:14:53 -07:00
parent 86518d222d
commit dfcf70b9b5
24 changed files with 148 additions and 54 deletions

View file

@ -3562,6 +3562,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona
surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data());
surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
surfaceContext->setContextProperty("module", "");
}
}

View file

@ -225,6 +225,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
QObject::connect(_dockWidget.get(), SIGNAL(onResizeEvent()), this, SLOT(emitMainWindowResizeEvent()));
_dockWidget->setSource(QUrl(sourceUrl));
_dockWidget->setObjectName("DockedWidget");
mainWindow->addDockWidget(dockArea, _dockWidget.get());
} else {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
@ -283,6 +284,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) {
sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString();
}
object->setObjectName("InteractiveWindow");
object->setProperty(SOURCE_PROPERTY, sourceURL);
});
}

View file

@ -8,10 +8,7 @@ var customEmojiList = [
]
}
]
try {
if (module) {
module.exports = customEmojiList;
}
} catch (e) {
console.log("error exporting:\n", e);
if (module.exports) {
module.exports = customEmojiList;
}

View file

@ -38734,10 +38734,7 @@ var emojiList = [
}
}
]
try {
if (module) {
module.exports = emojiList;
}
} catch (e) {
console.log("error exporting:\n", e);
if (module.exports) {
module.exports = emojiList;
}

View file

@ -102,7 +102,6 @@ function startTimeoutDelete() {
// The QML has a property called archEnd on the pie chart that controls how much pie is showing
var COUNT_DOWN_INTERVAL_MS = 100;
function beginCountDownTimer() {
_this._avimojiQMLWindow.sendToQml({
"source": "simplifiedEmoji.js",
@ -128,9 +127,9 @@ function resetEmojis() {
clearCountDownTimerHandler();
if (currentEmoji) {
Entities.deleteEntity(currentEmoji);
currentEmoji = false;
selectedEmojiFilename = null;
}
currentEmoji = false;
selectedEmojiFilename = null;
}
@ -360,11 +359,11 @@ function playPopAnimation() {
Entities.editEntity(currentEmoji, {"dimensions": dimensions});
}
} else {
// make sure there is a currentEmoji entity before trying to delete
pruneOldAvimojis();
if (currentEmoji) {
Entities.deleteEntity(currentEmoji);
currentEmoji = false;
}
currentEmoji = false;
finalInPopScale = null;
selectedEmojiFilename = null;
clearCountDownTimerHandler();

View file

@ -31,6 +31,9 @@ Rectangle {
// if this is true, then hovering doesn't allow showing other icons
property bool isSelected: false
KeyNavigation.backtab: emojiSearchTextField
KeyNavigation.tab: emojiSearchTextField
// Update the selected emoji image whenever the code property is changed.
onCurrentCodeChanged: {
mainEmojiImage.source = emojiBaseURL + currentCode;
@ -209,6 +212,18 @@ Rectangle {
}
}
}
// If this MouseArea is hit, the user is clicking on an area not handled
// by any other MouseArea
MouseArea {
anchors.fill: parent
onClicked: {
// The grid will forward keypresses to the main Interface window
grid.forceActiveFocus();
// Necessary to get keyboard keyPress/keyRelease forwarding to work. See `Application::hasFocus()`;
Window.setFocus();
}
}
Rectangle {
id: emojiIndicatorContainer
@ -302,6 +317,7 @@ Rectangle {
MouseArea {
hoverEnabled: enabled
anchors.fill: parent
propagateComposedEvents: false
onEntered: {
grid.currentIndex = index
// don't allow a hover image change of the main emoji image
@ -313,6 +329,10 @@ Rectangle {
}
onClicked: {
root.selectEmoji(model.code.utf);
// The grid will forward keypresses to the main Interface window
grid.forceActiveFocus();
// Necessary to get keyboard keyPress/keyRelease forwarding to work. See `Application::hasFocus()`;
Window.setFocus();
}
}
}
@ -330,6 +350,10 @@ Rectangle {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.selectEmoji(grid.model.get(grid.currentIndex).code.utf);
}
root.keyPressEvent(event.key, event.modifiers);
}
Keys.onReleased: {
root.keyReleaseEvent(event.key, event.modifiers);
}
}
@ -429,6 +453,7 @@ Rectangle {
id: attributionMouseArea
hoverEnabled: enabled
anchors.fill: parent
propagateComposedEvents: false
onClicked: {
popupContainer.visible = true;
}
@ -458,8 +483,15 @@ Rectangle {
}
}
signal sendToScript(var message);
signal sendToScript(var message)
signal keyPressEvent(int key, int modifiers)
signal keyReleaseEvent(int key, int modifiers)
Keys.onPressed: {
root.keyPressEvent(event.key, event.modifiers);
}
Keys.onReleased: {
root.keyReleaseEvent(event.key, event.modifiers);
}
function fromScript(message) {
if (message.source !== "simplifiedEmoji.js") {

View file

@ -127,14 +127,51 @@ function getSounds() {
}
// Returns the first valid joint position from the list of supplied test joint positions.
// If none are valid, returns MyAvatar.position.
function getValidJointPosition(jointsToTest) {
var currentJointIndex;
for (var i = 0; i < jointsToTest.length; i++) {
currentJointIndex = MyAvatar.getJointIndex(jointsToTest[i]);
if (currentJointIndex > -1) {
return MyAvatar.getJointPosition(jointsToTest[i]);
}
}
return Vec3.sum(MyAvatar.position, Vec3.multiply(0.25, Quat.getForward(MyAvatar.orientation)));
}
// Returns the world position halfway between the user's hands
var HALF = 0.5;
function getClapPosition() {
var validLeftJoints = ["LeftHandMiddle2", "LeftHand", "LeftArm"];
var leftPosition = getValidJointPosition(validLeftJoints);
var validRightJoints = ["RightHandMiddle2", "RightHand", "RightArm"];;
var rightPosition = getValidJointPosition(validRightJoints);
var centerPosition = Vec3.sum(leftPosition, rightPosition);
centerPosition = Vec3.multiply(centerPosition, HALF);
return centerPosition;
}
var clapSoundInterval = false;
var CLAP_SOUND_INTERVAL_MS = 260; // Must match the clap animation interval
var CLAP_SOUND_INTERVAL_MS_FLOOR = 260;
var CLAP_SOUND_INTERVAL_MS_CEIL = 320;
function startClappingSounds() {
maybeClearClapSoundInterval();
// Compute a random clap sound interval to avoid strange echos between many people clapping simultaneously
var clapSoundIntervalMS = Math.floor(randomFloat(CLAP_SOUND_INTERVAL_MS_FLOOR, CLAP_SOUND_INTERVAL_MS_CEIL));
clapSoundInterval = Script.setInterval(function() {
playSound(clapSounds[Math.floor(Math.random() * clapSounds.length)], MyAvatar.position, true);
}, CLAP_SOUND_INTERVAL_MS);
playSound(clapSounds[Math.floor(Math.random() * clapSounds.length)], getClapPosition(), true);
}, clapSoundIntervalMS);
}
@ -151,10 +188,8 @@ function toggleReaction(reaction) {
if (reactionEnding) {
endReactionWrapper(reaction);
updateEmoteIndicatorIcon("images/emote_Icon.svg");
} else {
beginReactionWrapper(reaction);
updateEmoteIndicatorIcon("images/" + reaction + "_Icon.svg");
}
}
@ -169,6 +204,8 @@ function beginReactionWrapper(reaction) {
if (MyAvatar.beginReaction(reaction)) {
reactionsBegun.push(reaction);
}
updateEmoteIndicatorIcon("images/" + reaction + "_Icon.svg");
// Insert reaction-specific logic here:
switch (reaction) {
@ -235,10 +272,10 @@ function mouseMoveEvent(event) {
Entities.editEntity(pointReticle, { position: reticlePosition });
} else if (reticlePosition) {
pointReticle = Entities.addEntity({
type: "Sphere",
type: "Box",
name: "Point Reticle",
position: reticlePosition,
dimensions: { x: 0.1, y: 0.1, z: 0.1 },
dimensions: { x: 0.075, y: 0.075, z: 0.075 },
color: { red: 255, green: 0, blue: 0 },
collisionless: true,
ignorePickIntersection: true,
@ -275,6 +312,8 @@ function endReactionWrapper(reaction) {
reactionsBegun.splice(reactionsBegunIndex, 1);
}
}
updateEmoteIndicatorIcon("images/emote_Icon.svg");
// Insert reaction-specific logic here:
switch (reaction) {
@ -301,19 +340,35 @@ function onMessageFromEmoteAppBar(message) {
}
switch (message.method) {
case "positive":
if (!message.data.isPressingAndHolding) {
return;
}
triggerReactionWrapper("positive");
updateEmoteIndicatorIcon("images/" + message.method + "_Icon.svg");
break;
case "negative":
if (!message.data.isPressingAndHolding) {
return;
}
triggerReactionWrapper("negative");
updateEmoteIndicatorIcon("images/" + message.method + "_Icon.svg");
break;
case "raiseHand":
case "applaud":
if (message.data.isPressingAndHolding) {
beginReactionWrapper(message.method);
} else {
endReactionWrapper(message.method);
}
break;
case "point":
case "raiseHand":
if (!message.data.isPressingAndHolding) {
return;
}
toggleReaction(message.method);
break;
case "toggleEmojiApp":
if (!message.data.isPressingAndHolding) {
return;
}
toggleEmojiApp();
break;
default:
@ -363,8 +418,8 @@ function onWindowMinimizedChanged(isMinimized) {
// for the tooltips to match the actual keys.
var POSITIVE_KEY = "z";
var NEGATIVE_KEY = "x";
var RAISE_HAND_KEY = "c";
var APPLAUD_KEY = "v";
var APPLAUD_KEY = "c";
var RAISE_HAND_KEY = "v";
var POINT_KEY = "b";
var EMOTE_WINDOW = "f";
function keyPressHandler(event) {
@ -383,7 +438,7 @@ function keyPressHandler(event) {
toggleReaction("applaud");
} else if (event.text === POINT_KEY) {
toggleReaction("point");
} else if (event.text === EMOTE_WINDOW) {
} else if (event.text === EMOTE_WINDOW && !(Settings.getValue("io.highfidelity.isEditing", false))) {
toggleEmojiApp();
}
}
@ -392,18 +447,10 @@ function keyPressHandler(event) {
function keyReleaseHandler(event) {
if (!event.isAutoRepeat) {
if (event.text === RAISE_HAND_KEY) {
if (reactionsBegun.indexOf("raiseHand") > -1) {
toggleReaction("raiseHand");
}
} else if (event.text === APPLAUD_KEY) {
if (event.text === APPLAUD_KEY) {
if (reactionsBegun.indexOf("applaud") > -1) {
toggleReaction("applaud");
}
} else if (event.text === POINT_KEY) {
if (reactionsBegun.indexOf("point") > -1) {
toggleReaction("point");
}
}
}
}
@ -657,7 +704,6 @@ var EMOJI_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window
0x00008000 | // Qt::WindowMaximizeButtonHint
0x00004000; // Qt::WindowMinimizeButtonHint
var emojiAppWindow = false;
var POPOUT_SAFE_MARGIN_X = 30;
var POPOUT_SAFE_MARGIN_Y = 30;
var emojiAppWindowSignalsConnected = false;
function toggleEmojiApp() {
@ -678,7 +724,7 @@ function toggleEmojiApp() {
y: EMOJI_APP_HEIGHT_PX
},
position: {
x: Math.max(Window.x + POPOUT_SAFE_MARGIN_X, Window.x + Window.innerWidth / 2 - EMOJI_APP_WIDTH_PX / 2),
x: Window.x + EMOTE_APP_BAR_LEFT_MARGIN,
y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - EMOJI_APP_HEIGHT_PX / 2)
},
overrideFlags: EMOJI_APP_WINDOW_FLAGS

View file

@ -171,8 +171,8 @@ Rectangle {
id: buttonsModel
ListElement { imageURL: "images/positive_Icon.svg"; hotkey: "Z"; method: "positive" }
ListElement { imageURL: "images/negative_Icon.svg"; hotkey: "X"; method: "negative" }
ListElement { imageURL: "images/raiseHand_Icon.svg"; hotkey: "C"; method: "raiseHand" }
ListElement { imageURL: "images/applaud_Icon.svg"; hotkey: "V"; method: "applaud" }
ListElement { imageURL: "images/applaud_Icon.svg"; hotkey: "C"; method: "applaud" }
ListElement { imageURL: "images/raiseHand_Icon.svg"; hotkey: "V"; method: "raiseHand" }
ListElement { imageURL: "images/point_Icon.svg"; hotkey: "B"; method: "point" }
ListElement { imageURL: "images/emote_Icon.svg"; hotkey: "F"; method: "toggleEmojiApp" }
}
@ -211,7 +211,7 @@ Rectangle {
opacity: 0.8
radius: 4
HifiStylesUit.GraphikRegular {
HifiStylesUit.GraphikSemiBold {
id: toolTipText
anchors.left: parent.left
anchors.leftMargin: 2
@ -222,7 +222,7 @@ Rectangle {
verticalAlignment: TextInput.AlignBottom
horizontalAlignment: TextInput.AlignLeft
color: simplifiedUI.colors.text.white
size: 22
size: 20
}
}
@ -230,17 +230,37 @@ Rectangle {
id: emoteTrayMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
Tablet.playSound(TabletEnums.ButtonClick);
sendToScript({
"source": "EmoteAppBar.qml",
"method": model.method
});
}
onEntered: {
Tablet.playSound(TabletEnums.ButtonHover);
}
onPressed: {
Tablet.playSound(TabletEnums.ButtonClick);
sendToScript({
"source": "EmoteAppBar.qml",
"method": model.method,
"data": { "isPressingAndHolding": true }
});
}
onReleased: {
sendToScript({
"source": "EmoteAppBar.qml",
"method": model.method,
"data": { "isPressingAndHolding": false }
});
}
onExited: {
if (pressed) {
sendToScript({
"source": "EmoteAppBar.qml",
"method": model.method,
"data": { "isPressingAndHolding": false }
});
}
}
}
}
}