facebook integration in awesomemenu in cocos2d - cocos2d-iphone

I have implemented awesomemenu in my game now i want to put three buttons by which i can redirect to another page like game high score , facebook ,and volume settings
but in awesomemenu if i want to add this facebook integration than how it will work means i got sharekit project which work properly now i want that to integrate in this game
in AwesomeMenu.m file there is touch detection method in which i can recognize three button by the tag but here i can't use [[ccdirector sharedirector]replacescene:]
Guide me what i have to write here?
- (void)AwesomeMenuItemTouchesEnd:(AwesomeMenuItem *)item
{
NSLog(#"%#",item);
// exclude the "add" button
if (item == _addButton)
{
return;
}
if(item.tag==1001){
}
if(item.tag==1002){
}
if(item.tag==1003){
}
}
what should i have to write in this if statement? is it correct or not?

There's a delegate function that comes with AwesomeMenu, which is: -(void)awesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx and let's you know which button did the user press.
To implement this, you need to:
set self as the delegate of the AwesomeMenu instance.
Add <AwesomeMenuDelegate> protocol to self.
implement -(void)awesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx.
example:
-(void)awesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx
{
switch (idx) {
case 0:
[self Button1Pressed];
break;
case 1:
[self Button2Pressed];
break;
case 2:
[self Button3Pressed];
break;
case 3:
[self Button4Pressed];
break;
default:
break;
}
}
Let me know if it's not clear. :)

Related

Ionic 2/3 :Dynamically set RootPage

I have a scenario where I have 2 profiles (user and admin) and I have a selection page once a person logs in. On the selection page, there are 2 radio buttons for (User and Admin profiles), what I am trying to achieve is, the person can choose only 1 profile (this is achieved by the radio button), now assuming I have saved the selected value, I want to set the rootPage to AdminPage or UserPage, but I don't want to immediately navigate, I just want to update/set the path so that when the person goes back (by pressing the back key or previous button) it will take the person to the desired page. Please let me know your thoughts.
Maby this will put you in the right direction:
https://ionicframework.com/docs/api/navigation/NavController/#insert
do not set adminPage or userPage as rootPage but insert the page on the stack
The trick here is that you want to set the root to a new page after the user tries to go back, the easiest way to achieve this is using the NavController navguards to execute a code before leaving the page, this way it'll check wich page the user has selected and then set the root.
Since the select can be easy impemented following the docs i'll leave that aside. Let's just say you have a property userType that is a string and can be 'user' or 'admin', in your select page you'll do the following:
public canLeave: boolean = false; //this'll controll if the user can leave the page or not
public userType: string = 'user'; // just setting a default value to your select
// this is a navguard
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage');
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage');
}
}
return true;
}
Hope this helps.
I got the solution to the error,
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage'); // <-- this should be UserPage instead of 'UserPage'
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage'); // <-- this should be AdminPage instead of 'AdminPage'
}
}
return true;
}

Delete confirmation when deleting from floating menu in a page editor in sitecore

I am very new sitecore, working with sitecore 7.
The question is when I am in a page editor, when I delete an item using the floating menu 'delete' function, It just deletes the item.
Customer requirement is to add a confirmation box here. Something like 'are you sure to delete'. and two typical buttons(yes/cancel).
is that even possible? any help would be appreciated.
EDIT:
In the picture below, The red cross, is a delete/remove button. If I click it just deletes. I want to show confirmation upon clicking the button.
EDIT 2:
Ok, I am writing a custom command.
I have added a new button. The target is this new button will ask if the user wants to remove the component or not. And if user says 'yes' it will do the same as the default built in remove button does.
Code:
public class RemoveWithNoti:Sitecore.Shell.Applications.WebEdit.Commands.WebEditCommand
{
public override void Execute(CommandContext context)
{
Context.ClientPage.Start(this, "Run", context.Parameters);
}
protected static void Run(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
if (args.HasResult)
{
//Here I need to call "chrome:rendering:delete" this . I just dont know how to!!
}
}
else
{
SheerResponse.Confirm("Are you certain that you want to remove this component");
args.WaitForPostBack();
}
}
}
How do I call chrome:rendering:delete from code??
The "chrome:rendering:delete" event is handled on the client side by javascript. Here is the exact places:
/sitecore/shell/Applications/Page Modes/ChromeTypes/RenderingChromeType.js file:
handleMessage: function(message, params, sender) {
switch (message) {
...
case "chrome:rendering:delete":
this.deleteControl();
break;
...
},
You can do something like this in the same file:
deleteControl: function() {
if(confirm('Are you sure to remove this component?')){
var placeholder = this.getPlaceholder();
if (placeholder) {
placeholder.type.deleteControl(this.chrome);
}
}
}

how can I disable the options menu from action bar(not the menu items)

I have a activity which is hosting 3 fragments. A,B,C. For the hosting activity and Fragment A, it should show the options menu, so I am inflating it in fragment A.
Now For fragment B and C I just want to display the action bar(having title and back arrow), and disable the complete options menu dropdown(the 3 dots in the right corner).
I tried using setHasMenuOptions(false) in fragments B and C but its not working.
Is there any option to hide the three dots with dropdown in other two fragments.
My activity has the following code to perform the back navigation. Everything is working fine accept hiding the complete menu in the two fragments B and C.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
super.onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Override onPrepareOptionsMenu in yor fragment class and do menu.clear();
Also do setHasMenuOptions(true);
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.clear();
}

How to abort saveui pipeline in Sitecore and then reset values?

I am trying to implement a saveui pipeline processor in Sitecore 6. Basically I have created a custom processor that presents the user with a popup message depending on which fields they may have changed on the item and what the new data is. If they made certain changes then they are presented with a popup asking them if they want to continue. If they answer no then the pipeline is aborted. That is all working. However I noticed that when you abort the pipeline all Sitecore seems to do is not save. All of the changes that the user made to the content item are still there in the UI. If you navigate away from the item in Sitecore, it will prompt you if you want to save the changes. Is there some way that I can get the Sitecore UI to cancel all of the changes and revert all of the fields back to their initial values? Aborting the pipeline is good because I don't want to save, but I also want to cancel the save in the UI too. Does anyone know how to do this?
Sample Code:
public class CustomSaveProcessor
{
public void Process(SaveArgs args)
{
Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
if(args.Items == null)
{ return; }
if(args.IsPostback)
{
if(args.Parameters["runContext"] == "firstQuestion")
{
if((args.Result == null) || (args.Result == "null") || (args.Result == "no") || (args.Result == "cancel"))
{
args.AbortPipeline();
//Should there be something here to tell the Sitecore UI to reset the values?
return;
}
else
{
//User has answered first question Yes
//This means they want to save the changes to the item
//We also want to ask a second question that effects other content items
SheerResponse.YesNoCancel("Do you want to also modify other items?", "300px", "200px");
args.Parameters["runContext"] = "secondQuestion";
args.WaitForPostBack();
}
}
else
{
if(args.Result == "yes")
{
//This is the answer to second question
//Custom code here to modify other content items
}
//We are completely done now.
return;
}
}
else
{
//Ask the user the first question
SheerResponse.YesNoCancel("Are you sure you want to proceed?", "300px", "200px");
args.Parameters["runContext"] = "firstQuestion";
args.WaitForPostback();
}
}
}
You can just reload the content tree with the following code.
String refresh = String.Format("item:refreshchildren(id={0})", Sitecore.Context.Item.Parent.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);
Or as Corey discovered if you want to refersh the item you'd use
String refresh = String.Format("item:load(id={0})", myOriginalItem.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);
See this post for more details
I think you can try to reload the current content item after aborting your custom save handler to set the intial values of the content item. Not sure if you then still get the "alert message".
Take a look at this post with a similiar issue

PSN_QUERYCANCEL does not close Property Sheet

I have a property sheet that I have created and each of the tab pages share the same pfnDlgProc. In the pfnDlgProc, I have this code:
switch (msg) {
case WM_NOTIFY:
nmhdr = (NMHDR*)lParam;
switch (nmhdr->code) {
case PSN_QUERYCANCEL:
printf("PSN_QUERYCANCEL\n");
SetWindowLong(nmhdr->hwndFrom, DWL_MSGRESULT, FALSE);
return TRUE;
}
break;
...
}
When I click the Cancel button on my property sheet, PSN_QUERYCANCEL is printed, but the property sheet does not close. Why is this? Is there something else I need to do to allow it to/make it close? I know I can add DestroyWindow(nmhdr->hwndFrom) to the handler but is that the proper way to do it?
You are setting the DWL_MSGRESULT on the window handle that sent you the notification, but not necessarily the window that is the dialog you are processing the WM_NOTIFY for. Instead of using the nmhdr->hwndFrom window handle, try using the HWND that is passed to your pfnDlgProc.