本文整理汇总了C++中tlistbox类的典型用法代码示例。如果您正苦于以下问题:C++ tlistbox类的具体用法?C++ tlistbox怎么用?C++ tlistbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tlistbox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: city_changed
void tside_report::city_changed(twindow& window, tlistbox& list, const int type)
{
if (candidate_cities_.empty()) {
return;
}
twidget* grid_ptr = list.get_row_panel(list.get_selected_row());
unsigned int selected_row = dynamic_cast<ttoggle_panel*>(grid_ptr)->get_data();
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:9,代码来源:side_report.cpp
示例2: add_row
void tbrowse::add_row(twindow& window, tlistbox& list, const std::string& name, bool dir)
{
std::stringstream ss;
string_map list_item;
std::map<std::string, string_map> list_item_item;
list_item["label"] = "misc/open.png~SCALE(32, 32)";
list_item_item.insert(std::make_pair("open", list_item));
ss << tintegrate::generate_img(get_browse_icon(dir) + "~SCALE(24, 24)") << name;
list_item["label"] = ss.str();
list_item_item.insert(std::make_pair("name", list_item));
list_item["label"] = "---";
list_item_item.insert(std::make_pair("date", list_item));
list_item["label"] = dir? null_str: "---";
list_item_item.insert(std::make_pair("size", list_item));
list.add_row(list_item_item);
int index = list.get_item_count() - 1;
ttoggle_panel* panel = dynamic_cast<ttoggle_panel*>(list.get_row_panel(index));
tbutton* button = find_widget<tbutton>(panel, "open", false, true);
if (dir) {
connect_signal_mouse_left_click(
*button
, boost::bind(
&tbrowse::open
, this
, boost::ref(window)
, _3
, _4
, (int)true
, (int)index));
panel->connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(boost::bind(
&tbrowse::open
, this
, boost::ref(window)
, _3
, _4
, (int)true
, (int)index)
, event::tdispatcher::back_pre_child);
} else {
button->set_visible(twidget::HIDDEN);
button->set_active(false);
}
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:53,代码来源:browse.cpp
示例3: add_row_to_heros
void ttent::add_row_to_heros(tlistbox& list, int h, int leader, int city, int stratum)
{
// Add list item
string_map list_item;
std::map<std::string, string_map> list_item_item;
if (!rpg_mode_) {
list_item["label"] = heros_[h].image();
list_item_item.insert(std::make_pair("icon", list_item));
}
if (h != player_hero_->number_) {
list_item["label"] = heros_[h].name();
} else {
list_item["label"] = player_hero_->name();
}
list_item_item.insert(std::make_pair("name", list_item));
if (leader != -1) {
list_item["label"] = heros_[leader].name();
} else {
list_item["label"] = "---";
}
list_item_item.insert(std::make_pair("side", list_item));
if (city != -1) {
list_item["label"] = heros_[city].name();
} else {
list_item["label"] = "---";
}
list_item_item.insert(std::make_pair("city", list_item));
list_item["label"] = hero::stratum_str(stratum);
list_item_item.insert(std::make_pair("stratum", list_item));
list.add_row(list_item_item);
if (rpg_mode_) {
tgrid* grid_ptr = list.get_row_grid(mem_vsize_);
tcontrol* control = dynamic_cast<tcontrol*>(grid_ptr->find("icon", true));
control->set_visible(twidget::INVISIBLE);
}
rows_mem_[mem_vsize_].hero_ = h;
rows_mem_[mem_vsize_].leader_ = leader;
rows_mem_[mem_vsize_].city_ = city;
rows_mem_[mem_vsize_ ++].stratum_ = stratum;
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:48,代码来源:tent.cpp
示例4: add_row_to_factions
void ttent::add_row_to_factions(tlistbox& list, const config& cfg)
{
// Add list item
string_map list_item;
std::map<std::string, string_map> list_item_item;
int number = cfg["leader"].to_int();
list_item["label"] = heros_[number].image();
list_item_item.insert(std::make_pair("icon", list_item));
const config& art_cfg = cfg.child("artifical");
std::vector<std::string> vstr = utils::split(art_cfg["service_heros"].str());
list_item["label"] = lexical_cast_default<std::string>(vstr.size());
list_item_item.insert(std::make_pair("fresh", list_item));
vstr = utils::split(art_cfg["wander_heros"].str());
list_item["label"] = lexical_cast_default<std::string>(vstr.size());
list_item_item.insert(std::make_pair("wander", list_item));
number = art_cfg["heros_army"].to_int();
list_item["label"] = heros_[number].name();
list_item_item.insert(std::make_pair("city", list_item));
list.add_row(list_item_item);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:25,代码来源:tent.cpp
示例5: type_selected
void temploy::type_selected(twindow& window, tlistbox& list, const int type)
{
cursel_ = list.get_selected_row();
set_ok_active(window);
refresh_tooltip(window);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:8,代码来源:employ.cpp
示例6: item_selected
void tinapp_purchase::item_selected(twindow& window, tlistbox& list, const int type)
{
twindow::tinvalidate_layout_blocker blocker(window);
int cursel = list.get_selected_row();
purchase_->set_active(!browse_ && operating_anim_ == twidget::npos);
refresh_tip(window, items_[cursel]);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:10,代码来源:inapp_purchase.cpp
示例7: campaign_selected
void tcampaign_selection::campaign_selected(twindow& window, tlistbox& list, const int type)
{
const int selected_row = list.get_selected_row();
tscrollbar_panel& multi_page = find_widget<tscrollbar_panel>(&window, "campaign_details", false);
tscroll_label& label = find_widget<tscroll_label>(&window, "description", false);
label.set_label(campaigns_[selected_row].description);
tcontrol& image = find_widget<tcontrol>(&window, "image", false);
image.set_label(campaigns_[selected_row].image);
window.invalidate_layout();
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:14,代码来源:campaign_selection.cpp
示例8: fill_local
void tgame_load::fill_local(twindow& window, tlistbox& list)
{
find_widget<tcontrol>(&window, "delete", false).set_active(true);
find_widget<tcontrol>(&window, "ok", false).set_active(true);
std::string str = tintegrate::generate_format(_("Upload"), "blue");
find_widget<tcontrol>(&window, "xmit", false).set_label(str);
{
cursor::setter cur(cursor::WAIT);
games_ = savegame::manager::get_saves_list();
}
list.clear();
BOOST_FOREACH (const savegame::save_info game, games_) {
std::map<std::string, string_map> data;
string_map item;
item["label"] = game.name;
data.insert(std::make_pair("filename", item));
item["label"] = game.format_time_summary();
data.insert(std::make_pair("date", item));
list.add_row(data);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:24,代码来源:game_load.cpp
示例9: type_selected
void texpedite::type_selected(twindow& window, tlistbox& list, const int type)
{
tbutton* task = find_widget<tbutton>(&window, "task", false, true);
tbutton* ok = find_widget<tbutton>(&window, "ok", false, true);
// prevent visible/disable disband button from layouting window.
twindow::tinvalidate_layout_blocker invalidate_layout_blocker(window);
list.invalidate_layout(false);
troop_index_ = list.get_selected_row();
refresh_tooltip(window);
// There is maybe no troop after disband. so troop_index_ maybe equal -1.
if (troop_index_ >= 0) {
int size = city_.reside_troops().size();
const unit& u = *city_.reside_troops()[troop_index_];
for (int index = 0; index < size; index ++) {
twidget* grid_ptr = list.get_row_panel(index);
// tbutton& disband = find_widget<tbutton>(&window, "disband", false);
tbutton& disband = *dynamic_cast<tbutton*>(grid_ptr->find("disband", false));
if (index == troop_index_) {
disband.set_visible(twidget::VISIBLE);
disband.set_active(u.human());
} else {
disband.set_visible(twidget::INVISIBLE);
}
}
set_task_str(window, u);
ok->set_active(u.human() && can_move(u));
} else {
task->set_active(false);
ok->set_active(false);
}
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:36,代码来源:expedite.cpp
示例10: display_savegame
void tgame_load::display_savegame(twindow& window, tlistbox& list)
{
const int selected_row = list.get_selected_row();
twidget& preview_pane =
find_widget<twidget>(&window, "preview_pane", false);
if (selected_row == -1) {
preview_pane.set_visible(twidget::HIDDEN);
} else if (current_page_ == LOCAL_PAGE) {
preview_pane.set_visible(twidget::VISIBLE);
savegame::save_info& game = games_[selected_row];
filename_ = game.name;
config cfg_summary;
std::string dummy;
try {
savegame::manager::load_summary(game.name, cfg_summary, &dummy);
} catch(game::load_game_failed&) {
cfg_summary["corrupt"] = "yes";
}
find_widget<timage>(&window, "imgLeader", false).
set_label(cfg_summary["leader_image"]);
find_widget<tminimap>(&window, "minimap", false).
set_map_data(tminimap::TILE_MAP, cfg_summary["map_data"]);
find_widget<tscroll_label>(&window, "lblSummary", false).set_label(generate_summary(game.name, cfg_summary));
// window.invalidate_layout();
} else if (current_page_ == NETWORK_PAGE) {
preview_pane.set_visible(twidget::VISIBLE);
savegame::www_save_info& game = www_saves_[selected_row];
filename_ = game.name;
find_widget<tminimap>(&window, "minimap", false).set_map_data(tminimap::TILE_MAP, "");
find_widget<tscroll_label>(&window, "lblSummary", false).set_label(generate_summary(game.name, null_cfg));
}
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:45,代码来源:game_load.cpp
示例11: item_selected
void tbrowse::item_selected(twindow& window, tlistbox& list, const int type)
{
int row = list.get_selected_row();
tristate dir = t_unset;
if (row >= 0) {
std::set<tfile>::const_iterator it;
if (row < (int)dirs_in_current_dir_.size()) {
dir = t_true;
it = dirs_in_current_dir_.begin();
} else {
dir = t_false;
it = files_in_current_dir_.begin();
row -= dirs_in_current_dir_.size();
}
std::advance(it, row);
selected_ = it->name;
} else {
selected_.empty();
}
set_ok_active(window, dir);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:23,代码来源:browse.cpp
示例12: fill_table
void tside_report::fill_table(tlistbox& list, int catalog)
{
for (std::vector<artifical*>::const_iterator it = candidate_cities_.begin(); it != candidate_cities_.end(); ++ it) {
artifical& city = **it;
std::stringstream str;
/*** Add list item ***/
string_map table_item;
std::map<std::string, string_map> table_item_item;
str.str("");
str << city.name();
str << "(Lv";
str << tintegrate::generate_format(city.level(), "green");
str << ")";
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("name", table_item));
if (catalog == STATUS_PAGE) {
str.str("");
if (city.hitpoints() < city.max_hitpoints() / 2) {
str << tintegrate::generate_format(city.hitpoints(), "red");
} else if (city.hitpoints() < city.max_hitpoints()) {
str << tintegrate::generate_format(city.hitpoints(), "yellow");
} else {
str << city.hitpoints();
}
str << "/" << city.max_hitpoints();
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("hp", table_item));
str.str("");
str << city.experience() << "/";
if (city.can_advance()) {
str << city.max_experience();
} else {
str << "-";
}
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("xp", table_item));
str.str("");
str << tintegrate::generate_format(city.fresh_heros().size(), "green");
str << "/";
str << tintegrate::generate_format(city.finish_heros().size(), "red");
str << "/";
str << tintegrate::generate_format(city.wander_heros().size(), "yellow");
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("hero", table_item));
str.str("");
str << tintegrate::generate_format(city.reside_troops().size(), "yellow");
str << "/";
str << city.field_troops().size();
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("troop", table_item));
str.str("");
str << tintegrate::generate_format(city.total_gold_income(current_team_.market_increase_), "yellow");
str << "/";
str << tintegrate::generate_format(city.total_technology_income(current_team_.technology_increase_), "green");
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("income", table_item));
size_t built = 0;
size_t building = 0;
const std::vector<map_location>& ea = city.economy_area();
for (std::vector<map_location>::const_iterator it2 = ea.begin(); it2 != ea.end(); ++ it2) {
unit* u = units_.find_unit(*it2);
if (!u || !hero::is_ea_artifical(u->type()->master())) {
continue;
}
if (u->get_state(ustate_tag::BUILDING)) {
building ++;
} else {
built ++;
}
}
str.str("");
str << tintegrate::generate_format(building + built, building? "yellow": "green");
str << "/";
if (building + built != ea.size()) {
str << tintegrate::generate_format(ea.size(), "red");
} else {
str << ea.size();
}
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("ea", table_item));
}
list.add_row(table_item_item);
unsigned hero_index = list.get_item_count() - 1;
twidget* grid_ptr = list.get_row_panel(hero_index);
ttoggle_panel* toggle = dynamic_cast<ttoggle_panel*>(grid_ptr);
toggle->set_data(hero_index);
}
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:97,代码来源:side_report.cpp
示例13: type_selected
void tfinal_battle::type_selected(twindow& window, tlistbox& list, const int type)
{
type_index_ = list.get_selected_row();
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:4,代码来源:final_battle.cpp
示例14: fill_table
void thero_selection::fill_table(tlistbox& list, int catalog)
{
std::vector<int> features;
std::stringstream str;
std::string color;
hero& leader = *(*teams_)[side_ - 1].leader();
int hero_index = 0;
for (std::vector<std::pair<int, unit*> >::iterator itor = pairs_.begin(); itor != pairs_.end(); ++ itor, hero_index ++) {
/*** Add list item ***/
string_map table_item;
std::map<std::string, string_map> table_item_item;
hero& h = heros_[itor->first];
unit& u = *itor->second;
int catalog_diff = posix_abs((int)leader.base_catalog_ - h.base_catalog_);
if (catalog_diff > HERO_MAX_LOYALTY / 2) {
catalog_diff = HERO_MAX_LOYALTY - catalog_diff;
}
if (catalog == OWNERSHIP_PAGE) {
table_item["label"] = h.name();
table_item_item.insert(std::make_pair("name", table_item));
if (h.side_ != HEROS_INVALID_SIDE) {
table_item["label"] = (*teams_)[h.side_].name();
} else {
table_item["label"] = "---";
}
table_item_item.insert(std::make_pair("side", table_item));
artifical* city = units_? units_->city_from_cityno(h.city_): NULL;
if (city) {
table_item["label"] = city->name();
} else {
table_item["label"] = "---";
}
table_item_item.insert(std::make_pair("city", table_item));
str.str("");
if (h.side_ != HEROS_INVALID_SIDE) {
str << h.loyalty(leader);
} else {
str << "--";
}
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("loyalty", table_item));
str.str("");
str << (int)h.base_catalog_;
if (HERO_MAX_LOYALTY - catalog_diff >= game_config::move_loyalty_threshold) {
color = "green";
} else if (HERO_MAX_LOYALTY - catalog_diff >= game_config::wander_loyalty_threshold) {
color = "yellow";
} else {
color = "red";
}
str << "(" << tintegrate::generate_format(catalog_diff, color) << ")";
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("hero_catalog", table_item));
str.str("");
if (!u.is_artifical()) {
str << u.name() << _("name^Troop");
} else if (u.is_city()) {
str << u.name();
} else {
str << u.name() << u.type_name();
}
table_item["label"] = str.str();
table_item_item.insert(std::make_pair("position", table_item));
table_item["label"] = lexical_cast<std::string>(h.meritorious_);
table_item_item.insert(std::make_pair("meritorious", table_item));
} else if (catalog == ABILITY_PAGE) {
table_item["label"] = h.name();
table_item_item.insert(std::make_pair("name", table_item));
table_item["label"] = lexical_cast<std::string>(fxptoi9(h.leadership_));
table_item_item.insert(std::make_pair("leadership", table_item));
table_item["label"] = lexical_cast<std::string>(fxptoi9(h.force_));
table_item_item.insert(std::make_pair("force", table_item));
table_item["label"] = lexical_cast<std::string>(fxptoi9(h.intellect_));
table_item_item.insert(std::make_pair("intellect", table_item));
table_item["label"] = lexical_cast<std::string>(fxptoi9(h.spirit_));
table_item_item.insert(std::make_pair("spirit", table_item));
table_item["label"] = lexical_cast<std::string>(fxptoi9(h.charm_));
table_item_item.insert(std::make_pair("charm", table_item));
table_item["label"] = hero::status_str(h.status_);
table_item_item.insert(std::make_pair("action", table_item));
} else if (catalog == FEATURE_PAGE) {
table_item["label"] = h.name();
//.........这里部分代码省略.........
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:101,代码来源:hero_selection.cpp
示例15: init_player_list
void ttent::init_player_list(tlistbox& list, twindow& window)
{
if (player_hero_->valid() && rpg_mode_) {
rows_mem_ = (hero_row*)malloc(sizeof(hero_row) * (heros_.size() + 1));
add_row_to_heros(list, player_hero_->number_, -1, -1, hero_stratum_citizen);
} else {
rows_mem_ = (hero_row*)malloc(sizeof(hero_row) * heros_.size());
}
std::string text;
config cfg_from_file;
wml_config_from_file(game_config::path + "/xwml/campaigns/" + campaign_config_["id"].str() + ".bin", cfg_from_file);
const config& scenario = cfg_from_file.child("scenario");
std::map<int, int> mayor_map;
std::vector<std::string> v;
int leader, city, stratum;
foreach (const config& side, scenario.child_range("side")) {
// city_map_.clear();
leader = side["leader"].to_int();
if (side.has_attribute("controller")) {
text = side["controller"].str();
if (text != "human") {
continue;
}
}
foreach (const config& c, side.child_range("artifical")) {
int mayor = -1;
if (c.has_attribute("mayor")) {
mayor = c["mayor"].to_int();
}
city = c["heros_army"].to_int();
int cityno = c["cityno"].to_int();
city_map_[cityno] = city;
city_leader_map_[cityno] = leader;
mayor_map[cityno] = mayor;
// service_heros
v = utils::split(c["service_heros"].str());
for (std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++ it) {
int h = lexical_cast_default<int>(*it);
if (h == leader) {
stratum = hero_stratum_leader;
} else if (h == mayor) {
stratum = hero_stratum_mayor;
} else {
stratum = hero_stratum_citizen;
}
if (rpg_mode_ || stratum == hero_stratum_leader) {
add_row_to_heros(list, h, leader, city, stratum);
}
}
if (rpg_mode_) {
// wander_heros
v = utils::split(c["wander_heros"].str());
for (std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++ it) {
int h = lexical_cast_default<int>(*it);
stratum = hero_stratum_wander;
// add_row_to_heros(list, h, leader, city, stratum);
}
}
}
// unit. they maybe leader
foreach (const config& u, side.child_range("unit")) {
v = utils::split(u["heros_army"].str());
for (std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++ it) {
int cityno = u["cityno"].to_int();
if (cityno == HEROS_DEFAULT_CITY) {
continue;
}
int h = lexical_cast_default<int>(*it);
std::map<int, int>::const_iterator it2 = mayor_map.find(cityno);
VALIDATE(it2 != mayor_map.end(), "Cannot find cityno = " + u["cityno"].str() + " duration parseing " + heros_[h].name());
int mayor = it2->second;
if (h == leader) {
stratum = hero_stratum_leader;
} else if (h == mayor) {
stratum = hero_stratum_mayor;
} else {
stratum = hero_stratum_citizen;
}
if (rpg_mode_ || stratum == hero_stratum_leader) {
std::map<int, int>::const_iterator it2 = city_map_.find(cityno);
VALIDATE(it2 != city_map_.end(), "Cannot find cityno = " + u["cityno"].str() + " duration parseing " + heros_[h].name());
add_row_to_heros(list, h, leader, it2->second, stratum);
}
}
}
}
list.set_callback_value_change(dialog_callback<ttent, &ttent::player_selected>);
// disable all sort button
tbutton* button = find_widget<tbutton>(&window, "hero_name", false, true);
button->set_active(false);
button = find_widget<tbutton>(&window, "hero_stratum", false, true);
button->set_active(false);
button = find_widget<tbutton>(&window, "hero_side", false, true);
button->set_active(false);
//.........这里部分代码省略.........
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:101,代码来源:tent.cpp
示例16: page_selected
void tpreferences::page_selected(twindow& window, tlistbox& list, const int type)
{
page_ = list.get_selected_row();
swap_page(window, page_, true);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:6,代码来源:preferences.cpp
示例17: type_selected
void trpg_detail::type_selected(twindow& window, tlistbox& list, const int type)
{
troop_index_ = list.get_selected_row();
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:4,代码来源:rpg_detail.cpp
示例18: add_row_to_stuff_list
void add_row_to_stuff_list(const std::string& id, const std::string& label)
{
std::map<std::string, string_map> data;
string_map item;
item["id"] = id;
item["label"] = label;
data.insert(std::make_pair("name", item));
stuff_list->add_row(data);
}
开发者ID:AI0867,项目名称:wesnoth,代码行数:9,代码来源:gamestate_inspector.cpp
示例19: add_side
void add_side(int side_num, const std::string& label)
{
sides.push_back(side_num);
DBG_GUI << "Sides list: adding item (side_num: \"" << side_num
<< "\" label: \"" << label << "\")\n";
std::map<std::string, string_map> data;
string_map item;
item["id"] = std::string("side_") + str_cast(side_num);
item["label"] = label;
item["use_markup"] = "true";
data.insert(std::make_pair("side", item));
sides_list->add_row(data);
}
开发者ID:sunny975,项目名称:wesnoth,代码行数:13,代码来源:mp_change_control.cpp
示例20: add_nick
void add_nick(const std::string& nick, const std::string& label)
{
DBG_GUI << "Nicks list: adding item (nick: \"" << nick << "\" label: \""
<< label << "\")\n";
nicks.push_back(nick);
std::map<std::string, string_map> data;
string_map item;
item["id"] = nick;
item["label"] = label;
item["use_markup"] = "true";
data.insert(std::make_pair("nick", item));
nicks_list->add_row(data);
}
开发者ID:sunny975,项目名称:wesnoth,代码行数:13,代码来源:mp_change_control.cpp
注:本文中的tlistbox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论