Пример #1
0
void feature_notify_handler_rclick(HWND hdlgP, int DlgItem, LPNMHDR lpNMHdr)
{
	LVITEM					lvi;
	LPNMITEMACTIVATE		lpnmitem;

	if (lpNMHdr->idFrom != IDC_LV_FEATURE_COMPLEX) {
		return;
	}

	// NM_表示对通用控件都通用,范围丛(0, 99)
	// TVN_表示只能TreeView通用,范围丛(400, 499)
	lpnmitem = (LPNMITEMACTIVATE)lpNMHdr;
	// 如果单击到的是复选框位置,把复选框状态置反
	// 当前定义的图标大小是16x16. ptAction反回的(x,y)是整个列表视图内的坐标,因而y值不大好判断
	// 认为如果x是小于16的就认为是击中复选框
	
	POINT point = {lpnmitem->ptAction.x, lpnmitem->ptAction.y};
	MapWindowPoints(lpNMHdr->hwndFrom, NULL, &point, 1);

	lvi.iItem = lpnmitem->iItem;
	lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
	lvi.iSubItem = 0;
	lvi.pszText = gdmgr._menu_text;
	lvi.cchTextMax = _MAX_PATH;
	ListView_GetItem(lpNMHdr->hwndFrom, &lvi);

	HMENU hpopup = CreatePopupMenu();

	if (lpNMHdr->idFrom == IDC_LV_FEATURE_COMPLEX) {
		AppendMenu(hpopup, MF_STRING, IDM_ADD, utf8_2_ansi(_("Append after it")));
		AppendMenu(hpopup, MF_STRING, IDM_EDIT, utf8_2_ansi(_("Edit...")));
		AppendMenu(hpopup, MF_STRING, IDM_DELETE, utf8_2_ansi(_("Delete...")));

		if (lpnmitem->iItem < 0) {
			EnableMenuItem(hpopup, IDM_ADD, MF_BYCOMMAND | MF_GRAYED);
			EnableMenuItem(hpopup, IDM_EDIT, MF_BYCOMMAND | MF_GRAYED);
			EnableMenuItem(hpopup, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED);
		}
	}

	TrackPopupMenuEx(hpopup, 0, 
		point.x, 
		point.y, 
		hdlgP, 
		NULL);

	DestroyMenu(hpopup);

	ns::type = DlgItem;
	ns::clicked_feature = lpnmitem->iItem;

    return;
}
Пример #2
0
BOOL On_DlgFormationInitDialog(HWND hdlgP, HWND hwndFocus, LPARAM lParam)
{
	HWND hwndParent = GetParent(hdlgP); 
    DLGHDR *pHdr = (DLGHDR *) GetWindowLong(hwndParent, GWL_USERDATA);
    SetWindowPos(hdlgP, HWND_TOP, pHdr->rcDisplay.left, pHdr->rcDisplay.top, 0, 0, SWP_NOSIZE); 

	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_CANDIDATE), utf8_2_ansi(_("Candidate")));
	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_OFFICE), utf8_2_ansi(_("Office")));
	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_WANDER), utf8_2_ansi(_("Wander")));

	return FALSE;
}
Пример #3
0
void fill_row(HWND hctl, hero& h)
{
	std::stringstream strstr;
	char text[_MAX_PATH];
	LVITEM lvi;
	int column = 0;

	lvi.mask = LVIF_TEXT | LVIF_PARAM;
	// 姓名
	lvi.iItem = ListView_GetItemCount(hctl);
	lvi.iSubItem = column ++;
	int number = h.number_;
	strstr.str("");
	strstr << std::setfill('0') << std::setw(3) << number << ": " << h.name();
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvi.pszText = text;
	lvi.lParam = (LPARAM)h.number_;
	ListView_InsertItem(hctl, &lvi);

	// 相性
	lvi.mask = LVIF_TEXT;
	lvi.iSubItem = column ++;
	strstr.str("");
	int value = h.base_catalog_;
	strstr << value;
	strcpy(text, strstr.str().c_str());
	lvi.pszText = text;
	ListView_SetItem(hctl, &lvi);

	// 特技
	lvi.mask = LVIF_TEXT;
	lvi.iSubItem = column ++;
	strcpy(text, utf8_2_ansi(hero::feature_str(h.feature_).c_str()));
	lvi.pszText = text;
	ListView_SetItem(hctl, &lvi);

	// 势力特技
	lvi.mask = LVIF_TEXT;
	lvi.iSubItem = column ++;
	strcpy(text, utf8_2_ansi(hero::feature_str(h.side_feature_).c_str()));
	lvi.pszText = text;
	ListView_SetItem(hctl, &lvi);

	// 统帅
	lvi.mask = LVIF_TEXT;
	lvi.iSubItem = column ++;
	sprintf(text, "%u.%u", fxptoi9(h.leadership_), fxpmod9(h.leadership_));
	lvi.pszText = text;
	ListView_SetItem(hctl, &lvi);
}
Пример #4
0
bool notify_handler_rclick(const std::map<int, std::string>& menu, HWND hwnd, int id, LPNMHDR lpNMHdr, is_enable_cb fn)
{
	if (id != listview_id) {
		return false;
	}
	LVITEM lvi;
	LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE)lpNMHdr;

	POINT point = {lpnmitem->ptAction.x, lpnmitem->ptAction.y};
	MapWindowPoints(lpNMHdr->hwndFrom, NULL, &point, 1);

	lvi.iItem = lpnmitem->iItem;
	lvi.mask = LVIF_PARAM;
	lvi.iSubItem = 0;
	ListView_GetItem(lpNMHdr->hwndFrom, &lvi);

	HMENU hpopup_candidate = CreatePopupMenu();
	for (std::map<int, std::string>::const_iterator it = menu.begin(); it != menu.end(); ++ it) {
		AppendMenu(hpopup_candidate, MF_STRING, it->first, utf8_2_ansi(it->second.c_str()));
		if (lpnmitem->iItem < 0 || (fn && !fn(hwnd, it->first, lvi.lParam))) {
			EnableMenuItem(hpopup_candidate, it->first, MF_BYCOMMAND | MF_GRAYED);
		}
	}

	TrackPopupMenuEx(hpopup_candidate, 0, 
		point.x, 
		point.y, 
		hwnd, 
		NULL);

	DestroyMenu(hpopup_candidate);

	lParam = lvi.lParam;
	return true;
}
Пример #5
0
// void advancement_tree_internal(const unit_type& current, 
void tcore::tree_2_tv(HWND hctl, HTREEITEM htvroot)
{
	char text[_MAX_PATH];
	HTREEITEM htvi;
	std::stringstream strstr;
	std::vector<std::string> advances_from;

	size_t index = 0;
	for (std::vector<node*>::const_iterator it = utype_tree_.begin(); it != utype_tree_.end(); ++ it, index ++) {
		const node* n = *it;
		const unit_type* current = n->current;
		htvi = TreeView_AddLeaf(hctl, htvroot);
		strstr.str("");
		strstr << std::setw(2) << std::setfill('0') << index << ": " << utf8_2_ansi(current->type_name().c_str()) << "(" << current->id() << ")";
		if (!current->packer()) {
			strstr << "[" << current->level() << "级]";
		} else {
			strstr << "[打包]";
		}
		strcpy(text, strstr.str().c_str());
		// 枚举到此为止,此个config一定有孩子,强制让出来前面+符号
		LPARAM lParam = tv_tree_.size();
		advances_from.clear();
		tv_tree_.push_back(std::make_pair<std::string, std::vector<std::string> >(current->id(), advances_from));
		if (n->advances_to.empty()) {
			TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, lParam, gdmgr._iico_dir, gdmgr._iico_dir, 1, text);
		} else {
			TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_CHILDREN, lParam, gdmgr._iico_dir, gdmgr._iico_dir, 1, text);
			advances_from.push_back(current->id());
			tree_2_tv_internal(hctl, htvi, n->advances_to, advances_from);
			TreeView_Expand(hctl, htvi, TVE_EXPAND);
		}
	}
}
Пример #6
0
void OnIntegrateConvertBt(HWND hdlgP, int id, HWND hwndCtrl, UINT codeNotify)
{
    RECT rc;
    GetWindowRect(hwndCtrl, &rc);

    HMENU hpopup_convert = CreatePopupMenu();
    AppendMenu(hpopup_convert, MF_STRING, IDM_CONVERT_NORMAL, utf8_2_ansi(_("Normal")));
    AppendMenu(hpopup_convert, MF_STRING, IDM_CONVERT_POEDIT, utf8_2_ansi(_("Poedit")));

    TrackPopupMenuEx(hpopup_convert, 0,
                     rc.left,
                     rc.bottom,
                     hdlgP,
                     NULL);

    DestroyMenu(hpopup_convert);
}
Пример #7
0
void tintegrate2::refresh(HWND hdlgP)
{
    fill_formaters();

    Button_SetText(GetDlgItem(hdlgP, IDC_BT_INTEGRATE_CONVERT), utf8_2_ansi(_("Convert to")));

    std::stringstream strstr;
    HWND hctl = GetDlgItem(hdlgP, IDC_CMB_INTEGRATE_FORMATER);
    ComboBox_ResetContent(hctl);
    for (std::vector<tformater>::const_iterator it = formaters.begin(); it != formaters.end(); ++ it) {
        const tformater& formater = *it;
        strstr.str("");
        strstr << utf8_2_ansi(formater.name) << " <=====> ";
        strstr << formater.example;
        ComboBox_AddString(hctl, strstr.str().c_str());
    }
    ComboBox_SetCurSel(hctl, 0);
}
Пример #8
0
void integrate_enter_ui(void)
{
    StatusBar_Idle();

    StatusBar_SetText(gdmgr._hwnd_status, 0, utf8_2_ansi(_("Interate text, image...")));

    integrate.refresh(gdmgr._hdlg_integrate);
    return;
}
Пример #9
0
BOOL On_DlgFormationEditInitDialog(HWND hdlgP, HWND hwndFocus, LPARAM lParam)
{
	editor_config::move_subcfg_right_position(hdlgP, lParam);

	std::stringstream strstr;
	if (ns::action_formation == ma_edit) {
		strstr << _("Edit formaton");
	} else {
		strstr << _("Add formaton");
	}
	SetWindowText(hdlgP, utf8_2_ansi(strstr.str().c_str()));

	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_LEADER), utf8_2_ansi(_("Leader")));
	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_CITY), utf8_2_ansi(_("City")));
	
	tformation& f = ns::core.formations_updating_[ns::clicked_formation];
	f.update_to_ui_formation_edit(hdlgP);

	return FALSE;
}
Пример #10
0
static bool save_if_dirty()
{
    if (integrate_get_save_btn()) {
        std::stringstream title, message;
        utils::string_map symbols;
        HWND hdlgP = gdmgr._hdlg_integrate;

        DLGHDR *pHdr = (DLGHDR *) GetWindowLong(hdlgP, GWL_USERDATA);

        symbols["campaign"] = "";
        title << utf8_2_ansi(_("Save"));
        message << utf8_2_ansi(vgettext2("Integrate is dirty, do you want to save modify?", symbols).c_str());
        int retval = MessageBox(hdlgP, message.str().c_str(), title.str().c_str(), MB_YESNO);
        if (retval == IDYES) {
            integrate.save(gdmgr._hdlg_integrate);
            return true;
        } else {
            integrate_enable_save_btn(FALSE);
            return false;
        }
    }
    return false;
}
Пример #11
0
void text_convert_to(HWND hdlgP, int id)
{
    HWND hctl = GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT);
    int len = Edit_GetTextLength(hctl);
    tmalloc_free_lock lock(len + 1);
    Edit_GetText(hctl, lock.buf, lock.len);
    std::string str(ansi_2_utf8(lock.buf));

    std::stringstream err;
    try {
        help::parse_text(str);

    } catch (game::error& e) {
        err << e.message;

    } catch (utils::invalid_utf8_exception&) {
        err << _("Encounter unknown format character!");
    }
    if (!err.str().empty()) {
        err << "\n\n";
        err << _("Exist grammar error, don't execute converting!");
        MessageBox(NULL, utf8_2_ansi(err.str().c_str()), "Error", MB_OK | MB_ICONWARNING);
        return;
    }

    if (id == IDM_CONVERT_NORMAL) {
        // \\n\r\n to \r\n
        replace_all_distinct(str, null_str, "\\n\r\n", "\r\n");
    } else if (id == IDM_CONVERT_POEDIT) {
        // \r\n to \\n\r\n
        replace_all_distinct(str, "\\n", "\r\n", "\\n\r\n");
    } else {
        return;
    }
    Edit_SetText(GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT), utf8_2_ansi(str));
}
Пример #12
0
void fill_header(HWND hwnd)
{
	Button_SetText(GetDlgItem(hwnd, find_bt_id), utf8_2_ansi(_("Find")));

	Button_Enable(GetDlgItem(hwnd, find_bt_id), FALSE);

	char text[1024];
	HWND hctl = GetDlgItem(hwnd, listview_id);
	LVCOLUMN lvc;

	lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.fmt = LVCFMT_LEFT;
	lvc.cx = 90;
	strcpy(text, dgettext_2_ansi("wesnoth-hero", "name"));
	lvc.pszText = text;
	lvc.cchTextMax = 0;
	lvc.iSubItem = 0;
	ListView_InsertColumn(hctl, 0, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 60;
	lvc.iSubItem = 1;
	strcpy(text, dgettext_2_ansi("wesnoth-hero", "catalog"));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, 1, &lvc);

	lvc.cx = 48;
	lvc.iSubItem = 2;
	strcpy(text, dgettext_2_ansi("wesnoth-hero", "feature"));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, 2, &lvc);

	lvc.cx = 40;
	lvc.iSubItem = 3;
	strcpy(text, dgettext_2_ansi("wesnoth-hero", "side feature"));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, 3, &lvc);

	lvc.cx = 40;
	lvc.iSubItem = 4;
	strcpy(text, dgettext_2_ansi("wesnoth-hero", "leadership"));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, 4, &lvc);

	ListView_SetImageList(hctl, NULL, LVSIL_SMALL);
	ListView_SetExtendedListViewStyleEx(hctl, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
}
Пример #13
0
void sync_enter_ui(void) 
{
	StatusBar_Trans();

	// 保留给将来使用按钮,当前版本全都灰掉
	ToolBar_EnableButton(gdmgr._htb_sync, IDM_REFRESH, TRUE);
	ToolBar_EnableButton(gdmgr._htb_sync, IDM_SYNC_SYNC, FALSE);

	HWND hctl = GetDlgItem(gdmgr._htb_sync, IDC_CMB_SYNC_LANGUAGE);
	ComboBox_ResetContent(hctl);
	const std::vector<language_def>& languages = get_languages();
	const language_def& current_language = get_language();
	BOOST_FOREACH (const language_def& lang, languages) {
		ComboBox_AddString(hctl, utf8_2_ansi(lang.language.c_str()));
		if (lang == current_language) {
			ComboBox_SetCurSel(hctl, ComboBox_GetCount(hctl) - 1);
		}
	}
Пример #14
0
BOOL On_DlgFeatureInitDialog(HWND hdlgP, HWND hwndFocus, LPARAM lParam)
{
	HWND hwndParent = GetParent(hdlgP); 
    DLGHDR *pHdr = (DLGHDR *) GetWindowLong(hwndParent, GWL_USERDATA);
    SetWindowPos(hdlgP, HWND_TOP, pHdr->rcDisplay.left, pHdr->rcDisplay.top, 0, 0, SWP_NOSIZE); 

	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_REMARK), utf8_2_ansi(_("Atomic feature remark")));

	std::stringstream strstr;

	HWND hctl = GetDlgItem(hdlgP, IDC_LV_FEATURE_ATOM);
	LVCOLUMN lvc;
	int index = 0;
	char text[_MAX_PATH];

	lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.fmt = LVCFMT_LEFT;
	lvc.cx = 40;
	strcpy(text, utf8_2_ansi(_("Number")));
	lvc.pszText = text;
	lvc.cchTextMax = 0;
	lvc.iSubItem = index;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 90;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Name");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 40;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Level");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 400;
	lvc.iSubItem = index;
	strcpy(text, utf8_2_ansi(_("Description")));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	ListView_SetImageList(hctl, NULL, LVSIL_SMALL);
	ListView_SetExtendedListViewStyleEx(hctl, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

	// complex
	hctl = GetDlgItem(hdlgP, IDC_LV_FEATURE_COMPLEX);
	index = 0;

	lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.fmt = LVCFMT_LEFT;
	lvc.cx = 40;
	strcpy(text, utf8_2_ansi(_("Number")));
	lvc.pszText = text;
	lvc.cchTextMax = 0;
	lvc.iSubItem = index;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 90;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Name");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 40;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Level");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 180;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Item");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 350;
	lvc.iSubItem = index;
	strcpy(text, utf8_2_ansi(_("Description")));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	ListView_SetImageList(hctl, NULL, LVSIL_SMALL);
	ListView_SetExtendedListViewStyleEx(hctl, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

	return FALSE;
}
Пример #15
0
BOOL On_DlgFeatureEditInitDialog(HWND hdlgP, HWND hwndFocus, LPARAM lParam)
{
	editor_config::move_subcfg_right_position(hdlgP, lParam);

	std::stringstream strstr;
	if (ns::type == IDC_LV_FEATURE_ATOM) {
		strstr << _("Edit atomic feature");
	} else {
		strstr << _("Edit complex feature");
	}
	
	int feature = ns::type == IDC_LV_FEATURE_ATOM? ns::clicked_feature: HEROS_BASE_FEATURE_COUNT + ns::clicked_feature;
	tfeature& f = ns::core.features_updating_[feature];
	strstr << std::setfill('0') << std::setw(3) << feature << ": " << hero::feature_str(feature);
	SetWindowText(hdlgP, utf8_2_ansi(strstr.str().c_str()));
	ShowWindow(GetDlgItem(hdlgP, IDCANCEL), SW_HIDE);

	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_LEVEL), utf8_2_ansi(_("Level")));
	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_CANDIDATE), utf8_2_ansi(_("Candidate")));
	Static_SetText(GetDlgItem(hdlgP, IDC_STATIC_ITEM), utf8_2_ansi(_("Item")));

	HWND hctl = GetDlgItem(hdlgP, IDC_CMB_FEATUREEDIT_LEVEL);
	ComboBox_AddString(hctl, "Lv0");
	ComboBox_AddString(hctl, "Lv1");
	ComboBox_AddString(hctl, "Lv2");
	ComboBox_AddString(hctl, "Lv3");
	ComboBox_AddString(hctl, "Lv4");

	hctl = GetDlgItem(hdlgP, IDC_LV_FEATUREEDIT_CANDIDATE);
	LVCOLUMN lvc;
	int index = 0;
	char text[_MAX_PATH];

	lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.fmt = LVCFMT_LEFT;
	lvc.cx = 40;
	strcpy(text, utf8_2_ansi(_("Number")));
	lvc.pszText = text;
	lvc.cchTextMax = 0;
	lvc.iSubItem = index;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 60;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Name");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 320;
	lvc.iSubItem = index;
	strcpy(text, utf8_2_ansi(_("Description")));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	ListView_SetImageList(hctl, NULL, LVSIL_SMALL);
	ListView_SetExtendedListViewStyleEx(hctl, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

	// item
	hctl = GetDlgItem(hdlgP, IDC_LV_FEATUREEDIT_ITEMS);
	index = 0;

	lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.fmt = LVCFMT_LEFT;
	lvc.cx = 40;
	strcpy(text, utf8_2_ansi(_("Number")));
	lvc.pszText = text;
	lvc.cchTextMax = 0;
	lvc.iSubItem = index;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 60;
	lvc.iSubItem = index;
	strstr.str("");
	strstr << _("Name");
	strcpy(text, utf8_2_ansi(strstr.str().c_str()));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	lvc.mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvc.cx = 320;
	lvc.iSubItem = index;
	strcpy(text, utf8_2_ansi(_("Description")));
	lvc.pszText = text;
	ListView_InsertColumn(hctl, index ++, &lvc);

	ListView_SetImageList(hctl, NULL, LVSIL_SMALL);
	ListView_SetExtendedListViewStyleEx(hctl, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

	f.update_to_ui_feature_edit(hdlgP);

	return FALSE;
}
Пример #16
0
void tfeature::update_to_ui_feature_edit(HWND hdlgP) const
{
	HWND hctl = GetDlgItem(hdlgP, IDC_CMB_FEATUREEDIT_LEVEL);
	ComboBox_SetCurSel(hctl, level_);

	hctl = GetDlgItem(hdlgP, IDC_LV_FEATUREEDIT_CANDIDATE);
	std::stringstream strstr;
	std::string str;
	char text[_MAX_PATH];

	ListView_DeleteAllItems(hctl);
	// fill data
	LVITEM lvi;
	int iItem = 0;
	const std::vector<int>& features = hero::valid_features();
	for (std::vector<int>::const_iterator it = features.begin(); it != features.end(); ++ it) {
		if (ns::type == IDC_LV_FEATURE_ATOM) {
			break;
		}
		if (*it >= HEROS_BASE_FEATURE_COUNT) {
			break;
		}
		if (items_.find(*it) != items_.end()) {
			continue;
		}

		int index = 0;
		
		lvi.mask = LVIF_TEXT | LVIF_PARAM;
		// number
		lvi.iItem = iItem;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << *it;
		strcpy(text, strstr.str().c_str());
		lvi.pszText = text;
		lvi.lParam = (LPARAM)*it;
		ListView_InsertItem(hctl, &lvi);

		// name
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_str(*it);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// description
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_desc_str(*it);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		iItem ++;
	}

	hctl = GetDlgItem(hdlgP, IDC_LV_FEATUREEDIT_ITEMS);
	ListView_DeleteAllItems(hctl);
	iItem = 0;
	for (std::set<int>::const_iterator it = items_.begin(); it != items_.end(); ++ it, iItem ++) {
		int index = 0;
		
		lvi.mask = LVIF_TEXT | LVIF_PARAM;
		// number
		lvi.iItem = iItem;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << *it;
		strcpy(text, strstr.str().c_str());
		lvi.pszText = text;
		lvi.lParam = (LPARAM)*it;
		ListView_InsertItem(hctl, &lvi);

		// name
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_str(*it);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// description
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_desc_str(*it);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);
	}

	if (ns::type != IDC_LV_FEATURE_ATOM) {
		Button_Enable(GetDlgItem(hdlgP, IDOK), !items_.empty());
	}
}
Пример #17
0
void tcore::update_to_ui_formation(HWND hdlgP)
{
	char text[_MAX_PATH];
	std::stringstream strstr;

	HWND hctl = GetDlgItem(hdlgP, IDC_TV_FORMATION_EXPLORER);

	// 1. clear treeview
	TreeView_DeleteAllItems(hctl);

	// 2. fill content
	htvroot_formation_ = TreeView_AddLeaf(hctl, TVI_ROOT);
	strstr.str("");
	strstr << dgettext_2_ansi("kingdom-lib", "tactical^Formation");
	strcpy(text, strstr.str().c_str());
	// must set TVIF_CHILDREN
	TreeView_SetItem1(hctl, htvroot_formation_, TVIF_TEXT | TVIF_PARAM | TVIF_CHILDREN, 0, 0, 0, 
		1, text);

	HTREEITEM htvi_formation, htvi_branch, htvi;
	utils::string_map symbols;

	const std::map<int, tformation_profile>& formations = unit_types.formations();
	for (std::map<int, tformation_profile>::const_iterator it = formations.begin(); it != formations.end(); ++ it) {
		const tformation_profile& f = it->second;

		htvi_formation = TreeView_AddLeaf(hctl, htvroot_formation_);
		LPARAM lParam = f.index();
		strstr.str("");
		strstr << std::setw(2) << std::setfill('0') << f.index() << ": " << utf8_2_ansi(f.name().c_str()) << "(" << f.id() << ")";
		strstr << utf8_2_ansi(_("Description")) << ": ";
		strstr << utf8_2_ansi(f.description().c_str());
		strcpy(text, strstr.str().c_str());
		TreeView_SetItem2(hctl, htvi_formation, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_CHILDREN, lParam, gdmgr._iico_dir, gdmgr._iico_dir, 1, text);

		// arms requrie
		htvi = TreeView_AddLeaf(hctl, htvi_formation);
		strstr.str("");
		strstr << _("Arms require");
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 1, text);

		htvi_branch = htvi;

		htvi = TreeView_AddLeaf(hctl, htvi_branch);
		strstr.str("");
		strstr << _("Type") << ": ";
		for (std::set<std::string>::const_iterator it2 = f.arms_type_.begin(); it2 != f.arms_type_.end(); ++ it2) {
			if (it2 != f.arms_type_.begin()) {
				strstr << ", ";
			}
			strstr << dsgettext("kingdom-lib", it2->c_str());
		}

		strstr << "     ";
		strstr << _("attack^Range") << ": " << dsgettext("kingdom-lib", unit_types.range_ids()[f.arms_range_].c_str());
		strstr << "(" << f.arms_range_id_ << ")";
		
		strstr << "     ";
		strstr << _("Quantity") << ": " << f.arms_count_;
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);

		TreeView_Expand(hctl, htvi_branch, TVE_EXPAND);

		if (f.attack_flag_) {
			bool first = true;
			htvi = TreeView_AddLeaf(hctl, htvi_formation);
			strstr.str("");
			strstr << _("Attack") << ": ";
			if (f.attack_flag_ & tformation_profile::SLOW) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "slowed");
			}
			if (f.attack_flag_ & tformation_profile::BREAK) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "broken");
			}
			if (f.attack_flag_ & tformation_profile::POISON) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "poisoned");
			}
			strcpy(text, utf8_2_ansi(strstr.str().c_str()));
			TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);
		}

		htvi = TreeView_AddLeaf(hctl, htvi_formation);
		strstr.str("");
		strstr << _("Icon") << "/" << _("Image") << ": ";
		strstr << f.icon() << "        " << f.bg_image();
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);

		TreeView_Expand(hctl, htvi_formation, TVE_EXPAND);
	}

	TreeView_Expand(hctl, htvroot_formation_, TVE_EXPAND);
}
Пример #18
0
void tcore::update_to_ui_feature(HWND hdlgP)
{
	HWND hctl = GetDlgItem(hdlgP, IDC_LV_FEATURE_ATOM);
	std::stringstream strstr;
	std::string str;
	char text[_MAX_PATH];

	ListView_DeleteAllItems(hctl);
	// fill data
	LVITEM lvi;
	int iItem = 0;
	for (std::vector<tfeature>::iterator it = features_updating_.begin(); it != features_updating_.end(); ++ it) {
		int feature = std::distance(features_updating_.begin(), it);
		if (feature >= HEROS_BASE_FEATURE_COUNT) {
			break;
		}
		const tfeature& f = *it;
		int index = 0;
		
		lvi.mask = LVIF_TEXT | LVIF_PARAM;
		// number
		lvi.iItem = iItem ++;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << feature;
		strcpy(text, strstr.str().c_str());
		lvi.pszText = text;
		lvi.lParam = (LPARAM)feature;
		ListView_InsertItem(hctl, &lvi);

		// name
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_str(feature);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// level
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << f.level_;
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// description
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_desc_str(feature);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);
	}

	// complex
	hctl = GetDlgItem(hdlgP, IDC_LV_FEATURE_COMPLEX);
	ListView_DeleteAllItems(hctl);
	// fill data
	iItem = 0;
	for (std::vector<tfeature>::iterator it = features_updating_.begin(); it != features_updating_.end(); ++ it) {
		int feature = std::distance(features_updating_.begin(), it);
		if (feature < HEROS_BASE_FEATURE_COUNT) {
			continue;
		}
		const tfeature& f = *it;
		int index = 0;
		
		lvi.mask = LVIF_TEXT | LVIF_PARAM;
		// number
		lvi.iItem = iItem;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << feature;
		strcpy(text, strstr.str().c_str());
		lvi.pszText = text;
		lvi.lParam = (LPARAM)feature;
		ListView_InsertItem(hctl, &lvi);

		// name
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_str(feature);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// level
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << f.level_;
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// item
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		for (std::set<int>::const_iterator it2 = it->items_.begin(); it2 != it->items_.end(); ++ it2) {
			if (it2 != it->items_.begin()) {
				strstr << ", ";
			}
			strstr << hero::feature_str(*it2);
		}
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		// description
		lvi.mask = LVIF_TEXT;
		lvi.iSubItem = index ++;
		strstr.str("");
		strstr << hero::feature_desc_str(feature);
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		lvi.pszText = text;
		ListView_SetItem(hctl, &lvi);

		iItem ++;
	}
}