-
-
+
-
-
-
-| Offer |
-Wanted |
-Trainer |
-
-
+
-
-| <%# CreateOffer4(Container.DataItem) %> |
-<%# CreateWanted4(Container.DataItem) %> |
-<%# CreateTrainer4(Container.DataItem) %> |
-
+
+
+
+
+ -
+ <%# CreateOfferImage(Container.DataItem) %>
+
+ -
+ <%# CreatePokeball(Container.DataItem) %>
+ Lv.
+ <%# CreateLevel(Container.DataItem) %>
+ <%# CreateGender(Container.DataItem) %>
+ <%# CreatePokerus(Container.DataItem) %>
+
+
+
+
+
+
+
+
-
+
diff --git a/web/gts/Default.aspx.cs b/web/gts/Default.aspx.cs
index d6f1504d..04cdb535 100644
--- a/web/gts/Default.aspx.cs
+++ b/web/gts/Default.aspx.cs
@@ -49,125 +49,118 @@ namespace PkmnFoundations.GTS
{
if (min == 0 && max == 0)
{
- return "Any";
+ return "Any level";
}
else if (min == 0)
{
- return String.Format("{0} and under", max);
+ return String.Format("Lv. {0} and under", max);
}
else if (max == 0)
{
- return String.Format("{0} and up", min);
+ return String.Format("Lv. {0} and up", min);
}
else
{
- return String.Format("{0} to {1}", min, max);
+ return String.Format("Lv. {0} to {1}", min, max);
}
}
- protected String CreateOffer4(object DataItem)
+ protected String CreateOfferImage(object DataItem)
+ {
+ return "

";
+ }
+
+ protected String CreatePokeball(object DataItem)
+ {
+ return "

";
+ }
+
+ protected String CreatePokerus(object DataItem)
+ {
+ return "";
+ }
+
+
+ // fixme: I can remove the need for separate 4/5 functions by making
+ // the GtsRecords inherit from IGtsRecord and make the the Pokemon field
+ // return PokemonPartyBase.
+
+ protected String CreateLevel(object DataItem)
{
GtsRecord4 record = (GtsRecord4)DataItem;
- Pokemon4 pokemon = null;
- StringBuilder builder = new StringBuilder();
-
- try
- {
- pokemon = new Pokemon4(m_pokedex, record.Data);
- }
- catch
- {
- builder.Append("Failure to parse pokemon data.
");
- }
-
- try
- {
- try
- {
- builder.Append(String.Format("{0} (#{1})", pokemon.Species.Name, pokemon.SpeciesID));
- }
- catch (KeyNotFoundException)
- {
- builder.Append(String.Format("??? (#{0})", record.Species));
- }
- catch (NullReferenceException)
- {
- builder.Append(String.Format("??? (#{0})", record.Species));
- }
- builder.Append("
");
- try
- {
- if (pokemon.FormID != 0)
- {
- try
- {
- builder.Append(pokemon.Form.Name);
- }
- catch (KeyNotFoundException)
- {
- builder.Append("Unknown form");
- }
- catch (NullReferenceException)
- {
- builder.Append("Unknown form");
- }
- builder.Append("
");
- }
- }
- catch (NullReferenceException)
- {
- builder.Append("Unknown form");
- }
- builder.Append(String.Format("Lv {0}", record.Level));
- builder.Append(String.Format(", {0}", record.Gender));
- builder.Append("
");
- try
- {
- builder.Append(String.Format("Nature: {0}", pokemon.Nature.ToString()));
- }
- catch (NullReferenceException)
- {
- builder.Append("Nature: ???");
- }
- builder.Append("
");
- try
- {
- builder.Append(String.Format("Ability: {0}", pokemon.Ability.Name));
- }
- catch (KeyNotFoundException)
- {
- builder.Append("Ability: ???");
- }
- catch (NullReferenceException)
- {
- builder.Append("Ability: ???");
- }
- builder.Append("
");
-
- return builder.ToString();
- }
- catch
- {
- return "Encountered an error trying to display this offer.";
- }
+ return record.Level.ToString();
}
- protected String CreateWanted4(object DataItem)
+ protected String CreateGender(object DataItem)
{
GtsRecord4 record = (GtsRecord4)DataItem;
- return String.Format("{3} (#{0})
{1}
Lv {2}",
- record.RequestedSpecies,
- record.RequestedGender,
- FormatLevels(record.RequestedMinLevel, record.RequestedMaxLevel),
- m_pokedex.Species(record.RequestedSpecies).Name);
+ return Format.GenderSymbol(record.Gender);
}
- protected String CreateTrainer4(object DataItem)
+ protected String CreateNickname(object DataItem)
+ {
+ return "todo";
+ }
+
+ protected String CreateSpecies(object DataItem)
+ {
+ GtsRecord4 record = (GtsRecord4)DataItem;
+ return m_pokedex.Species(record.Species).Name.ToString();
+ }
+
+ protected String CreatePokedex(object DataItem)
+ {
+ GtsRecord4 record = (GtsRecord4)DataItem;
+ return record.Species.ToString();
+ }
+
+ protected String CreateHeldItem(object DataItem)
+ {
+ return "todo";
+ }
+
+ protected String CreateNature(object DataItem)
+ {
+ return "todo";
+ }
+
+ protected String CreateAbility(object DataItem)
+ {
+ return "todo";
+ }
+
+ protected String CreateTrainer(object DataItem)
{
GtsRecord4 record = (GtsRecord4)DataItem;
return Common.HtmlEncode(record.TrainerName.Text);
}
+ protected String CreateWantedSpecies(object DataItem)
+ {
+ GtsRecord4 record = (GtsRecord4)DataItem;
+ return String.Format("{0} (#{1})",
+ m_pokedex.Species(record.RequestedSpecies).Name,
+ record.RequestedSpecies);
+ }
+
+ protected String CreateWantedGender(object DataItem)
+ {
+ GtsRecord4 record = (GtsRecord4)DataItem;
+ return Format.GenderSymbol(record.RequestedGender);
+ }
+
+ protected String CreateWantedLevel(object DataItem)
+ {
+ GtsRecord4 record = (GtsRecord4)DataItem;
+ return FormatLevels(record.RequestedMinLevel, record.RequestedMaxLevel);
+ }
+
+
+
+
+
protected String CreateOffer5(object DataItem)
{
GtsRecord5 record = (GtsRecord5)DataItem;
@@ -181,7 +174,7 @@ namespace PkmnFoundations.GTS
protected String CreateWanted5(object DataItem)
{
GtsRecord5 record = (GtsRecord5)DataItem;
- return String.Format("{3} (#{0})
{1}
Lv {2}",
+ return String.Format("{3} (#{0})
{1}
{2}",
record.RequestedSpecies,
record.RequestedGender,
FormatLevels(record.RequestedMinLevel, record.RequestedMaxLevel),
@@ -193,8 +186,5 @@ namespace PkmnFoundations.GTS
GtsRecord5 record = (GtsRecord5)DataItem;
return Common.HtmlEncode(record.TrainerName.Text);
}
-
-
-
}
}
\ No newline at end of file
diff --git a/web/gts/Default.aspx.designer.cs b/web/gts/Default.aspx.designer.cs
index 3d998e25..16959aec 100644
--- a/web/gts/Default.aspx.designer.cs
+++ b/web/gts/Default.aspx.designer.cs
@@ -39,42 +39,6 @@ namespace PkmnFoundations.GTS {
///
protected global::PkmnFoundations.Web.controls.PokemonPicker ppSpecies;
- ///
- /// txtLevelMin control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.TextBox txtLevelMin;
-
- ///
- /// txtLevelMax control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.TextBox txtLevelMax;
-
- ///
- /// chkMale control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.CheckBox chkMale;
-
- ///
- /// chkFemale control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.CheckBox chkFemale;
-
///
/// rbGen4 control.
///
@@ -120,6 +84,42 @@ namespace PkmnFoundations.GTS {
///
protected global::System.Web.UI.WebControls.Button btnSearch;
+ ///
+ /// txtLevelMin control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.TextBox txtLevelMin;
+
+ ///
+ /// txtLevelMax control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.TextBox txtLevelMax;
+
+ ///
+ /// chkMale control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.CheckBox chkMale;
+
+ ///
+ /// chkFemale control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.CheckBox chkFemale;
+
///
/// rptPokemon4 control.
///
diff --git a/web/gts/Pokemon.aspx.cs b/web/gts/Pokemon.aspx.cs
index fb6d7306..6add6371 100644
--- a/web/gts/Pokemon.aspx.cs
+++ b/web/gts/Pokemon.aspx.cs
@@ -85,14 +85,13 @@ namespace PkmnFoundations.Web.gts
{
litNickname.Text = pkmn.Nickname;
bool shiny = pkmn.IsShiny;
- imgPokemon.ImageUrl = (shiny ? "~/images/pkmn-lg-s/" : "~/images/pkmn-lg/") +
- SpeciesFilename(pkmn) + ".png";
+ imgPokemon.ImageUrl = WebFormat.PokemonImage(pkmn);
imgPokemon.AlternateText = pkmn.Species.Name.ToString();
phShiny.Visible = shiny;
// todo: pokerus
phPkrs.Visible = false;
phPkrsCured.Visible = false;
- litMarks.Text = CreateMarks(pkmn.Markings);
+ litMarks.Text = WebFormat.Markings(pkmn.Markings);
imgPokeball.ImageUrl = ItemFilename(pkmn.Pokeball);
imgPokeball.AlternateText = pkmn.Pokeball.Name.ToString();
imgPokeball.ToolTip = pkmn.Pokeball.Name.ToString();
@@ -157,49 +156,6 @@ namespace PkmnFoundations.Web.gts
rptUnknownRibbons.DataBind();
}
- private String[] m_marks = new String[] { "●", "▲", "■", "♥", "★", "♦" };
-
- private String CreateMarks(Markings markings)
- {
- StringBuilder result = new StringBuilder();
- int marking = 1;
- for (int value = 0; value < 6; value++)
- {
- if (((int)markings & marking) != 0)
- {
- result.Append("
");
- result.Append(m_marks[value]);
- result.Append("");
- }
- else
- {
- result.Append("
");
- result.Append(m_marks[value]);
- result.Append("");
- }
-
- marking <<= 1;
- }
-
- return result.ToString();
- }
-
- private String SpeciesFilename(Pokemon4 pkmn)
- {
- // todo: move to a more central location
- StringBuilder builder = new StringBuilder();
- builder.Append(pkmn.SpeciesID);
- if (pkmn.Form.Suffix.Length > 0)
- {
- builder.Append('-');
- builder.Append(pkmn.Form.Suffix);
- }
- if (pkmn.Species.GenderVariations && pkmn.Gender == Genders.Female)
- builder.Append("-f");
-
- return builder.ToString();
- }
-
private String ItemFilename(Item item)
{
return "~/images/item-sm/" + item.ID.ToString() + ".png";
diff --git a/web/src/Common.cs b/web/src/Common.cs
index 8f9652d2..7e8ff84d 100644
--- a/web/src/Common.cs
+++ b/web/src/Common.cs
@@ -39,6 +39,21 @@ namespace PkmnFoundations.Web
message[x] ^= m_pad[(x + padOffset) & 0xff];
}
+ public static String ResolveUrl(String url)
+ {
+ url = url.Trim();
+ if (!(url[0] == '~')) return url;
+ try
+ {
+ if (VirtualPathUtility.IsAppRelative(url)) return VirtualPathUtility.ToAbsolute(url);
+ return url;
+ }
+ catch (HttpException)
+ {
+ return url;
+ }
+ }
+
#region File extensions
public static String GetExtension(String filename)
{