本文整理汇总了C++中Label类的典型用法代码示例。如果您正苦于以下问题:C++ Label类的具体用法?C++ Label怎么用?C++ Label使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLabTitleContent
void DialogNode::setLabTitleContent(std::string text)
{
Label *labContent = (Label*)this->getChildByTag((int)ChildTag::LAB_CONTENT);
labContent->setString(text);
}
示例2: set_title
ProjectSettings::ProjectSettings(EditorData *p_data) {
singleton=this;
set_title("Project Settings (engine.cfg)");
undo_redo=&p_data->get_undo_redo();
data=p_data;
TabContainer *tab_container = memnew( TabContainer );
add_child(tab_container);
set_child_rect(tab_container);
//tab_container->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 15 );
//tab_container->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 15 );
//tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
//tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
Control *props_base = memnew( Control );
tab_container->add_child(props_base);
props_base->set_name("General");
globals_editor = memnew( PropertyEditor );
props_base->add_child(globals_editor);
globals_editor->set_area_as_parent_rect();
globals_editor->hide_top_label();
globals_editor->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 55 );
globals_editor->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
globals_editor->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
globals_editor->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
globals_editor->set_capitalize_paths(false);
globals_editor->get_tree()->connect("cell_selected",this,"_item_selected");
globals_editor->connect("property_toggled",this,"_item_checked");
globals_editor->connect("property_edited",this,"_settings_prop_edited");
Label *l = memnew( Label );
props_base->add_child(l);
l->set_pos(Point2(6,5));
l->set_text("Category:");
l = memnew( Label );
l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
props_base->add_child(l);
l->set_begin(Point2(0.21,5));
l->set_text("Property:");
l = memnew( Label );
l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
props_base->add_child(l);
l->set_begin(Point2(0.51,5));
l->set_text("Type:");
category = memnew( LineEdit );
props_base->add_child(category);
category->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
category->set_begin( Point2(5,25) );
category->set_end( Point2(0.20,26) );
category->connect("text_entered",this,"_item_adds");
property = memnew( LineEdit );
props_base->add_child(property);
property->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
property->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
property->set_begin( Point2(0.21,25) );
property->set_end( Point2(0.50,26) );
property->connect("text_entered",this,"_item_adds");
type = memnew( OptionButton );
props_base->add_child(type);
type->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
type->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
type->set_begin( Point2(0.51,25) );
type->set_end( Point2(0.70,26) );
type->add_item("bool");
type->add_item("int");
type->add_item("float");
type->add_item("string");
Button *add = memnew( Button );
props_base->add_child(add);
add->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
add->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
add->set_begin( Point2(0.71,25) );
add->set_end( Point2(0.85,26) );
add->set_text("Add");
add->connect("pressed",this,"_item_add");
Button *del = memnew( Button );
props_base->add_child(del);
del->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
del->set_anchor(MARGIN_RIGHT,ANCHOR_END);
del->set_begin( Point2(0.86,25) );
del->set_end( Point2(5,26) );
del->set_text("Del");
del->connect("pressed",this,"_item_del");
Button *save = memnew( Button );
props_base->add_child(save);
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
w.attach(ntValue, Update::Value, &b);
w.setValue(0.01f, 0);
w.setValue(0.02f, 1);
assert(b);
assert(w.getValue(0) == 0.01f);
assert(w.getValue(1) == 0.02f);
assert(w.center() == 0.015f);
assert(w.range() == 0.01f);
w.endpoints(0,1);
assert(w.getValue(0) == 0);
assert(w.getValue(1) == 1);
w.centerRange(0.5, 0.25);
assert(w.getValue(0) == (0.5-0.25/2));
assert(w.getValue(1) == (0.5+0.25/2));
float v1,v2;
w.attachVariable(v1, 0);
w.attachVariable(v2, 1);
w.setValue(0.2, 0);
w.setValue(0.3, 1);
assert(w.data().toToken() == "{0.2, 0.3}");
v1 = v2 = 0;
w.setDataFromString("{0.7, 0.8}");
assert(w.getValue(0)==0.7 && w.getValue(1)==0.8);
assert(v1==(float)w.getValue(0) && v2==(float)w.getValue(1));
}
{
bool b=false;
Label w;
w.attach(ntValue, Update::Value, &b);
w.setValue("test");
assert(b);
assert(w.getValue() == "test");
assert(w.data().toToken() == "\"test\"");
w.setValue("");
w.setDataFromString("\"test\""); assert(w.getValue() == "test");
}
{
// {
// double val = 1e14;
// double inc = 1;
// printf("%f\n", val + inc*1);
// printf("%f\n", val + inc*2);
// printf("%f\n", val + inc*3);
// printf("%f\n", val + inc*4);
// }
bool b=false;
NumberDialer w(1,2,1,0);
w.attach(ntValue, Update::Value, &b);
w.setValue(0.75);
assert(b);
assert(w.getValue() == 0.75);
// Setting to current value should NOT send notification to avoid infinite loops
b=false;
示例4: LOGI
void SamplesGame::initialize()
{
LOGI(">SamplesGame::initialize ()");
LOGI(">SamplesGame::initialize FileSystem::getAssetPath() = '%s'", FileSystem::getAssetPath());
LOGI(">SamplesGame::initialize FileSystem::getResourcePath() = '%s'", FileSystem::getResourcePath());
Bundle* bundle = Bundle::create("res/ui/arial.gpb");
LOGI(">SamplesGame::initialize bundle=%p", bundle);
_font = bundle->loadFont(bundle->getObjectId(0));
LOGI(">SamplesGame::initialize _font=%p", _font);
_font = Font::create("res/ui/arial.gpb");
LOGI(">SamplesGame::initialize _font=%p", _font);
for (size_t i = 0; i < _categories->size(); ++i)
{
std::sort((*_samples)[i].begin(), (*_samples)[i].end());
}
// Load camera script
getScriptController()->loadScript("res/common/camera.lua");
// Create the selection form
_sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
_sampleSelectForm->setWidth(220);
_sampleSelectForm->setHeight(1, true);
_sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
const size_t size = _samples->size();
LOGI(">SamplesGame::initialize _samples->size()=%d", size);
for (size_t i = 0; i < size; ++i)
{
Label* categoryLabel = Label::create((*_categories)[i].c_str());
categoryLabel->setFontSize(22);
categoryLabel->setText((*_categories)[i].c_str());
_sampleSelectForm->addControl(categoryLabel);
categoryLabel->release();
SampleRecordList list = (*_samples)[i];
const size_t listSize = list.size();
for (size_t j = 0; j < listSize; ++j)
{
SampleRecord sampleRecord = list[j];
Button* sampleButton = Button::create(sampleRecord.title.c_str());
sampleButton->setText(sampleRecord.title.c_str());
sampleButton->setWidth(1, true);
sampleButton->setHeight(50);
sampleButton->addListener(this, Control::Listener::CLICK);
_sampleSelectForm->addControl(sampleButton);
sampleButton->release();
}
}
_sampleSelectForm->setFocus();
// Disable virtual gamepads.
unsigned int gamepadCount = getGamepadCount();
for (unsigned int i = 0; i < gamepadCount; i++)
{
Gamepad* gamepad = getGamepad(i, false);
if (gamepad->isVirtual())
{
gamepad->getForm()->setEnabled(false);
}
}
/*
for (size_t i = 0; i < size; ++i)
{
SampleRecordList list = (*_samples)[i];
const size_t listSize = list.size();
for (size_t j = 0; j < listSize; ++j)
{
SampleRecord sampleRecord = list[j];
// TODO if (sampleRecord.title.compare(control->getId()) == 0)
{
_sampleSelectForm->setEnabled(false);
runSample(sampleRecord.funcPtr);
LOGI("<SamplesGame::initialize _activeSample=%lx", (long )_activeSample);
return;
}
}
}
*/
LOGI("<SamplesGame::initialize _activeSample=%lx", (long )_activeSample);
}
示例5: lprintfln
/**
* If there is no list populates the List View Widget with the project data
* from mProjects vector. Else destroys and deallocates previous list items
* and creates new ones.
*/
void WorkspaceLayout::updateProjectList(MAUtil::Vector <reloadProject> * projects)
{
// Remove The ListView and add An Activity Indicator
lprintfln("Updating Project List");
mListView->setVisible(false);
/**
* FIXME Removing listView and adding Activity indicator causes
* the list view not getting events until some point,
* when removing activity indicator to add the list again.
*/
//this->removeChild(mListView);
//this->addChild(mActivityIndicatorContainer);
// If there was a project Selected before update remove the
// control buttons
if(mSelectedProject != -1)
{
Widget *h = mListView->getChild(mSelectedProject)->getChild(0);
h->removeChild(h->getChild(1));
h->removeChild(h->getChild(1));
}
// ReInitialize selected project
mSelectedProject = -1;
mSelectedProjectName = "";
// Delete all the widgets from the ListView
int prProjects = mListView->countChildWidgets();
if(prProjects != 0)
{
for(int i = 0; i < prProjects; i++)
{
Widget *listItemWidget = mListView->getChild(0); // list Item Widget
Widget *hLayout = listItemWidget->getChild(0); // horizontal layout widget
for( int j = 0; j < hLayout->countChildWidgets(); j++)
{
Widget * w = hLayout->getChild(0);
hLayout->removeChild(w);
delete w;
}
listItemWidget->removeChild(hLayout);
delete hLayout;
mListView->removeChild(listItemWidget);
delete listItemWidget;
}
}
// Re-populate the ListView with projects
for (MAUtil::Vector <reloadProject>::iterator i = projects->begin(); i != projects->end(); i++)
{
// New List Itemprojects
ListViewItem* item = new ListViewItem();
item->setHeight(mWidgetHeight);
item->fillSpaceHorizontally();
// New Horizontal Layout
HorizontalLayout *itemHorizontalLayout = new HorizontalLayout();
itemHorizontalLayout->fillSpaceHorizontally();
itemHorizontalLayout->setHeight(mWidgetHeight);
// New Label
Label* projectNameLabel = new Label();
projectNameLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);
projectNameLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
projectNameLabel->setText(i->name);
projectNameLabel->fillSpaceHorizontally();
projectNameLabel->fillSpaceVertically();
if (mOS.find("iPhone") >= 0)
{
itemHorizontalLayout->setWidth(item->getWidth());
projectNameLabel->setFontColor(0xffffff);
}
itemHorizontalLayout->addChild(projectNameLabel);
item->addChild(itemHorizontalLayout);
mListView->addChild(item);
}
mListView->setVisible(true);
// Remove Indicator and Add Project ListView
//this->addChild(mListView);
//this->removeChild(mActivityIndicatorContainer);
}
示例6: background
int WaitingMenu::run(sf::RenderWindow &window, CommonData* commonData) {
// Create background
sf::Sprite background(commonData->defaultBackgroundTexture);
// Create menu title
Label* lobbyTitle = new Label("Lobby", 100, commonData);
lobbyTitle->setPosition((SCREEN_WIDTH - lobbyTitle->getWidth()) / 2, 50);
// Teams labels
Label* blueTeamLabel = new Label("Blue team", 70, 150, 200, commonData);
blueTeamLabel->setColor(sf::Color::Blue);
Label* redTeamLabel = new Label("Red team", 70, commonData);
redTeamLabel->setPosition(SCREEN_WIDTH - redTeamLabel->getWidth() - 150, 200);
redTeamLabel->setColor(sf::Color::Red);
// Players labels
Label** playerLabel = new Label*[4];
for (int i = 0; i < 4; i++) {
playerLabel[i] = new Label("", 60, 180, 300 + (i/2)*100, commonData);
if (i % 2 == 1) {
playerLabel[i]->setPosition(SCREEN_WIDTH - playerLabel[i]->getWidth() - 180, 300 + (i/2)*100);
}
}
// Countdown label
Label* countdownLabel = new Label("The game will start in 15 seconds...", 40, commonData);
countdownLabel->setPosition(SCREEN_WIDTH - countdownLabel->getWidth() - 30, 600);
// Countdown
sf::Clock clock;
sf::Time fiveteenSeconds = sf::seconds(15.0f);
int amountOfPlayers = 0;
// Main loop
while (window.isOpen()) {
// Position of mouse
sf::Vector2i position = sf::Mouse::getPosition(window);
// Process events
sf::Event event;
while (window.pollEvent(event)) {
// Close window: exit
if (event.type == sf::Event::Closed) {
window.close();
}
// Escape pressed: exit
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
window.close();
}
}
// Show players name on labels
for (int i = 0; i < commonData->map->playersSize(); i++) {
Player* player = commonData->map->getPlayerAtIndex(i);
playerLabel[player->getID()]->setString(player->getName());
}
// Prepare countdown information
if ((amountOfPlayers != commonData->map->playersSize()) && (commonData->map->playersSize() == 2 || commonData->map->playersSize() == 4)) {
clock.restart();
amountOfPlayers = commonData->map->playersSize();
}
// Clear screen
window.clear(sf::Color::Black);
// Draw
window.draw(background);
lobbyTitle->draw(window);
blueTeamLabel->draw(window);
redTeamLabel->draw(window);
for (int i = 0; i < 4; i++) {
if (i % 2 == 1) {
playerLabel[i]->setPosition(SCREEN_WIDTH - playerLabel[i]->getWidth() - 180, 300 + (i/2)*100);
}
playerLabel[i]->draw(window);
}
// Show information about starting game only when there are 2 or 4 players
if (commonData->map->playersSize() == 2 || commonData->map->playersSize() == 4) {
int timeToStart = (int)ceil(fiveteenSeconds.asSeconds() - clock.getElapsedTime().asSeconds());
if (timeToStart <= 3) {
timeToStart = 3;
}
countdownLabel->setString("The game will start in " + Converter::int2string(timeToStart) + " seconds...");
countdownLabel->setPosition(SCREEN_WIDTH - countdownLabel->getWidth() - 30, 600);
countdownLabel->draw(window);
}
// Update the window
window.display();
// Go to the game if countdown will finish
if ((amountOfPlayers == 2 || amountOfPlayers == 4) && clock.getElapsedTime().asSeconds() > fiveteenSeconds.asSeconds() - 3.0f && commonData->gameStarted == true) {
return GAME;
}
}
// Change screen
//.........这里部分代码省略.........
示例7: snprintf
void TestUnicodePath::onEnter()
{
FileUtilsDemo::onEnter();
auto s = Director::getInstance()->getWinSize();
auto util = FileUtils::getInstance();
int x = s.width/2,
y = s.height/5;
Label* label = nullptr;
std::string dir = "中文路径/";
std::string filename = "测试文件.test";
std::string act;
auto getMsg = [&act](bool b, const std::string& path)-> std::string
{
char msg[512];
snprintf((char *)msg, 512, "%s for %s path: \"%s\"", b ? "success" : "failed", act.c_str(), path.c_str());
return std::string(msg);
};
// Check whether unicode dir should be create or not
std::string dirPath = util->getWritablePath() + dir;
if (!util->isDirectoryExist(dirPath))
{
util->createDirectory(dirPath);
}
act = "create";
bool isExist = util->isDirectoryExist(dirPath);
label = Label::createWithSystemFont(getMsg(isExist, dirPath), "", 12, Size(s.width, 0));
label->setPosition(x, y * 4);
this->addChild(label);
if (isExist)
{
// Check whether unicode file should be create or not
std::string filePath = dirPath + filename;
if (! util->isFileExist(filePath))
{
std::string writeDataStr = " 测试字符串.";
Data writeData;
writeData.copy((unsigned char *)writeDataStr.c_str(), writeDataStr.size());
util->writeDataToFile(writeData, filePath);
}
isExist = util->isFileExist(filePath);
label = Label::createWithSystemFont(getMsg(isExist, filePath), "", 12, Size(s.width, 0));
label->setPosition(x, y * 3);
this->addChild(label);
act = "remove";
if (isExist)
{
// read file content and log it
unsigned char* buffer = nullptr;
Data readData = util->getDataFromFile(filePath);
buffer = (unsigned char*)malloc(sizeof(unsigned char) * (readData.getSize() + 1));
memcpy(buffer, readData.getBytes(), readData.getSize());
buffer[readData.getSize()] = '\0';
// vc can't treat unicode string correctly, don't use unicode string in code
log("The content of file from writable path: %s", buffer);
free(buffer);
// remove test file
label = Label::createWithSystemFont(getMsg(util->removeFile(filePath), filePath), "", 12, Size(s.width, 0));
label->setPosition(x, y * 2);
this->addChild(label);
}
// remove test dir
label = Label::createWithSystemFont(getMsg(util->removeDirectory(dirPath), dirPath), "", 12, Size(s.width, 0));
label->setPosition(x, y * 1);
this->addChild(label);
}
}
示例8: set_focus_mode
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
editor=p_editor;
singleton=this;
updating=false;
set_focus_mode(FOCUS_ALL);
player=NULL;
add_style_override("panel", get_stylebox("panel","Panel"));
Label * l;
/*l= memnew( Label );
l->set_text(TTR("Animation Player:"));
add_child(l);*/
HBoxContainer *hb = memnew( HBoxContainer );
add_child(hb);
play_bw_from = memnew( ToolButton );
play_bw_from->set_tooltip(TTR("Play backwards selected animation from current pos. (A)"));
hb->add_child(play_bw_from);
play_bw = memnew( ToolButton );
play_bw->set_tooltip(TTR("Play backwards selected animation from end. (Shift+A)"));
hb->add_child(play_bw);
stop = memnew( ToolButton );
stop->set_toggle_mode(true);
hb->add_child(stop);
stop->set_tooltip(TTR("Stop animation playback. (S)"));
play = memnew( ToolButton );
play->set_tooltip(TTR("Play selected animation from start. (Shift+D)"));
hb->add_child(play);
play_from = memnew( ToolButton );
play_from->set_tooltip(TTR("Play selected animation from current pos. (D)"));
hb->add_child(play_from);
//pause = memnew( Button );
//pause->set_toggle_mode(true);
//hb->add_child(pause);
frame = memnew( SpinBox );
hb->add_child(frame);
frame->set_custom_minimum_size(Size2(60,0));
frame->set_stretch_ratio(2);
frame->set_tooltip(TTR("Animation position (in seconds)."));
hb->add_child( memnew( VSeparator));
scale = memnew( LineEdit );
hb->add_child(scale);
scale->set_h_size_flags(SIZE_EXPAND_FILL);
scale->set_stretch_ratio(1);
scale->set_tooltip(TTR("Scale animation playback globally for the node."));
scale->hide();
add_anim = memnew( ToolButton );
add_anim->set_tooltip(TTR("Create new animation in player."));
hb->add_child(add_anim);
load_anim = memnew( ToolButton );
load_anim->set_tooltip(TTR("Load an animation from disk."));
hb->add_child(load_anim);
save_anim = memnew(MenuButton);
save_anim->set_tooltip(TTR("Save the current animation"));
save_anim->get_popup()->add_item(TTR("Save"), ANIM_SAVE);
save_anim->get_popup()->add_item(TTR("Save As.."), ANIM_SAVE_AS);
save_anim->set_focus_mode(Control::FOCUS_NONE);
hb->add_child(save_anim);
accept = memnew(AcceptDialog);
add_child(accept);
accept->connect("confirmed", this, "_menu_confirm_current");
duplicate_anim = memnew( ToolButton );
hb->add_child(duplicate_anim);
duplicate_anim->set_tooltip(TTR("Duplicate Animation"));
rename_anim = memnew( ToolButton );
hb->add_child(rename_anim);
rename_anim->set_tooltip(TTR("Rename Animation"));
remove_anim = memnew( ToolButton );
hb->add_child(remove_anim);
remove_anim->set_tooltip(TTR("Remove Animation"));
//.........这里部分代码省略.........
示例9: onEnter
void TestDirectoryFuncs::onEnter()
{
FileUtilsDemo::onEnter();
auto s = Director::getInstance()->getWinSize();
auto sharedFileUtils = FileUtils::getInstance();
int x = s.width/2,
y = s.height/4;
Label* label = nullptr;
std::string dir = sharedFileUtils->getWritablePath() + "__test/";
std::string subDir = "dir1/dir2";
std::string msg;
bool ok;
// Check whether dir can be created
ok = sharedFileUtils->createDirectory(dir);
if (ok && sharedFileUtils->isDirectoryExist(dir))
{
msg = StringUtils::format("createDirectory: Directory '__test' created");
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y * 3);
this->addChild(label);
// Create sub directories recursively
ok = sharedFileUtils->createDirectory(dir + subDir);
if (ok && sharedFileUtils->isDirectoryExist(dir + subDir))
{
msg = StringUtils::format("createDirectory: Sub directories '%s' created", subDir.c_str());
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y * 2);
this->addChild(label);
}
else
{
msg = StringUtils::format("createDirectory: Failed to create sub directories '%s'", subDir.c_str());
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y * 2);
this->addChild(label);
}
// Remove directory
ok = sharedFileUtils->removeDirectory(dir);
if (ok && !sharedFileUtils->isDirectoryExist(dir))
{
msg = StringUtils::format("removeDirectory: Directory '__test' removed");
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y);
this->addChild(label);
}
else
{
msg = StringUtils::format("removeDirectory: Failed to remove directory '__test'");
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y);
this->addChild(label);
}
}
else
{
msg = StringUtils::format("createDirectory: Directory '__test' can not be created");
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y * 2);
this->addChild(label);
}
}
示例10: fopen
void TestFileFuncs::onEnter()
{
FileUtilsDemo::onEnter();
auto s = Director::getInstance()->getWinSize();
auto sharedFileUtils = FileUtils::getInstance();
int x = s.width/2,
y = s.height/5;
Label* label = nullptr;
std::string filename = "__test.test";
std::string filename2 = "__newtest.test";
std::string filepath = sharedFileUtils->getWritablePath() + filename;
std::string content = "Test string content to put into created file";
std::string msg;
FILE *out = fopen(filepath.c_str(), "w");
fputs(content.c_str(), out);
fclose(out);
// Check whether file can be created
if (sharedFileUtils->isFileExist(filepath))
{
label = Label::createWithSystemFont("Test file '__test.test' created", "", 20);
label->setPosition(x, y * 4);
this->addChild(label);
// getFileSize Test
long size = sharedFileUtils->getFileSize(filepath);
msg = StringUtils::format("getFileSize: Test file size equals %ld", size);
label = Label::createWithSystemFont(msg, "", 20);
label->setPosition(x, y * 3);
this->addChild(label);
// renameFile Test
if (sharedFileUtils->renameFile(sharedFileUtils->getWritablePath(), filename, filename2))
{
label = Label::createWithSystemFont("renameFile: Test file renamed to '__newtest.test'", "", 20);
label->setPosition(x, y * 2);
this->addChild(label);
// removeFile Test
filepath = sharedFileUtils->getWritablePath() + filename2;
if (sharedFileUtils->removeFile(filepath))
{
label = Label::createWithSystemFont("removeFile: Test file removed", "", 20);
label->setPosition(x, y * 1);
this->addChild(label);
}
else
{
label = Label::createWithSystemFont("removeFile: Failed to remove test file", "", 20);
label->setPosition(x, y * 1);
this->addChild(label);
}
}
else
{
label = Label::createWithSystemFont("renameFile: Failed to rename test file to '__newtest.test', further test skipped", "", 20);
label->setPosition(x, y * 2);
this->addChild(label);
}
}
else
{
label = Label::createWithSystemFont("Test file can not be created, test skipped", "", 20);
label->setPosition(x, y * 4);
this->addChild(label);
}
}
示例11: Size
bool DialogNode::init(std::string title, std::string content, std::string btn1Text, cocos2d::CallFuncN* btn1Callback, std::string btn2Text, cocos2d::CallFuncN* btn2Callback)
{
if(Node::init())
{
this->m_btn1Callback = NULL;
this->m_btn2Callback = NULL;
if (btn1Callback)
{
this->m_btn1Callback = btn1Callback;
this->m_btn1Callback->retain();
}
if (btn2Callback)
{
this->m_btn2Callback = btn2Callback;
this->m_btn2Callback->retain();
}
this->setScale(0);
Sprite *bgSprite = Sprite::create("dialog_bg.png");
this->addChild(bgSprite);
this->setContentSize(bgSprite->getContentSize());
this->setAnchorPoint(Vec2(0.5, 0.5));
bgSprite->setPosition(Vec2(this->getContentSize().width / 2, this->getContentSize().height / 2));
Label *labTitle = Label::createWithSystemFont(title.c_str(), GAME_CONFIG_GLOBAL_FONTNAME_01, 32);
labTitle->setPosition(Vec2(this->getContentSize().width / 2, 170));
labTitle->setTag((int)ChildTag::LAB_TITLE);
this->addChild(labTitle);
Label *labContent = Label::create(content, GAME_CONFIG_GLOBAL_FONTNAME_01, 25, Size(300, 70), TextHAlignment::LEFT, TextVAlignment::TOP);
labContent->setPosition(Vec2(this->getContentSize().width / 2, 115));
labContent->setTag((int)ChildTag::LAB_CONTENT);
this->addChild(labContent);
if (btn2Callback)
{
//2个按钮
Button *btn1 = Button::create();
btn1->loadTextureNormal("dialog_btn_yes_1.png");
btn1->loadTexturePressed("dialog_btn_yes_2.png");
btn1->setPosition(Vec2(this->getContentSize().width / 2 - 90, 45));
btn1->setEnabled(false);
btn1->addTouchEventListener(CC_CALLBACK_2(DialogNode::onButton, this));
btn1->setTag((int)ChildTag::BTN_1);
btn1->setTitleFontName(GAME_CONFIG_GLOBAL_FONTNAME_01);
btn1->setTitleFontSize(32.0f);
btn1->setTitleText(btn1Text.c_str());
btn1->setScale(0.75);
this->addChild(btn1);
Button *btn2 = Button::create();
btn2->loadTextureNormal("dialog_btn_no_1.png");
btn2->loadTexturePressed("dialog_btn_no_2.png");
btn2->setPosition(Vec2(this->getContentSize().width / 2 + 90, 45));
btn2->setEnabled(false);
btn2->addTouchEventListener(CC_CALLBACK_2(DialogNode::onButton, this));
btn2->setTag((int)ChildTag::BTN_2);
btn2->setTitleFontName(GAME_CONFIG_GLOBAL_FONTNAME_01);
btn2->setTitleFontSize(32.0f);
btn2->setTitleText(btn2Text.c_str());
btn2->setScale(0.75);
this->addChild(btn2);
}
else
{
//1个按钮
Button *btn1 = Button::create();
btn1->loadTextureNormal("dialog_btn_yes_1.png");
btn1->loadTexturePressed("dialog_btn_yes_2.png");
btn1->setPosition(Vec2(this->getContentSize().width / 2, 45));
btn1->setEnabled(false);
btn1->addTouchEventListener(CC_CALLBACK_2(DialogNode::onButton, this));
btn1->setTag((int)ChildTag::BTN_1);
btn1->setTitleFontName(GAME_CONFIG_GLOBAL_FONTNAME_01);
btn1->setTitleFontSize(32.0f);
btn1->setTitleText(btn1Text.c_str());
btn1->setScale(0.75);
this->addChild(btn1);
}
this->runAction(Sequence::createWithTwoActions(EaseElasticOut::create(ScaleTo::create(1, 1)), CallFunc::create(CC_CALLBACK_0(DialogNode::showActEnd, this))));
return true;
}
return false;
}
示例12: QColor
StepsNewGesture::StepsNewGesture(ExecutionManager *pExecutionManager, int pNumberOfGesture, QWidget *parent)
{
int labelFontSize = 23;
QColor labelColor = QColor(210,210,210);
this->executionManager = pExecutionManager;
this->commandChooser = new CommandChooser(parent);
this->stepper = new StepperNewGesture(this->executionManager, this->commandChooser, pNumberOfGesture, parent);
/* Local */
QString locale = QLocale::system().name().section('_', 0, 0);
XmlConf* conf = Xml().importConfig(Utils::getConfigLocation());
if (conf != NULL)
{
if (conf->language != NULL)
{
locale = conf->language;
}
}
if (locale.compare("en") != 0 && locale.compare("fr") != 0)
{
locale = "en";
}
/* STEP 0 */
QWidget *step = new QWidget(stepper);
QVBoxLayout* vLayoutStep = new QVBoxLayout(step);
vLayoutStep->setMargin(0);
Label* lblStepTop = new Label(tr("\n\nThe recording of a gesture MUST start and end with a neutral stance.\n\n"),step);
lblStepTop->setTextColor(labelColor);
lblStepTop->changeFontSize(16);
lblStepTop->setPaintShadow(false);
lblStepTop->setFixedHeight(60);
lblStepTop->setPaintShadow(false);
QLabel *picNeutral = new QLabel(step);
QPixmap pix = QPixmap(Utils::getResourcesDirectory() + "/tuto/neutral_" + locale + ".png");
picNeutral->setPixmap(pix);
vLayoutStep->addWidget(lblStepTop);
vLayoutStep->addWidget(picNeutral);
stepper->addStep(tr("Information"),true,false,true, StepperNewGesture::First ,step);
/* STEP 1 */
Label *step1 = new Label(tr("You will have 5 seconds to place\nbefore registering your gesture\n1/") + QString::number(pNumberOfGesture),stepper);
step1->changeFontSize(labelFontSize);
step1->setTextColor(labelColor);
step1->setPaintShadow(false);
stepper->addStep(tr("Add a new gesture"),true,true,true, StepperNewGesture::StartTimer ,step1);
/* STEP 2 */
Label *step2 = new Label(tr("Ready ?"),stepper);
step2->changeFontSize(labelFontSize);
step2->setTextColor(labelColor);
step2->setPaintShadow(false);
stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::StartRecording ,step2);
/* STEP 3 */
QWidget* step3 = new QWidget(parent);
QVBoxLayout* vLayoutStep3 = new QVBoxLayout(step3);
GlView* glViewStep3= new GlView(step3);
DAOLayer* dao = DAOLayer::getInstance();
connect(dao, SIGNAL(skeletonDataReceived(QString)), glViewStep3,SLOT(skeletonDataReceived(QString)));
Label* labelStep3 = new Label(tr("Realtime visualizer"), step3);
labelStep3->setFixedHeight(50);
labelStep3->changeFontSize(labelFontSize);
labelStep3->setTextColor(labelColor);
labelStep3->setPaintShadow(false);
vLayoutStep3->addWidget(labelStep3);
vLayoutStep3->addWidget(glViewStep3);
glViewStep3->startAnimating();
stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::VisualizeRecording ,step3);
/* STEP 4 */
QWidget* step4 = new QWidget(parent);
QVBoxLayout* vLayoutStep4 = new QVBoxLayout(step4);
this->glViewStep4= new GlView(step4);
connect(this->executionManager, SIGNAL(gestureRecorded(Gesture*)), this, SLOT(gestureReceived(Gesture*)));
Label *labelStep4 = new Label(tr("Is it the right gesture ?"),stepper);
labelStep4->setFixedHeight(50);
labelStep4->changeFontSize(labelFontSize);
labelStep4->setTextColor(labelColor);
labelStep4->setPaintShadow(false);
vLayoutStep4->addWidget(labelStep4);
vLayoutStep4->addWidget(this->glViewStep4);
this->glViewStep4->startAnimating();
stepper->addStep(tr("Add a new gesture"),true,true,true,StepperNewGesture::ConfigureAction,step4);
/* STEP 5 */
QWidget* step5 = new QWidget(parent);
QVBoxLayout* vLayout = new QVBoxLayout(step5);
QWidget* step5Bottom = new QWidget(step5);
QHBoxLayout* hLayoutStep5 = new QHBoxLayout(step5Bottom);
this->commandChooser->setParent(step5Bottom);
ComboBox *combo = this->commandChooser->getCommandComboBox();
KeyListener *keyListener = this->commandChooser->getCommandKeyListener();
TextField *tfNewGesture = this->commandChooser->getCommandTextField();
ButtonElement *btnCommand = this->commandChooser->getCommandButton();
//.........这里部分代码省略.........
示例13: Vec2
// メッセージを生成
Label* CharacterMessageLayer::createMessage()
{
CharacterMessageData* data {this->datas.front()};
// フレームの位置を戻す
this->frame->stopAllActions();
this->frame->setPosition(this->defaultMFramePosition);
// リアクション
if(data->getOption() == CharacterMessageData::Option::REACTION)
{
// 白いエフェクトを出してフェードアウト
Sprite* white { Sprite::create() };
white->setTextureRect(Rect(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT));
white->setColor(Color3B::WHITE);
white->setPosition(white->getContentSize() / 2);
this->addChild(white);
this->reactionEffect = white;
white->runAction(Sequence::createWithTwoActions(FadeOut::create(1.f), RemoveSelf::create()));
// フレームを揺らす
Action* swingAction { RepeatForever::create(Sequence::createWithTwoActions(MoveBy::create(0.05f, Vec2(10.f, 0)), MoveBy::create(0.05f, Vec2(-10.f, 0)))) };
this->frame->runAction(swingAction);
this->runAction(Sequence::create(DelayTime::create(1.5f),CallFunc::create([this, swingAction]
{
this->stopAction(swingAction);
if(_closed) return;
this->frame->setPosition(this->defaultMFramePosition);
}), nullptr));
SoundManager::getInstance()->playSE("msg_reaction.mp3", 0.5f);
}
// ボイスがあれば鳴らす
string voiceFileName = data->getVoiceFileName();
if (voiceFileName != "") {
SoundManager::getInstance()->playVoice(voiceFileName);
}
// キャラクター画像
if(this->charaImg)
{
this->charaImg->removeFromParent();
this->charaImg = nullptr;
}
if(data->getImageName() == "") {
string charaImgName = CsvDataManager::getInstance()->getCharacterData()->getFileName(data->getCharaId()) + ((data->isMiniChara())? "_m_" : "_s_") + to_string(data->getImgId()) + ".png" ;
Point charaImgPoint = (data->isMiniChara())? Point(WINDOW_WIDTH * 4 / 5, WINDOW_HEIGHT * 7 / 40) : Point(WINDOW_WIDTH * 3 / 4, 0);
if(data->getCharaId() != -1 && SpriteFrameCache::getInstance()->getSpriteFrameByName(charaImgName))
{
Sprite* img { Sprite::createWithSpriteFrameName(charaImgName)};
img->setPosition(charaImgPoint);
img->setLocalZOrder((data->isMiniChara()) ? 1 : -1);
this->addChild(img);
this->charaImg = img;
}
} else {
Sprite* img {Sprite::create(Resource::SpriteFrame::BASE_PATH + "disp/" + data->getImageName())};
img->setPosition(WINDOW_CENTER);
img->setLocalZOrder((data->isImageOnly()) ? 1 : -1);
img->setOpacity(0);
this->addChild(img);
img->runAction(FadeIn::create(0.5f));
}
// キャラクター名
this->nameFrame->removeAllChildren();
Label* name { Label::createWithTTF(data->getCharaName(), "fonts/cinecaption2.28.ttf", 26.f)};
this->nameFrame->addChild(name);
// キャラクター名の長さによってキャラクター名用枠の大きさ、位置を変える
this->nameFrame->setContentSize(Size(name->getContentSize().width + H_MARGIN_S * 2, this->nameFrame->getContentSize().height));
this->nameFrame->setPosition(this->nameFrame->getContentSize().width / 2 + LEFT_MARGIN / 4, this->frame->getContentSize().height + this->nameFrame->getContentSize().height / 2);
name->setPosition(this->nameFrame->getContentSize() / 2);
// メッセージ本文
Label* message = Label::createWithTTF(data->getMessage(), "fonts/cinecaption2.28.ttf", 24.f);
message->setLineHeight(36.f);
message->setHorizontalAlignment(TextHAlignment::LEFT);
message->setVerticalAlignment(TextVAlignment::TOP);
message->setPosition(Point(message->getContentSize().width / 2 + LEFT_MARGIN, this->frame->getContentSize().height - message->getContentSize().height / 2 - TOP_MARGIN));
this->frame->addChild(message);
if(data->isImageOnly()){
this->removeChildByTag(MAIN_FRAME_TAG);
this->removeChildByTag(NAME_FRAME_TAG);
_closed = true;
}
if(!this->datas.front()->hasNextPage())
{
CC_SAFE_RELEASE(this->datas.front());
this->datas.pop();
}
//.........这里部分代码省略.........
示例14:
bool operator==(const Label& left, const Label& right)
{
return left.key() == right.key() && left.value() == right.value();
}
示例15: memnew
SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open_instance) {
undo_redo=NULL;
tree_dirty=true;
selected=NULL;
marked_selectable=false;
marked_children_selectable=false;
can_rename=p_can_rename;
can_open_instance=p_can_open_instance;
display_foreign=false;
editor_selection=NULL;
if (p_label) {
Label *label = memnew( Label );
label->set_pos( Point2(10, 0));
label->set_text("Scene Tree (Nodes):");
add_child(label);
}
tree = memnew( Tree );
tree->set_anchor( MARGIN_RIGHT, ANCHOR_END );
tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
tree->set_begin( Point2(0,p_label?18:0 ));
tree->set_end( Point2(0,0 ));
add_child( tree );
tree->connect("cell_selected", this,"_selected_changed");
tree->connect("item_edited", this,"_renamed");
tree->connect("multi_selected",this,"_cell_multi_selected");
tree->connect("button_pressed",this,"_cell_button_pressed");
// tree->connect("item_edited", this,"_renamed",Vector<Variant>(),true);
error = memnew( AcceptDialog );
add_child(error);
show_enabled_subscene=false;
last_hash=0;
pending_test_update=false;
updating_tree=false;
blocked=0;
instance_menu = memnew( PopupMenu );
instance_menu->add_check_item("Editable Children",SCENE_MENU_EDITABLE_CHILDREN);
instance_menu->add_check_item("Load As Placeholder",SCENE_MENU_USE_PLACEHOLDER);
instance_menu->add_separator();
instance_menu->add_item("Open in Editor",SCENE_MENU_OPEN);
instance_menu->connect("item_pressed",this,"_subscene_option");
add_child(instance_menu);
inheritance_menu = memnew( PopupMenu );
inheritance_menu->add_item("Clear Inheritance",SCENE_MENU_CLEAR_INHERITANCE);
inheritance_menu->add_separator();
inheritance_menu->add_item("Open in Editor",SCENE_MENU_OPEN_INHERITED);
inheritance_menu->connect("item_pressed",this,"_subscene_option");
add_child(inheritance_menu);
clear_inherit_confirm = memnew( ConfirmationDialog );
clear_inherit_confirm->set_text("Clear Inheritance? (No Undo!)");
clear_inherit_confirm->get_ok()->set_text("Clear!");
add_child(clear_inherit_confirm);
}