Permalink
Browse files

City picker mostly done, few bit of work left on the list box control.

  • Loading branch information...
1 parent e8c1c8e commit 4ef14dd9558331dc3a1d58f819c03968506b9c50 @ddfczm ddfczm committed Apr 7, 2013
Showing with 1,588 additions and 130 deletions.
  1. +1 −0 TSO LoginServices/www/cityList.php
  2. +30 −1 TSOClient/Dummy/Program.cs
  3. BIN TSOClient/TSOClient.suo
  4. +3 −1 TSOClient/TSOClient/Code/GameController.cs
  5. +9 −1 TSOClient/TSOClient/Code/Network/NetworkController.cs
  6. +2 −2 TSOClient/TSOClient/Code/Sound/SoundManager.cs
  7. +151 −0 TSOClient/TSOClient/Code/UI/Controls/UIAlert.cs
  8. +38 −0 TSOClient/TSOClient/Code/UI/Controls/UIBlocker.cs
  9. +25 −2 TSOClient/TSOClient/Code/UI/Controls/UIButton.cs
  10. +32 −0 TSOClient/TSOClient/Code/UI/Controls/UIDialog.cs
  11. +17 −0 TSOClient/TSOClient/Code/UI/Controls/UIImage.cs
  12. +427 −0 TSOClient/TSOClient/Code/UI/Controls/UIListBox.cs
  13. +47 −85 TSOClient/TSOClient/Code/UI/Controls/UITextEdit.cs
  14. +1 −15 TSOClient/TSOClient/Code/UI/Framework/GameScreen.cs
  15. +94 −3 TSOClient/TSOClient/Code/UI/Framework/Parser/UIScript.cs
  16. +206 −0 TSOClient/TSOClient/Code/UI/Framework/TextRenderer.cs
  17. +38 −1 TSOClient/TSOClient/Code/UI/Framework/TextStyle.cs
  18. +7 −2 TSOClient/TSOClient/Code/UI/Framework/UIElement.cs
  19. +98 −0 TSOClient/TSOClient/Code/UI/Framework/UIScreen.cs
  20. +15 −0 TSOClient/TSOClient/Code/UI/Model/UIElementState.cs
  21. +182 −0 TSOClient/TSOClient/Code/UI/Panels/UICitySelector.cs
  22. +72 −1 TSOClient/TSOClient/Code/UI/ScreenManager.cs
  23. +23 −7 TSOClient/TSOClient/Code/UI/Screens/PersonSelection.cs
  24. +4 −1 TSOClient/TSOClient/Code/UI/Screens/PersonSelectionEdit.cs
  25. +15 −1 TSOClient/TSOClient/Code/Utils/TextureUtils.cs
  26. +10 −0 TSOClient/TSOClient/Content/SimDialogue_12px.spritefont
  27. +10 −0 TSOClient/TSOClient/Content/SimDialogue_14px.spritefont
  28. +10 −0 TSOClient/TSOClient/Content/SimDialogue_16px.spritefont
  29. +3 −3 TSOClient/TSOClient/Content/obj/x86/Debug/ContentPipeline.xml
  30. +5 −0 TSOClient/TSOClient/ContentManager/ContentStrings.cs
  31. +6 −0 TSOClient/TSOClient/TSOClient.csproj
  32. +7 −4 TSOClient/TSOServiceClient/Model/CityList.cs
@@ -34,6 +34,7 @@
'name' => $row['name'],
'uuid' => $row['uuid'],
'map' => $row['mapId'],
+ 'online' => $row['online'] == '1',
'status' => intval($row['status']),
'motd' => $motd
));
@@ -2,20 +2,49 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.IO;
namespace Dummy
{
class Program
{
+ /// <summary>
+ /// Just a place to do tests without loading the whole client
+ /// </summary>
+ /// <param name="args"></param>
static void Main(string[] args)
{
+ /** Work out char ranges used in the UI **/
+ var englishDir = @"C:\Program Files\Maxis\The Sims Online\TSOClient\gamedata\uitext\english.dir";
+ var files = Directory.GetFiles(englishDir);
+ var charsUsed = new List<int>();
+
+ foreach (var file in files)
+ {
+ var content = File.ReadAllText(file);
+ for (var i = 0; i < content.Length; i++)
+ {
+ var character = (int)content[i];
+ if (!charsUsed.Contains(character))
+ {
+ charsUsed.Add(character);
+ }
+ }
+ }
+
+ charsUsed.Sort();
+
+ System.Diagnostics.Debug.WriteLine(String.Join(", ", charsUsed.Select(x => x.ToString()).ToArray()));
+
+
+ /*
var service = new TSOServiceClient.TSOServiceClient();
var session = service.Authenticate(new TSOServiceClient.Model.AuthRequest {
Username = "dazlee4",
Password = "password"
});
- var x = true;
+ var x = true;*/
}
}
}
Binary file not shown.
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using TSOClient.Code.UI.Screens;
+using TSOServiceClient.Model;
namespace TSOClient.Code
{
@@ -59,9 +60,10 @@ public void ShowPersonSelection()
}
- public void ShowPersonCreation()
+ public void ShowPersonCreation(CityInfo selectedCity)
{
var screen = new PersonSelectionEdit();
+ screen.SelectedCity = selectedCity;
GameFacade.Screens.RemoveCurrent();
GameFacade.Screens.AddScreen(screen);
}
@@ -68,9 +68,17 @@ public bool InitialConnect(string username, string password, LoginProgressDelega
return false;
}
NetworkFacade.Avatars = avatarList.Body.Avatars;
-
progressDelegate(4);
+ foreach (var city in NetworkFacade.Cities)
+ {
+ var avatarInCity = NetworkFacade.Avatars.FirstOrDefault(x => x.CityId == city.ID);
+ if (avatarInCity != null)
+ {
+ city.Status = TSOServiceClient.Model.CityInfoStatus.Reserved;
+ }
+ }
+
return true;
}
@@ -22,9 +22,9 @@ public class SoundManager
/// </summary>
/// <param name="path"></param>
/// <param name="loop"></param>
- public void PlayBackgroundMusic(string path)
+ public int PlayBackgroundMusic(string path)
{
- LoadMusicTrack(path, 1, true);
+ return LoadMusicTrack(path, 1, true);
}
/// <summary>
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSOClient.Code.UI.Framework;
+using TSOClient.LUI;
+
+namespace TSOClient.Code.UI.Controls
+{
+ public class UIAlert : UIDialog
+ {
+ private UIAlertOptions Options;
+ private TextRendererResult MessageText;
+ private TextStyle TextStyle;
+
+ public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true)
+ {
+ this.Options = options;
+ this.Caption = options.Title;
+ this.Opacity = 0.9f;
+
+ TextStyle = TextStyle.DefaultLabel.Clone();
+ TextStyle.Size = 11;
+
+ /** Determine the size **/
+ ComputeText();
+
+ //32 from either edge
+ var w = options.Width;
+ var h = options.Height;
+ h = Math.Max(h, MessageText.BoundingBox.Height + 74);
+
+ SetSize(w, h);
+
+
+ /** Add buttons **/
+ var buttons = new List<UIButton>();
+ if ((options.Buttons & UIAlertButtons.OK) == UIAlertButtons.OK)
+ {
+ buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK));
+ }
+
+ /** Position buttons **/
+ var btnX = (w - ((buttons.Count * 100) + ((buttons.Count - 1) * 45))) / 2;
+ var btnY = h - 58;
+ foreach (var button in buttons)
+ {
+ button.Y = btnY;
+ button.X = btnX;
+ btnX += 45;
+ }
+ }
+
+ public void CenterAround(UIElement element)
+ {
+ CenterAround(element, 0, 0);
+ }
+
+ public void CenterAround(UIElement element, int offsetX, int offsetY)
+ {
+ var bounds = element.GetBounds();
+ if (bounds == null) { return; }
+
+
+ var topLeft =
+ element.LocalPoint(new Microsoft.Xna.Framework.Vector2(bounds.X, bounds.Y));
+
+
+ this.X = offsetX + topLeft.X + ((bounds.Width - this.Width) / 2);
+ this.Y = offsetY + topLeft.Y + ((bounds.Height - this.Height) / 2);
+ }
+
+
+ private Dictionary<UIElement, UIAlertButtons> ButtonMap = new Dictionary<UIElement, UIAlertButtons>();
+ private UIButton AddButton(string label, UIAlertButtons type)
+ {
+ var btn = new UIButton();
+ btn.Caption = label;
+ btn.Width = 100;
+ btn.OnButtonClick += new ButtonClickDelegate(btn_OnButtonClick);
+
+ ButtonMap.Add(btn, type);
+
+ this.Add(btn);
+ return btn;
+ }
+
+
+ void btn_OnButtonClick(UIElement button)
+ {
+ UIScreen.RemoveDialog(this);
+ }
+
+
+ private bool m_TextDirty = false;
+ protected override void CalculateMatrix()
+ {
+ base.CalculateMatrix();
+ m_TextDirty = true;
+ }
+
+ private void ComputeText()
+ {
+ MessageText = TextRenderer.ComputeText(Options.Message, new TextRendererOptions
+ {
+ Alignment = TextAlignment.Center,
+ MaxWidth = Options.Width - 64,
+ Position = new Microsoft.Xna.Framework.Vector2(32, 38),
+ Scale = _Scale,
+ TextStyle = TextStyle,
+ WordWrap = true
+ }, this);
+
+ m_TextDirty = false;
+ }
+
+ public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
+ {
+ base.Draw(batch);
+
+ if (m_TextDirty)
+ {
+ ComputeText();
+ }
+ TextRenderer.DrawText(MessageText.DrawingCommands, this, batch);
+ }
+ }
+
+
+ public class UIAlertOptions
+ {
+ public string Title { get; set; }
+ public string Message { get; set; }
+ public int Width = 340;
+ public int Height = -1;
+
+ public UIAlertButtons Buttons = UIAlertButtons.OK;
+ }
+
+ [Flags]
+ public enum UIAlertButtons
+ {
+ OK,
+ Cancel
+ }
+
+ public class UIAlertResult
+ {
+ public UIAlertButtons Button;
+ }
+}
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSOClient.Code.UI.Framework;
+using TSOClient.Code.UI.Model;
+
+namespace TSOClient.Code.UI.Controls
+{
+ /// <summary>
+ /// Just blocks and sinks mouse events
+ /// </summary>
+ public class UIBlocker : UIElement
+ {
+ private UIMouseEventRef MouseEvt;
+
+ public UIBlocker()
+ {
+ MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10), OnMouse);
+ SetSize(GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight);
+ }
+
+ private void OnMouse(UIMouseEventType type, UpdateState state)
+ {
+ }
+
+
+ public void SetSize(int width, int height)
+ {
+ MouseEvt.Region.Width = width;
+ MouseEvt.Region.Height = height;
+ }
+
+ public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
+ {
+ }
+ }
+}
@@ -59,6 +59,8 @@ static UIButton()
private bool m_HighlightNextDraw;
private float m_ResizeWidth;
+ private UIElementState m_State = UIElementState.Normal;
+
public bool Selected { get; set; }
@@ -172,6 +174,24 @@ private void CalculateAutoSize()
}
}
+ private void CalculateState() {
+ if (m_Disabled) {
+ m_State = UIElementState.Disabled;
+ return;
+ }
+
+ m_State = UIElementState.Normal;
+ switch(m_CurrentFrame){
+ case 1:
+ m_State = UIElementState.Selected;
+ break;
+
+ case 2:
+ m_State = UIElementState.Highlighted;
+ break;
+ }
+
+ }
private bool m_Clicking = false;
@@ -186,7 +206,7 @@ public bool Highlight
public bool Disabled
{
get { return m_Disabled; }
- set { m_Disabled = value; }
+ set { m_Disabled = value; CalculateState(); }
}
/// <summary>
@@ -208,6 +228,7 @@ public int CurrentFrame
if(value < 4)
{
m_CurrentFrame = value;
+ CalculateState();
}
}
}
@@ -257,6 +278,8 @@ private void OnMouseEvent(UIMouseEventType type, UpdateState state)
m_CurrentFrame = m_isOver ? 2 : 0;
break;
}
+
+ CalculateState();
}
public override void Draw(SpriteBatch SBatch)
@@ -306,7 +329,7 @@ public override void Draw(SpriteBatch SBatch)
*/
if (m_Caption != null && m_CaptionStyle != null)
{
- this.DrawLocalString(SBatch, m_Caption, Vector2.Zero, m_CaptionStyle, GetBounds(), TextAlignment.Center | TextAlignment.Middle);
+ this.DrawLocalString(SBatch, m_Caption, Vector2.Zero, m_CaptionStyle, GetBounds(), TextAlignment.Center | TextAlignment.Middle, Rectangle.Empty, m_State);
}
//SBatch.DrawString(m_Screen.ScreenMgr.SprFontSmall, m_Caption,
Oops, something went wrong.

0 comments on commit 4ef14dd

Please sign in to comment.