bool OptionsWrapper::loadOptions(Enum::GameOption modmapFlag, const std::string& name)
{
	unLoadOptions(modmapFlag);
	GameOptions opt;
	switch (modmapFlag) {
		default:
			break;
		case Enum::MapOption:
			try {
				opt = usync().GetMapOptions(name);
			} catch (...) {
				LslError("Could not load map options");
				usync().FetchUnitsyncErrors(name);
				return false;
			}
			break;

		case Enum::ModOption:
			try {
				opt = usync().GetGameOptions(name);
			} catch (...) {
				LslError("Could not load game options");
				usync().FetchUnitsyncErrors(name);
				return false;
			}
			break;

		case Enum::EngineOption: {
			//TODO Fixed,random and so forth are intls
			mmOptionList startpos("Start Position Type", "startpostype", "How players will select where to be spawned in the map\n0: fixed map positions\n1: random map positions\n2: choose in game\n3: choose in the lobby before starting", "0");
			startpos.addItem("0", "Fixed", "Use the start positions defined in the map, the positions will be assigned incrementally from the team with lowest number to highest");
			startpos.addItem("1", "Random", "Use the start positions defined in the map, the positions will be assigned randomly");
			startpos.addItem("2", "Choose in-game", "Players will be able to pick their own starting point right before the game starts, optionally limited by a bounding box defined by the host");
			startpos.addItem("3", "Choose before game", "The host will place each player's start position in the map preview before the game is launched");
			opt.list_map["startpostype"] = startpos;
			break;
		}

		case Enum::PrivateOptions: {
			opt.string_map["restrictions"] = mmOptionString("List of restricted units", "restrictedunits", "Units in this list won't be available in game", "", 0); // tab separated list
			opt.string_map["mapname"] = mmOptionString("Map name", "mapname", "Map name", "", 0);
			break;
		}
	}
	m_opts[modmapFlag] = opt;
	return true;
}
示例#2
0
void GetOptionEntry( const int i, GameOptions& ret)
{
    //all section values for options are converted to lower case
    //since usync returns the key of section type keys lower case
    //otherwise comapring would be a real hassle
    wxString key = susynclib().GetOptionKey(i);
      wxString name = susynclib().GetOptionName(i);
      switch (susynclib().GetOptionType(i))
      {
      case opt_float:
      {
        ret.float_map[key] = mmOptionFloat( name, key,
            susynclib().GetOptionDesc(i), susynclib().GetOptionNumberDef(i),
            susynclib().GetOptionNumberStep(i),
            susynclib().GetOptionNumberMin(i), susynclib().GetOptionNumberMax(i),
            susynclib().GetOptionSection(i).Lower(), susynclib().GetOptionStyle(i) );
        break;
      }
      case opt_bool:
      {
        ret.bool_map[key] = mmOptionBool( name, key,
            susynclib().GetOptionDesc(i), susynclib().GetOptionBoolDef(i),
            susynclib().GetOptionSection(i).Lower(), susynclib().GetOptionStyle(i) );
        break;
      }
      case opt_string:
      {
        ret.string_map[key] = mmOptionString( name, key,
            susynclib().GetOptionDesc(i), susynclib().GetOptionStringDef(i),
            susynclib().GetOptionStringMaxLen(i),
            susynclib().GetOptionSection(i).Lower(), susynclib().GetOptionStyle(i) );
        break;
      }
      case opt_list:
      {
         ret.list_map[key] = mmOptionList(name,key,
            susynclib().GetOptionDesc(i),susynclib().GetOptionListDef(i),
            susynclib().GetOptionSection(i).Lower(),susynclib().GetOptionStyle(i));

        int listItemCount = susynclib().GetOptionListCount(i);
         for (int j = 0; j < listItemCount; ++j)
         {
           wxString descr = susynclib().GetOptionListItemDesc(i,j);
           ret.list_map[key].addItem(susynclib().GetOptionListItemKey(i,j),susynclib().GetOptionListItemName(i,j), descr);
         }
        break;
      }
      case opt_section:
      {
        ret.section_map[key] = mmOptionSection( name, key, susynclib().GetOptionDesc(i),
            susynclib().GetOptionSection(i).Lower(), susynclib().GetOptionStyle(i) );
      }
      }
}
bool OptionsWrapper::loadOptions( GameOption modmapFlag, const wxString& name, const wxString& extra_filename )
{
	unLoadOptions(modmapFlag);
	GameOptions opt;
	switch (modmapFlag)
	{
	    default:
            break;
		case MapOption:
			try
			{
                opt = usync().GetMapOptions(name);
                ParseSectionMap( m_sections[modmapFlag], opt.section_map );
			}
			catch(...)
			{
				wxLogError(_T("Could not load map options"));
				return false;
			}
			break;

		case ModOption:
			try
			{
                opt = usync().GetModOptions(name);
                ParseSectionMap( m_sections[modmapFlag], opt.section_map );
			}
			catch(...)
			{
				wxLogError(_T("Could not load game options"));
				return false;
			}
			break;

        case EngineOption: {
            mmOptionList startpos( _("Start Position Type"),_T("startpostype"), _("How players will select where to be spawned in the map\n0: fixed map positions\n1: random map positions\n2: choose in game\n3: choose in the lobby before starting"), _T("0") );
            startpos.addItem( _T("0"), _("Fixed"), _T("Use the start positions defined in the map, the positions will be assigned incrementally from the team with lowest number to highest") );
            startpos.addItem( _T("1"), _("Random"), _T("Use the start positions defined in the map, the positions will be assigned randomly") );
            startpos.addItem( _T("2"), _("Choose in-game"), _T("Players will be able to pick their own starting point right before the game starts, optionally limited by a bounding box defined by the host") );
            startpos.addItem( _T("3"), _("Choose before game"), _T("The host will place each player's start position in the map preview before the game is launched") );
            opt.list_map[_T("startpostype")] = startpos;
            break;
        }

        case PrivateOptions: {
            opt.string_map[_T("restrictions")] = mmOptionString(_("List of restricted units"), _T("restrictedunits"), _T("Units in this list won't be available in game"), _T(""), 0 ); // tab separated list
            opt.string_map[_T("mapname")] = mmOptionString(_("Map name"), _T("mapname"), _T("Map name"), _T(""), 0 );
            break;
        }

        case ModCustomizations: {
            try {
                opt = usync().GetModCustomizations( name );
            }
            catch(...) {
				wxLogError(_T("Could not load mod customizations"));
				return false;
			}
			break;
        }

        case SkirmishOptions: {
            try {
                opt = usync().GetSkirmishOptions( name, extra_filename );
            }
            catch(...) {
				wxLogError(_T("Could not load skirmish options"));
				return false;
			}
			break;
        }
	}
	m_opts[modmapFlag] = opt;
	return true;
}