Ejemplo n.º 1
0
void BattleRoomTab::UpdateBattleInfo(const wxString& Tag)
{
	if (!m_battle)
		return;

	const long index = m_opt_list_map[Tag];
	if (index >= m_opts_list->GetItemCount()) {
		wxLogDebug(_T("UpdateBattleInfo: Invalid index %d %d %s"), index, m_opts_list->GetItemCount(), Tag.c_str());
		return;
	}

	LSL::Enum::GameOption type = (LSL::Enum::GameOption)FromwxString(Tag.BeforeFirst('_'));
	wxString key = Tag.AfterFirst('_');
	if ((type == LSL::Enum::MapOption) || (type == LSL::Enum::ModOption) || (type == LSL::Enum::EngineOption)) {
		LSL::Enum::OptionType DataType = m_battle->CustomBattleOptions().GetSingleOptionType(STD_STRING(key));
		wxString value = TowxString(m_battle->CustomBattleOptions().getSingleValue(STD_STRING(key), (LSL::Enum::GameOption)type));
		if (TowxString(m_battle->CustomBattleOptions().getDefaultValue(STD_STRING(key), type)) == value) {
			m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT));
		} else {
			m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
		}
		if (DataType == LSL::Enum::opt_bool) {
			value = bool2yn(FromwxString(value)); // convert from 0/1 to literal Yes/No
		} else if (DataType == LSL::Enum::opt_list) {
			value = TowxString(m_battle->CustomBattleOptions().GetNameListOptValue(STD_STRING(key), type)); // get the key full name not short key
		}
		m_opts_list->SetItem(index, 1, value);
	} else // if ( type == OptionsWrapper::PrivateOptions )
	{
		if (key == _T( "mapname" )) // the map has been changed
		{
			UpdateMapInfoSummary();

			wxString mapname = TowxString(m_battle->GetHostMapName());
			int index_ = m_map_combo->FindString(mapname);
			if (index_ != wxNOT_FOUND)
				m_map_combo->SetSelection(index_);
			else
				m_map_combo->SetValue(mapname);

			//delete any eventual map option from the list and add options of the new map
			for (int i = m_map_opts_index; i < m_opts_list->GetItemCount();) {
				m_opts_list->DeleteItem(i);
			}
			AddMMOptionsToList(m_map_opts_index, LSL::Enum::MapOption);

			m_minimap->UpdateMinimap();

		} else if (key == _T( "restrictions" )) {
			m_opts_list->SetItem(index, 1, bool2yn(m_battle->RestrictedUnits().size() > 0));
		}
	}
}
Ejemplo n.º 2
0
void BattleRoomTab::OnOptionActivate(wxListEvent& event)
{
	if (!m_battle)
		return;
	if (!m_battle->IsFounderMe())
		return;
	long index = event.GetIndex();
	if (index == 0)
		return;
	wxString tag;
	for (OptionListMap::const_iterator itor = m_opt_list_map.begin(); itor != m_opt_list_map.end(); ++itor) {
		if (itor->second == index) {
			tag = itor->first;
			break;
		}
	}
	LSL::OptionsWrapper& optWrap = m_battle->CustomBattleOptions();
	LSL::Enum::GameOption optFlag = (LSL::Enum::GameOption)FromwxString(tag.BeforeFirst('_'));
	const std::string key = STD_STRING(tag.AfterFirst('_'));
	LSL::Enum::OptionType type = optWrap.GetSingleOptionType(key);
	if (!optWrap.keyExists(key, optFlag, false, type))
		return;
	SingleOptionDialog dlg(*m_battle, tag);
	dlg.ShowModal();
}
Ejemplo n.º 3
0
void PlaybackListFilter::SetDurationValue()
{

	wxString dur = m_filter_duration_edit->GetValue();
	const wxChar* mysep = _T(":");
	int sep_count = dur.Replace(mysep, mysep); //i know, i know
	switch (sep_count) {
		default:
			break;

		case 0:
			m_duration_value = FromwxString(dur);
			break;
		case 1:
			m_duration_value = FromwxString(dur.AfterFirst(*mysep)) + (FromwxString(dur.BeforeFirst(*mysep)) * 60);
			break;
		case 2:
			m_duration_value = FromwxString(dur.AfterLast(*mysep)) + (FromwxString(dur.AfterFirst(*mysep).BeforeFirst(*mysep)) * 60) + (FromwxString(dur.BeforeFirst(*mysep)) * 3600);
			break;
	}
}
Ejemplo n.º 4
0
void SingleOptionDialog::OnOk(wxCommandEvent& /*unused*/)
{
	const auto optFlag = (LSL::Enum::GameOption)FromwxString(m_tag.BeforeFirst('_'));
	const std::string key = STD_STRING(m_tag.AfterFirst('_'));
	wxString value;
	if (m_textctrl)
		value = m_textctrl->GetValue();
	else if (m_combobox)
		value = TowxString(m_battle.CustomBattleOptions()
				       .GetNameListOptItemKey(key, STD_STRING(m_combobox->GetValue()), optFlag));
	else if (m_spinctrl) {
		double d = m_spinctrl->GetValue();
		value = wxString::Format(_T("%f"), d);
		wxLogMessage(_T("Got VALUE: %s -- %f"), value.c_str(), d);
	} else if (m_checkbox)
		value = TowxString(m_checkbox->GetValue());
	m_battle.CustomBattleOptions().setSingleOption(key, STD_STRING(value), optFlag);
	m_battle.SendHostInfo(STD_STRING(m_tag));
	EndModal(wxID_OK);
}
Ejemplo n.º 5
0
void AddBotDialog::UpdateOption(const wxString& Tag)
{
	const long index = m_opt_list_map[Tag];
	const LSL::Enum::GameOption type = (LSL::Enum::GameOption)FromwxString(Tag.BeforeFirst('_'));
	const std::string key = STD_STRING(Tag.AfterFirst('_'));
	std::string value;

	const auto DataType = m_battle.CustomBattleOptions().GetSingleOptionType(key);
	value = m_battle.CustomBattleOptions().getSingleValue(key, (LSL::Enum::GameOption)type);
	if (m_battle.CustomBattleOptions().getDefaultValue(key, type) == value)
		m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT));
	else
		m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
	if (DataType == LSL::Enum::opt_bool) {
		value = STD_STRING(bool2yn(LSL::Util::FromIntString(value))); // convert from 0/1 to literal Yes/No
	} else if (DataType == LSL::Enum::opt_list) {
		value = m_battle.CustomBattleOptions().GetNameListOptValue(key, type); // get the key full name not short key
	}
	m_opts_list->SetItem(index, 1, TowxString(value));
	m_opts_list->SetColumnWidth(1, wxLIST_AUTOSIZE);
}
Ejemplo n.º 6
0
long GetIntParam(wxString& params)
{
	return FromwxString(GetParamByChar(params, _T(' ')));
}
Ejemplo n.º 7
0
SingleOptionDialog::SingleOptionDialog(IBattle& battle, const wxString& optiontag)
    : m_battle(battle)
    , m_tag(optiontag)
    , m_checkbox(NULL)
    , m_combobox(NULL)
    , m_spinctrl(NULL)
    , m_textctrl(NULL)
    , m_cancel_button(NULL)
    , m_ok_button(NULL)
{
	LSL::OptionsWrapper& optWrap = m_battle.CustomBattleOptions();
	LSL::Enum::GameOption optFlag = (LSL::Enum::GameOption)FromwxString(optiontag.BeforeFirst('_'));
	const auto key = STD_STRING(optiontag.AfterFirst('_'));
	LSL::Enum::OptionType type = optWrap.GetSingleOptionType(key);
	Create((wxWindow*)&ui().mw(), wxID_ANY, _("Change option"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T( "OptionDialog" ));
	if (!optWrap.keyExists(key, optFlag, false, type)) {
		EndModal(wxID_CANCEL);
		return;
	}

	wxBoxSizer* m_main_sizer = new wxBoxSizer(wxVERTICAL);

	// wxStaticText* m_labelctrl = wxStaticText();

	switch (type) {
		case LSL::Enum::opt_bool: {
			const auto opt = optWrap.m_opts[optFlag].bool_map[key];
			m_checkbox = new wxCheckBox(this, wxID_ANY, TowxString(opt.name));
			m_checkbox->SetToolTip(opt.description);
			m_checkbox->SetValue(opt.value);
			m_main_sizer->Add(m_checkbox, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_float: {
			const auto opt = optWrap.m_opts[optFlag].float_map[key];
			m_spinctrl = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
							  wxSP_ARROW_KEYS, double(opt.min), double(opt.max),
							  double(opt.value), double(opt.stepping), TowxString(opt.key));
			m_spinctrl->SetToolTip(opt.description);
			m_main_sizer->Add(m_spinctrl, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_string: {
			const auto opt = optWrap.m_opts[optFlag].string_map[key];
			m_textctrl = new wxTextCtrl(this, wxID_ANY, TowxString(opt.value), wxDefaultPosition,
						    wxDefaultSize, 0, wxDefaultValidator, TowxString(opt.key));
			m_textctrl->SetToolTip(opt.description);
			m_main_sizer->Add(m_textctrl, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_list: {
			const auto opt = optWrap.m_opts[optFlag].list_map[key];
			const int temp = int(opt.cbx_choices.size() - 1);
			const int index = LSL::Util::Clamp(opt.cur_choice_index, 0, temp);
			m_combobox = new wxComboBox(this, wxID_ANY, TowxString(opt.cbx_choices[index]), wxDefaultPosition, wxDefaultSize,
						    lslTowxArrayString(opt.cbx_choices), wxCB_READONLY, wxDefaultValidator);
			std::string tooltip = opt.description + "\n";
			for (const auto itor : opt.listitems) {
				tooltip += "\n" + itor.name + ": " + itor.desc;
			}
			m_combobox->SetToolTip(tooltip);
			m_main_sizer->Add(m_combobox, 0, wxEXPAND);
			break;
		}
		default: {
			EndModal(wxID_CANCEL);
			return;
		}
	}

	wxSize __SpacerSize_1 = wxDLG_UNIT(this, wxSize(0, 0));
	m_main_sizer->Add(__SpacerSize_1.GetWidth(), __SpacerSize_1.GetHeight(), 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
	wxStaticLine* m_separator1 = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxSize(10, -1), wxLI_HORIZONTAL, _T( "ID_STATICLINE1" ));
	m_main_sizer->Add(m_separator1, 0, wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
	wxBoxSizer* m_buttons_sizer = new wxBoxSizer(wxHORIZONTAL);
	m_cancel_button = new wxButton(this, ID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T( "ID_CANCEL" ));
	m_buttons_sizer->Add(m_cancel_button, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
	m_buttons_sizer->Add(0, 0, 1, wxALL | wxEXPAND | wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 0);
	m_ok_button = new wxButton(this, ID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T( "ID_OK" ));
	m_buttons_sizer->Add(m_ok_button, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
	m_main_sizer->Add(m_buttons_sizer, 0, wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 0);


	m_main_sizer->Fit(this);
	m_main_sizer->SetSizeHints(this);

	SetSizer(m_main_sizer);
	Layout();

	Connect(ID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&SingleOptionDialog::OnCancel);
	Connect(ID_OK, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&SingleOptionDialog::OnOk);
}
Ejemplo n.º 8
0
bool PlaybackListFilter::FilterPlayback(const StoredGame& playback)
{

	if (!m_activ)
		return true;

	const OfflineBattle& battle = playback.battle;
	//Player Check
	if ((m_filter_player_choice_value != -1) && !_IntCompare(battle.GetNumUsers() - battle.GetSpectators(), m_filter_player_choice_value, m_filter_player_mode))
		return false;

	//Only Maps i have Check
	if (m_filter_map_show->GetValue() && !battle.MapExists())
		return false;

	//Only Mods i have Check
	if (m_filter_mod_show->GetValue() && !battle.GameExists())
		return false;

	//Strings Plain Text & RegEx Check (Case insensitiv)

	//Map:
	if (!TowxString(battle.GetHostMapName()).Upper().Contains(m_filter_map_edit->GetValue().Upper()) && !m_filter_map_expression->Matches(TowxString(battle.GetHostMapName())))
		return false;

	//Mod:
	if (!TowxString(battle.GetHostGameName()).Upper().Contains(m_filter_mod_edit->GetValue().Upper()) && !TowxString(battle.GetHostGameName()).Upper().Contains(m_filter_mod_edit->GetValue().Upper()) && !m_filter_mod_expression->Matches(TowxString(battle.GetHostGameName())))
		return false;

	if ((!m_filter_filesize_edit->GetValue().IsEmpty()) && !_IntCompare(playback.size, 1024 * FromwxString(m_filter_filesize_edit->GetValue()), m_filter_filesize_mode))
		return false;

	//duration
	if ((!m_filter_duration_edit->GetValue().IsEmpty()) && !_IntCompare(playback.duration, m_duration_value, m_filter_duration_mode))
		return false;

	return true;
}
Ejemplo n.º 9
0
bool abstract_panel::loadValuesIntoMap()
{
	try {
		//special treatment for resolution that'll set proper defaults for res
		wxDisplay display(0);
		//		wxRect display_rect ( display.GetGeometry() );
		//		const int current_x_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[0].key,display_rect.width);
		//		const int current_y_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[1].key,display_rect.height);

		for (int i = 0; i < intControls_size; ++i) {
			intSettings[intControls[i].key] = LSL::usync().GetSpringConfigInt(STD_STRING(intControls[i].key), FromwxString(intControls[i].def));
		}
		for (int i = 0; i < floatControls_size; ++i) {
			floatSettings[floatControls[i].key] = LSL::usync().GetSpringConfigFloat(STD_STRING(floatControls[i].key), FromwxString(floatControls[i].def));
		}
	} catch (...) {
		customMessageBox(SS_MAIN_ICON, _("Could not access your settings.\n"), _("Error"), wxOK | wxICON_HAND, 0);
		abstract_panel::settingsChanged = false;
		return false;
	}

	return true; // SUCCESS!
}
Ejemplo n.º 10
0
void abstract_panel::loadDefaults()
{
	//const Control RO_SLI[9]
	for (int i = 0; i < s_category_sizes[_T("RO_SLI")]; ++i)
		intSettings[RO_SLI[i].key] = FromwxString(RO_SLI[i].def);

	//const Control VO_CBOX[3]
	for (int i = 0; i < s_category_sizes[_T("VO_CBOX")]; ++i)
		intSettings[VO_CBOX[i].key] = FromwxString(VO_CBOX[i].def);

	//const Control VO_RBUT[2]
	for (int i = 0; i < s_category_sizes[_T("VO_RBUT")]; ++i)
		intSettings[VO_RBUT[i].key] = FromwxString(VO_RBUT[i].def);

	//	const Control VO_SLI[1]
	for (int i = 0; i < s_category_sizes[_T("VO_SLI")]; ++i)
		intSettings[VO_SLI[i].key] = FromwxString(VO_SLI[i].def);

	//	const Control VO_SLI_EXT[1]
	for (int i = 0; i < s_category_sizes[_T("VO_SLI_EXT")]; ++i)
		intSettings[VO_SLI_EXT[i].key] = FromwxString(VO_SLI_EXT[i].def);

	//	const Control AO_SLI[3]
	for (int i = 0; i < s_category_sizes[_T("AO_SLI")]; ++i)
		intSettings[AO_SLI[i].key] = FromwxString(AO_SLI[i].def);

	//	const Control QA_CBOX[10]
	for (int i = 0; i < s_category_sizes[_T("QA_CBOX")]; ++i)
		intSettings[QA_CBOX[i].key] = FromwxString(QA_CBOX[i].def);

	//	const Control UI_CBOX[17]
	for (int i = 0; i < s_category_sizes[_T("UI_CBOX")]; ++i)
		intSettings[UI_CBOX[i].key] = FromwxString(UI_CBOX[i].def);

	//	const Control MO_SLI[5]
	for (int i = 0; i < s_category_sizes[_T("MO_SLI")]; ++i)
		intSettings[MO_SLI[i].key] = FromwxString(MO_SLI[i].def);

	//	const Control MO_SLI_EXT[5]
	for (int i = 0; i < s_category_sizes[_T("MO_SLI_EXT")]; ++i)
		intSettings[MO_SLI_EXT[i].key] = FromwxString(MO_SLI_EXT[i].def);

	//	const Control DO_SLI[1]
	for (int i = 0; i < s_category_sizes[_T("DO_SLI")]; ++i)
		intSettings[DO_SLI[i].key] = FromwxString(DO_SLI[i].def);

	//	const Control DO_CBOX[2]
	for (int i = 0; i < s_category_sizes[_T("DO_CBOX")]; ++i)
		intSettings[DO_CBOX[i].key] = FromwxString(DO_CBOX[i].def);

	//	const Control WR_COMBOX[4]
	for (int i = 0; i < s_category_sizes[_T("WR_COMBOX")]; ++i)
		intSettings[WR_COMBOX[i].key] = FromwxString(WR_COMBOX[i].def);

	//	const Control MO_CBOX[2]
	for (int i = 0; i < s_category_sizes[_T("MO_CBOX")]; ++i)
		intSettings[MO_CBOX[i].key] = FromwxString(MO_CBOX[i].def);

	//	const Control MO_RBUT[5]
	for (int i = 0; i < s_category_sizes[_T("MO_RBUT")]; ++i)
		intSettings[MO_RBUT[i].key] = FromwxString(MO_RBUT[i].def);

	//	const Control RC_TEXT[2]
	for (int i = 0; i < s_category_sizes[_T("RC_TEXT")]; ++i)
		intSettings[RC_TEXT[i].key] = FromwxString(RC_TEXT[i].def);

	//	const Control UI_ZOOM[1]
	for (int i = 0; i < s_category_sizes[_T("UI_ZOOM")]; ++i)
		intSettings[UI_ZOOM[i].key] = FromwxString(UI_ZOOM[i].def);

	for (int i = 0; i < s_category_sizes[_T("W4_CONTROLS")] - 1; ++i)
		intSettings[W4_CONTROLS[i].key] = FromwxString(W4_CONTROLS[i].def);

	const size_t idx = s_category_sizes[_T("W4_CONTROLS")] - 1;
	floatSettings[W4_CONTROLS[idx].key] = FromwxString(W4_CONTROLS[idx].def); //TODO add comment: what does this do?
}