Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions Client/Simitone/Simitone.Client/Simitone.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
<AssemblyName>Simitone.Client</AssemblyName>
<FileAlignment>512</FileAlignment>
</PropertyGroup>

<ItemGroup>
<None Remove="Content\uigraphics\common\button.mobile.png" />
<None Remove="Content\uigraphics\common\greenbutton.mobile.png" />
<None Remove="Content\uigraphics\dialog\check.bmp" />
<None Remove="Content\uigraphics\dialog\check.png" />
<None Remove="Content\uigraphics\dialog\radio.bmp" />
<None Remove="Content\uigraphics\dialog\radio.png" />
<None Remove="Content\uigraphics\live\modes\opt_audio.png" />
<None Remove="Content\uigraphics\live\modes\opt_general.png" />
<None Remove="Content\uigraphics\live\modes\opt_gfx.png" />
<None Remove="Content\uigraphics\live\modes\opt_lang.png" />
<None Remove="Content\uigraphics\live\modes\opt_setting.png" />
<None Remove="Content\uigraphics\ngbh\ngbh_shadow.png" />
</ItemGroup>

<ItemGroup>
<Content Include="Content\3D\TEX_0.png">
Expand Down Expand Up @@ -77,9 +92,15 @@
<Content Include="Content\uigraphics\common\btn_back.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\common\button.mobile.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\common\circle10px.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\common\greenbutton.mobile.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\desktop\d_live_bg.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -140,9 +161,15 @@
<Content Include="Content\uigraphics\desktop\d_live_zoomp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\common\check.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\dialog\ngbh_outline.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\common\radio.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\blank_blue.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -464,6 +491,18 @@
<Content Include="Content\uigraphics\live\modes\live_relationships.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_audio.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_general.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_gfx.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_lang.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_neigh.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -473,6 +512,9 @@
<Content Include="Content\uigraphics\live\modes\opt_save.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\modes\opt_setting.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\live\money_bg.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -623,6 +665,9 @@
<Content Include="Content\uigraphics\ngbh\ngbh_opt.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\ngbh\ngbh_shadow.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\uigraphics\ngbh\ngbh_studio.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
30 changes: 24 additions & 6 deletions Client/Simitone/Simitone.Client/SimitoneGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using MSDFData;
using FSO.LotView.Model;
using Simitone.Client.UI.Panels;
using FSO.Files.Formats.IFF.Chunks;

namespace Simitone.Client
{
Expand All @@ -31,10 +32,19 @@ namespace Simitone.Client
/// </summary>
public class SimitoneGame : FSO.Common.Rendering.Framework.Game
{
//** if the window is resized below this value, UI elements can attempt to resize to available space below 0px -- resulting in immediate crash
// we should ensure a minimum width and height of at least the smallest supported resolution by the UI.
const int MIN_WIDTH = 800, MIN_HEIGHT = 600;

public UILayer uiLayer;
public _3DLayer SceneMgr;
private bool HasUpdated;

/// <summary>
/// The current language setting of this Simitone game
/// </summary>
public STRLangCode CurrentLanguage { get; private set; } = STRLangCode.EnglishUS;

public SimitoneGame() : base()
{
GameFacade.Game = this;
Expand All @@ -57,7 +67,7 @@ public SimitoneGame() : base()
}

this.Window.AllowUserResizing = true;
this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);
this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);

Thread.CurrentThread.Name = "Game";

Expand All @@ -69,8 +79,8 @@ void Window_ClientSizeChanged(object sender, EventArgs e)
if (newChange || !GlobalSettings.Default.Windowed || FSOEnvironment.SoftwareKeyboard) return;
if (Window.ClientBounds.Width == 0 || Window.ClientBounds.Height == 0) return;
newChange = true;
var width = Math.Max(1, Window.ClientBounds.Width);
var height = Math.Max(1, Window.ClientBounds.Height);
var width = Math.Max(MIN_WIDTH, Window.ClientBounds.Width);
var height = Math.Max(MIN_HEIGHT, Window.ClientBounds.Height);
Graphics.PreferredBackBufferWidth = width;
Graphics.PreferredBackBufferHeight = height;
Graphics.ApplyChanges();
Expand All @@ -93,7 +103,6 @@ void Window_ClientSizeChanged(object sender, EventArgs e)
/// </summary>
protected override void Initialize()
{

var settings = GlobalSettings.Default;
if (FSOEnvironment.DPIScaleFactor != 1 || FSOEnvironment.SoftwareDepth)
{
Expand Down Expand Up @@ -161,8 +170,7 @@ protected override void Initialize()
hit.SetMasterVolume(HITVolumeGroup.VOX, GlobalSettings.Default.VoxVolume / 10f);
hit.SetMasterVolume(HITVolumeGroup.AMBIENCE, GlobalSettings.Default.AmbienceVolume / 10f);

ContentStrings.TS1 = true;
GameFacade.Strings = new ContentStrings();
ChangeLanguage((STRLangCode)settings.LanguageCode);

GraphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.None };

Expand All @@ -189,6 +197,16 @@ protected override void Initialize()
}
}

internal void ChangeLanguage(STRLangCode NewLanguage)
{
//check if this language is already loaded.
if (GameFacade.Strings != null && CurrentLanguage == NewLanguage) return;
CurrentLanguage = NewLanguage;

ContentStrings.TS1 = true;
GameFacade.Strings = new ContentStrings(CurrentLanguage);
}

private void SaveGraphicsModePreference(GlobalGraphicsMode obj)
{
GlobalSettings.Default.GlobalGraphicsMode = (int)obj;
Expand Down
33 changes: 33 additions & 0 deletions Client/Simitone/Simitone.Client/TS1Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simitone.Client
{
internal static class GameplaySpeed
{
internal const int Pause = 4,
Play = 1,
FastForward = 2,
FastFastForward = 3,
Disabled = -1;

/// <summary>
/// Maps <c>VMSpeedMultiplier</c> settings to constants defined in <see cref="GameplaySpeed"/>
/// </summary>
internal static Dictionary<int, int> RemapSpeed = new Dictionary<int, int>()
{
{0, Pause}, //pause
{1, Play}, //1 speed
{3, FastForward}, //2 speed
{10, FastFastForward}, //3 speed
{-1, Disabled } // disabled (buy/build,etc.)
};
/// <summary>
/// Maps constants defined in <see cref="GameplaySpeed"/> to <c>VMSpeedMultiplier</c> settings
/// </summary>
internal static Dictionary<int, int> ReverseRemap = GameplaySpeed.RemapSpeed.ToDictionary(x => x.Value, x => x.Key);
}
}
46 changes: 43 additions & 3 deletions Client/Simitone/Simitone.Client/UI/Controls/UIBigButton.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using FSO.Client;
using FSO.Client.UI.Controls;
using FSO.Client.UI.Framework;
using FSO.Content;
using Simitone.Client.UI.Model;
using Simitone.Client.UI.Screens;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -12,13 +14,51 @@ namespace Simitone.Client.UI.Controls
{
public class UIBigButton : UIButton
{
float _mySize = 0;
string _ghostText = string.Empty;

public UIBigButton(bool green) : base()
{
bool Desktop = (UIScreen.Current as TS1GameScreen).Desktop;
string texRef = Desktop ? (green ? "greenbutton.png" : "button.png") : (green ? "greenbutton.mobile.png" : "button.mobile.png");

CaptionStyle = CaptionStyle.Clone();
CaptionStyle.Size = 37;
CaptionStyle.Color = (green)?UIStyle.Current.GreenBtnTxt:UIStyle.Current.BtnTxt;
CaptionStyle.Size = Desktop ? 14 : 37;
CaptionStyle.Color = green ? UIStyle.Current.GreenBtnTxt : UIStyle.Current.BtnTxt;
CaptionStyle.DisabledColor = UIStyle.Current.BtnDisable;
Texture = Content.Get().CustomUI.Get(green ? "greenbutton.png" : "button.png").Get(GameFacade.GraphicsDevice);
CaptionStyle.HighlightedColor = green ? UIStyle.Current.BtnPrimaryHighlight : UIStyle.Current.BtnNormalHighlight;
Texture = Content.Get().CustomUI.Get(texRef).Get(GameFacade.GraphicsDevice);
}

private void SetGhostText()
{
_ghostText = string.Empty;
var desiredSize = CaptionStyle.MeasureString(Caption);
if (desiredSize.X > Width)
{
//truncate
float overage = desiredSize.X - Width;
float charSize = desiredSize.X / Caption.Length;
int trimChars = 4 + (int)(overage / charSize); // 3 '.' plus truncating error correction
int totalChars = Math.Max(0, Caption.Length - trimChars);
_ghostText = Caption.Substring(0, totalChars) + "...";
}
}
public override void Draw(UISpriteBatch SBatch)
{
if (_mySize != Width) // on size changed invalidate size changed
{
SetGhostText();
_mySize = Width;
}

string caption = Caption;
if (!string.IsNullOrWhiteSpace(_ghostText))
Caption = _ghostText;

base.Draw(SBatch);

caption = Caption;
}
}
}
39 changes: 38 additions & 1 deletion Client/Simitone/Simitone.Client/UI/Controls/UIElasticButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,39 @@

namespace Simitone.Client.UI.Controls
{
public class UIElasticButton : UIButton
public interface IUIShadowElement
{
UIShadow ElementShadow { get; }
}

public class UIShadow
{
public UIShadow(Texture2D shadowTexture, float shadowOpacity = .5f, Color? shadowColor = default, float shadowDepth = 2f, Vector2? shadowDirection = default, Vector2? shadowSize = default)
{
ShadowTexture = shadowTexture;
ShadowOpacity = shadowOpacity;
ShadowColor = shadowColor ?? Color.Black;
ShadowDepth = shadowDepth;
ShadowDirection = shadowDirection ?? new Vector2(1,1);
ShadowDirection.Normalize();
ShadowSize = shadowSize ?? new(shadowTexture.Width,shadowTexture.Height);
}

public Texture2D ShadowTexture { get; set; }
public float ShadowOpacity { get; set; }
public Color ShadowColor { get; set; }
public float ShadowDepth { get; set; }
public Vector2 ShadowDirection { get; set; }
public Vector2 ShadowSize { get; set; }

public void Draw(UIElement VisualParent, Vector2 Origin, SpriteBatch Batch)
{
if (ShadowTexture == null) return;
VisualParent.DrawLocalTexture(Batch, ShadowTexture, Origin + (ShadowDirection * ShadowDepth));
}
}

public class UIElasticButton : UIButton, IUIShadowElement
{
public UIElasticButton(Texture2D tex) : base (tex)
{
Expand All @@ -29,6 +61,9 @@ public UIElasticButton(Texture2D tex) : base (tex)

private int LastState;
private int DownTime = 5;

public UIShadow ElementShadow { get; set; }

public override void Update(UpdateState state)
{
base.Update(state);
Expand Down Expand Up @@ -69,6 +104,8 @@ public override void Update(UpdateState state)
public override void Draw(UISpriteBatch SBatch)
{
if (!Visible) return;
if (ElementShadow != null)
ElementShadow.Draw(this, new Vector2(Texture.Width, Texture.Height) / -2, SBatch);
DrawLocalTexture(SBatch, Texture, null, new Vector2(Texture.Width, Texture.Height) / -2, Vector2.One, Color.White * (Disabled?0.5f:1f));
}
}
Expand Down
Loading