How to save options? - cocos2d-iphone

i have made a option's page where where we can choose fire to auto or manual...
now when i choose the option i want it to remain the same whenever i play the game until i change it again .
How?will it be saved somewhere automatically?

You are looking for NSUserDefaults. it is perfect for something like this.
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
if (standardUserDefaults) {
[standardUserDefaults setBOOL:YES forKey:#"autoFire"];
[standardUserDefaults synchronize];
}

Related

Actions Menu Interactive Grid

Is there any way to remove 'Chart' from Actions Menu in an Interactive Grid?
So I posted a short answer that should have honestly probably been a comment with a link to https://hardlikesoftware.com/weblog/2017/01/24/how-to-hack-apex-interactive-grid-part-2/
Then I had some time and decided to try to actually execute this and got to a solution thanks to https://community.oracle.com/thread/4324589 where they also further reference https://community.oracle.com/thread/4319050
So you know where to go for more information on this topic.
As for your solution:
Go into the Attributes of the IG, Find Javascript Initialization Code under Advanced.
Then paste the following code:
function(config) {
var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar();
config.toolbarData = toolbarData;
toolbarData.toolbarRemove( "chart-view" );
return config;
}
Hope this works for you, it worked for me.
EDIT:
In response to you asking how to find the name to remove.
Well thats not exactly simple. See if perhaps its mentioned in one of the posts. Otherwise you will have to search through the js file.
How I went about it is that once on the page, I opened up the console and ran $.apex.interactiveGrid.copyDefaultToolbar();
, opened up the returned array, and jumped to the definition of ToolbarRemove. This opened up InteractiveGrid.min.js so I could search there. Then I Ctrl + F there to find "chart".
What you could also do so you arent just searching blindly until you find it is that these labels need to be referenced for translation. So if you go to
http://translate-apex.com
And you find what the label is called, you can just search for that.
For the chart you could go to the translations and find the Chart item which is APEX.IG.CHART. Then in the js you find APEX.IG.CHART which only occurs once, instead of the 10 times "chart" occurs.
EDIT 2:
You asked about the Flashback dialog.
function(config) {
var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar();
config.toolbarData = toolbarData;
toolbarData.toolbarRemove( "show-flashback-dialog" );
return config;
}
This works for me
Check the attributes of the interactive grid and turn off the "Define chart view"
Check this image

wxGrid GetSelectedCells returns empty array

I want to delete selected rows when the use click on a button.
so far the code looks like that:
this->grid_ = new wxGrid(parent, ...)
this->grid_->SetSelectionMode(wxGrid::wxGridSelectCells);
// Later, whene the button is clicked
this->grid_->SetFocus();
wxGridCellCoordsArray wx_cells = this->grid_->GetSelectedCells();
The problem is that the wx_cells variable is always empty whatever I select.
I tried with GetSelectedRows with no success.
I've added SetFocus and SetSelectionMode hoping it would help but it did not.
How can I get this to work ?
What version of wxgrid are you using? There seems to be an issue with old wxgrid that it always return empty when calling GetSelectedCells. Perhaps you can refer to http://forums.wxwidgets.org/viewtopic.php?t=6335 to try if it fits in your case.

How can I show an image widget on top of a Button

refBuilder->get_widget("image1", image);
if(image){
pButton1->set_image(*image);
//Glib::PropertyProxy<bool> prop;
Gtk::Settings::property_gtk_button_images() = true;
}
I know the last line isn't written properly, I don't know how to use PropertyProxy. I just want to set the property to true. that might not solve what I want to achieve, but it might be a step closer. The class reference didn't specify how to use them properly. Any suggestions?
I am not sure what are you looking for but if you want to put an image on a button, then here is the code. Basically you need to define an image and set that image to the given button.
Gtk::Button *btn=Gtk::manage(new Gtk::Button("DummyButton"));
Gtk::Image *ImageIcon=Gtk::manage(new Gtk::Image(Gtk::IconTheme::get_default()->load_icon("ButtonImage",128)));
btn->set_image(*ImageIcon);
btn->set_image_position(Gtk::POS_TOP);

Can't hide CCMenuItem when using In-App-Purchase

This time I would like to ask if anybody had such strange problem with disabling button (CCMenuItemImage) in cocos2d. I have in-App-Purchase connected and when purchase is done following function is triggered
- (void)productPurchased:(NSNotification *)notification {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
waitingForStore = FALSE;
[loop setVisible:FALSE];
[buyItem setVisible:FALSE];
// setAccessibilityElementsHidden:YES];
NSString *productIdentifier = (NSString *) notification.object;
NSLog(#"Purchased: %#", productIdentifier);
}
waitingForStore = FALSE;
[loop setVisible:FALSE];
This two operation works fine, but the problem is with the third one. I would like to make the 'BUY' button invisible.
[buyItem setVisible:FALSE];
This one does not do anything at this place( the button is still visible and accessible). If I will use it on the other part of code it works just fine- but here .... not. Trying to change position doesn't work neither.
Could it be connected with inAppPurchase thread or something?
I have found the reason. It was my mistake when making two calls to the apple store and creating two buttons. :) So, it could be closed.
I understand your problem. If you you want to disable menuitem you can set menuitem.isEnabled property.
And if you want to hide button, you can set property menuitem.visible = NO.
If this is not working for you can also use [menuitem runaction:[CCFadeOut actionWithDuration:1.0f] ]. Then use FadeIn as per your requirement.
This is alternative option for you.

Using images in QListWidget, is this possible?

I am using QT to create a chat messenger client. To display the list of online users, I'm using a QListWidget, as created like this:
listWidget = new QListWidget(horizontalLayoutWidget);
listWidget->setObjectName("userList");
QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(listWidget->sizePolicy().hasHeightForWidth());
listWidget->setSizePolicy(sizePolicy1);
listWidget->setMinimumSize(QSize(30, 0));
listWidget->setMaximumSize(QSize(150, 16777215));
listWidget->setBaseSize(QSize(100, 0));
listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
Users are shown by constantly refreshing the list, like this: (Note: There are different channels, with different userlists, so refreshing it is the most efficient thing to do, as far as I know.)
void FMessenger::refreshUserlist()
{
if (currentPanel == 0)
return;
listWidget = this->findChild<QListWidget *>(QString("userList"));
listWidget->clear();
QList<FCharacter*> charList = currentPanel->charList();
QListWidgetItem* charitem = 0;
FCharacter* character;
foreach(character, charList)
{
charitem = new QListWidgetItem(character->name());
// charitem->setIcon(QIcon(":/Images/status.png"));
listWidget->addItem(charitem);
}
}
This has always worked perfectly. The line that I commented out is the one I have problems with: my current goal is to be able to display a user's online status with an image, which represents whether they are busy, away, available, etc. Using setIcon() does absolutely nothing though, apparently; the items still show up as they used to, without icons.
I'm aware that this is probably not the way this function needs to be used, but I have found little documentation about it online, and absolutely no useful examples of implementations. My question is, can anybody help me with fixing this problem?
This is how you may conduct your debugging:
Try the constructor that has both icon and text as arguments.
Try to use that icon in another context to ensure it is displayable (construct a QIcon with same argument and use it elsewhere, e.g. QLabel!).
Use icon() from the QListWidgetItem to receive back the icon and then look at that QIcon.
Create a new QListWidget, change nothing, and ordinarily add some stock items in your MainWidget's constructor. See if the icons show up there.