I've got a simple bot game I'm developing. It has a Root Dialog, which can take you to two others - A Start Dialog and a Join Dialog.
Join Dialog can lead to the Play Game Dialog, which when the game is over leads you to a Score Dialog.
Feels like a lot bot (sic) but it runs smoothly. When scoring is done, I'd like to get back to the Root Dialog for another round.
But I'm stuck.
Even though I issue both an EndDialog() activity and a CodeAction() activity that simply calls DialogContext.CancelAllDialogs(), I remain within what looks like the EndDialog and therefore I don't get back to Root.
Thus, I can't restart my game.
Is there something I'm missing? I'm using both Adaptive Dialogs as well as Adaptive Cards and Hero Cards. Although, I don't think the cards should matter.
So, this is what I ended up doing to get what I want. It might not be the best way, but it works:
I created a CodeAction dialog that runs when the message I want to trigger a round restart to come in - there's a specific intent that is tied to that.
The CodeAction calls this method:
private async Task<DialogTurnResult> CancelAndReturnToRoot(DialogContext dc, object options)
{
var lastDialog = dc;
var secondToLastDialog = lastDialog;
var journeysUp = 1;
while (lastDialog != null)
{
lastDialog = lastDialog.Parent;
if (lastDialog != null)
secondToLastDialog = lastDialog;
journeysUp++;
}
return await secondToLastDialog.CancelAllDialogsAsync();
}
This seems to release the dialogs that I created and let me get back to the beginning dialog.
Related
Last time I was doing optimizations (maybe a year ago), I was able to see all possible function calls in the js flamechart.
Now, however, it doesn't seem to go all the way.
Here's a long running function:
I'm expecting way more sub-calls so that I may understand why is it running so long.
Here's how that function looks like:
function updateIfNeeded() {
switch (state) {
case 'NO_REQUEST':
throw new Error('Unexpected draw callback.\n' + 'Please report this to <https://github.com/elm-lang/virtual-dom/issues>.');
case 'PENDING_REQUEST':
rAF(updateIfNeeded);
state = 'EXTRA_REQUEST';
var nextNode = view(nextModel);
var patches = diff(currNode, nextNode);
domNode = applyPatches(domNode, currNode, patches, eventNode);
currNode = nextNode;
return;
case 'EXTRA_REQUEST':
state = 'NO_REQUEST';
return;
}
}
It's part of the elm-runtime.
Now, while it is possible that this function might not call any other functions, it would not explain why it's running for so long.
Where is the button for my complete flamechart :}
The Performance panel has a Disable JavaScript Samples checkbox in the capture settings menu.
When this checkbox is enabled, the timeline only shows the yellow placeholders to differentiate between script execution time and, layout, paint and composite activity.
Notice how the Cog/Settings Icon is red when the checkbox is enabled.
When the checkbox is not checked, the timeline shows the flame chart. When all the capture options are in their default state, the Cog/Settings Icon is blue while the menu is open and grey when the menu is closed/collaped.
Unfortunately it is not possible to be certain that this was the exact issue that you encountered, as the shared screenshot doesn't depict the capture settings.
Hopefully this knowledge proves valuable should you encounter the same behaviour in the future.
I'm trying to make an augmented reality application with vuforia and unity.
whenever it recognize the image target, it must tell a story by showing text , and it should enable the user to press next and back to go on reading the different parts of this story, I'm totally new to unity and don't know how to handle with UI throughout scripting, I need some help on how to accomplish the part of "going forward and backward on showing the story by hitting Next and Back buttons", and all these parts of story should be related to the same image target in the same scene.
I appreciate it if you help me with an example code.
You should create some script that attach on trackable object, maybe something like this.
public class DataBook {
string[] dataBook;
string idText;
bool isActive;
}
Then you must create another script to set that trackable object is active or not, this link can help you to get that.
https://developer.vuforia.com/forum/faq/unity-how-do-i-get-list-active-trackables
Then after you get the active trackable object, you can set the dialog from the book by create another controller script for button, example
public void Next() {
DataBook[] books = FindObjectsOfType<DataBook>(); // if the object more than one, it will be more easy if it only the one
foreach (var book in books)
{
if (book.isActive) {
book.idText += 1;
textUI.text = book.dataBook[idText]; //textUI assign to object text on canvas
}
}
}
you can learn about unity UI Button on this :
https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button
Good luck
I have problem with dealing with invitations.
Scenario:
1. Friend invites me to his game
2. I join to the game via push notification
3. onSignInSucceeded() in MenuActivity runs my main game activity
#Override
public void onSignInSucceeded() {
Games.Invitations.registerInvitationListener(getApiClient(), this);
if (getInvitationId() != null) {
Intent intent = new Intent(getApplicationContext(), FindRoomActivity.class);
intent.putExtra(BundleConstants.FRIEND_GAME_CLIENT, true);
intent.putExtra(BundleConstants.INVITATION_ID, getInvitationId());
startActivity(intent);
}
}
4. Friend leaves the game before it ends, on my screen popup shows up and after confirmation I'm back in my Menuactivity, and again runs code form onSignInSucceeded and once again getInvitationId() returns invitation to the same (canceled) game.
I was trying to run declineRoomInvitation or dismissRoomInvitation before I leave that canceled game, but nothing helps.
Ok I think I have an idea. I don't see why this wouldn't work.
When you call Games.RealTimeMultiplayer.leave(getApiClient(), this, mRoom.getRoomId());, you are inputting a RoomUpdateListener which has listeners: onJoinedRoom, onLeftRoom, onRoomCreated and onRoomConnected.
So this is what you do, when a player leaves a game, his/her onLeftRoom will be called, when it is called, send a message to the other player using Games.RealTimeMultiplayer.sendReliableMessage, then when the other player receives this message, he/she will know that the player left the game so you can make the invitation for that game null so when signInSucceeded gets called again, it won't try to accept an invitation to a canceled game.
I think this is the best way to implement it. Hope this has been of help :)
I'm working on a concept that works like copy & paste but uses my own algorithm instead of using the clipboard.
We have users that use many different programs that contain part numbers. This is how my concept would work.
User highlights part number from any application (word, excel, pdf, JDE, etc)
Either by hotkey or clicking on another application the user launches my routine.
My routine grabs that text from the original application and processes it accordingly.
I know how to use the clipboard to get text.
What I'm not sure of is how to get currently selected text from the application that was active prior to running my code? Do I need to force my user to copy to clipboard first and then run my app or can I create my own copy/paste type windows add-in?
Preferred VB for this but can also use C++ or C# if easier.
As to the question why, because we want to the action to be seamless to the user. There will be several behind the scenes actions that take place and then the user will be presented a browser with pertinent information related to that part number. Ultimately, I don't want an in-between screen to pop up, but rather completely hidden from the user. If I require them to copy and then run my routine then I'm adding in one extra step to the user path that I'm hoping to avoid.
I looked into right click menu context a bit but found that each program can have their own override. I wasn't able to locate a way to globally override all right click context menus to include a new action.
From this article:
var element = AutomationElement.FocusedElement;
if (element != null)
{
object pattern;
if (element.TryGetCurrentPattern(TextPattern.Pattern, out pattern))
{
var tp = (TextPattern) pattern;
var sb = new StringBuilder();
foreach (var r in tp.GetSelection())
{
sb.AppendLine(r.GetText(-1));
}
var selectedText = sb.ToString();
}
}
It's in C# but it should be pretty trivial to translate.
My question is simple: WHEN (on what event?) can I be sure that a control has fully loaded and has its states and templates also?
Why am I asking:
I'm trying to restore the state of my own WP7 control after recovering from tombstone. This control looks like a calendar in a weekly view. In this calendar you can select many items displayed as colored Rectangles.
If I select any of them, and then go to tombstone and come back to the page, it seems like my control forgot which Rectangles were selected. In fact, it did NOT forget the data itself, but the Rectangles forgot their selected state.
After recovering from tombstone, I try to select the Rectangles by setting their VisualState to "Selected" (which works in any other scenario). I found out, that it fails, because VisualStateManager can't find the "Selected" state.
I know this is tricky, because when coming back from tombstone the controls do not build exactly as in any "normal" case. (for example Bindings and Templates do not apply in the same order) But up until now I could always trust, that when FrameworkElement.Loaded fired, I had my controls ready. Now it seems like VisualState is not. (I tried to set the state from Loaded event handler, but results are the same, VisualStateManager.GoToState returns with false.)
What more can I do?
This is a tricky one! I have also experienced issues where UI events fire before the UI itself is fully constructed, see this blog post for an example. My general approach to this is to handle the LayoutUpdated event, which fires each time the visual tree is updated. You will find that this event fires multiple times, both before and after the Loaded event.
When the Layoutupdated event fires, you can check whether the visual state change has worked, if so, no longer handle the event. If not, keep trying!
Within your loaded event, try the following:
// try to set the state
if (VisualStateManager.GoToState(myControl, "myState") == false)
{
// if failed, wait for the next LayoutUpdated event
EventHandler updateHandler = null;
updateHandler = (s, e2) =>
{
if (VisualStateManager.GoToState(myControl, "myState") == false)
{
myControl.LayoutUpdated -= updateHandler;
}
};
myControl.LayoutUpdated += updateHandler;
}