remove ScrollingTextWidget
This commit is contained in:
@@ -210,7 +210,6 @@
|
|||||||
<Compile Include="TraitDictionary.cs" />
|
<Compile Include="TraitDictionary.cs" />
|
||||||
<Compile Include="Widgets\ChromeMetrics.cs" />
|
<Compile Include="Widgets\ChromeMetrics.cs" />
|
||||||
<Compile Include="Widgets\PasswordFieldWidget.cs" />
|
<Compile Include="Widgets\PasswordFieldWidget.cs" />
|
||||||
<Compile Include="Widgets\ScrollingTextWidget.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
|
||||||
{
|
|
||||||
public class ScrollingTextWidget : Widget
|
|
||||||
{
|
|
||||||
public string Text = "";
|
|
||||||
string ScrollingText = "";
|
|
||||||
|
|
||||||
public string Background = null;
|
|
||||||
|
|
||||||
public bool Bold = false;
|
|
||||||
|
|
||||||
public int ScrollLength = 200;
|
|
||||||
|
|
||||||
// ticks per single letter scroll
|
|
||||||
public int ScrollRate = 4;
|
|
||||||
|
|
||||||
string ScrollBuffer = "";
|
|
||||||
|
|
||||||
int ScrollLocation = 0;
|
|
||||||
int ScrollTick = 0;
|
|
||||||
|
|
||||||
public Func<string> GetText;
|
|
||||||
public Func<string> GetBackground;
|
|
||||||
|
|
||||||
public ScrollingTextWidget()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
GetText = () => Text;
|
|
||||||
GetBackground = () => Background;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ScrollingTextWidget(ScrollingTextWidget other)
|
|
||||||
: base(other)
|
|
||||||
{
|
|
||||||
Text = other.Text;
|
|
||||||
GetText = other.GetText;
|
|
||||||
Bold = other.Bold;
|
|
||||||
GetBackground = other.GetBackground;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Tick()
|
|
||||||
{
|
|
||||||
if (Text != "")
|
|
||||||
{
|
|
||||||
ScrollingText = Text;
|
|
||||||
Text = "";
|
|
||||||
}
|
|
||||||
UpdateScrollBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetScroll()
|
|
||||||
{
|
|
||||||
ScrollLocation = 0;
|
|
||||||
ScrollTick = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateScrollBuffer()
|
|
||||||
{
|
|
||||||
ScrollTick++;
|
|
||||||
|
|
||||||
if (ScrollTick < ScrollRate)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ScrollTick = 0;
|
|
||||||
ScrollBuffer = "";
|
|
||||||
|
|
||||||
if (ScrollingText.Substring(ScrollingText.Length - 4, 3) != " ")
|
|
||||||
ScrollingText += " ";
|
|
||||||
|
|
||||||
int tempScrollLocation = ScrollLocation;
|
|
||||||
for (int i = 0; i < ScrollLength; ++i)
|
|
||||||
{
|
|
||||||
ScrollBuffer += ScrollingText.Substring(tempScrollLocation, 1);
|
|
||||||
tempScrollLocation = (tempScrollLocation + 1) % ScrollingText.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollLocation = (ScrollLocation + 1) % ScrollingText.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetText(string newText)
|
|
||||||
{
|
|
||||||
Text = newText.Replace("\n", " ");
|
|
||||||
Text = Text.Replace("\r", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw()
|
|
||||||
{
|
|
||||||
var bg = GetBackground();
|
|
||||||
|
|
||||||
if (bg != null)
|
|
||||||
WidgetUtils.DrawPanel(bg, RenderBounds);
|
|
||||||
|
|
||||||
var font = (Bold) ? Game.Renderer.Fonts["Bold"] : Game.Renderer.Fonts["Regular"];
|
|
||||||
var text = GetText();
|
|
||||||
if (text == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int2 textSize = font.Measure(text);
|
|
||||||
int2 position = RenderOrigin + new int2(0, (Bounds.Height - textSize.Y) / 2);
|
|
||||||
|
|
||||||
Game.Renderer.EnableScissor(position.X, position.Y, Bounds.Width, Bounds.Height);
|
|
||||||
font.DrawText(ScrollBuffer, position, Color.White);
|
|
||||||
Game.Renderer.DisableScissor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Widget Clone() { return new ScrollingTextWidget(this); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user