Skip to content

Commit

Permalink
1.8.2 Release Readiness Commit
Browse files Browse the repository at this point in the history
from r7871
  • Loading branch information
hegyak committed Sep 23, 2014
1 parent fc6898f commit 4e94f48
Show file tree
Hide file tree
Showing 21 changed files with 1,153 additions and 843 deletions.
16 changes: 13 additions & 3 deletions BizHawk.Client.Common/lua/LuaAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ namespace BizHawk.Client.Common
{
public class LuaMethodAttributes : Attribute
{
public string Name { get; set; }
public string Description { get; set; }

public LuaMethodAttributes(string name, string description)
{
Name = name;
Description = description;
}

public string Name { get; set; }
public string Description { get; set; }
}

public class LuaLibraryAttributes : Attribute
{
public LuaLibraryAttributes(bool released)
{
Released = released;
}

public bool Released { get; set; }
}
}
5 changes: 5 additions & 0 deletions BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,10 @@ public bool IsMarker(int frame)
{
return this.Any(m => m == frame);
}

public TasMovieMarker Get(int frame)
{
return this.FirstOrDefault(m => m == frame);
}
}
}
18 changes: 10 additions & 8 deletions BizHawk.Client.Common/movie/tasproj/TasStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ public bool HasState(int frame)
/// </summary>
public void Invalidate(int frame)
{
if (States.Count == 0)
return;
// TODO be more efficient, this could get slow
while (LastKey >= frame)
{
var state = States[LastKey];
Used -= state.Length;
States.RemoveAt(States.Count - 1);
if (States.Count > 0 && frame > 0) // Never invalidate frame 0, TODO: Only if movie is a power-on movie should we keep frame 0, check this
{
var statesToRemove = States
.Where(x => x.Key >= frame)
.ToList();
foreach (var state in statesToRemove)
{
Used -= state.Value.Length;
States.Remove(state.Key);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Gui.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Input.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Savestate.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Tastudio.cs" />
<Compile Include="tools\Lua\LuaCheckbox.cs">
<SubType>Component</SubType>
</Compile>
Expand Down
4 changes: 1 addition & 3 deletions BizHawk.Client.EmuHawk/config/ProfileConfig.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions BizHawk.Client.EmuHawk/config/ProfileConfig.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ProfileDialogHelpTexBox.Text" xml:space="preserve">
<value>Options:
Casual Gaming - All about performance!

Tool-Assisted Speedruns - Maximum Accuracy!

N64 Tool-assisted Speedruns - Identical to Tool
Assisted Speedruns but with additional N64 specific settings.

Longplays - Stability is the key!</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.ComponentModel;

using BizHawk.Client.Common;
using LuaInterface;

namespace BizHawk.Client.EmuHawk
{
[Description("A library for manipulating the Tastudio dialog of the EmuHawk client")]
[LuaLibraryAttributes(released: false)]
public sealed class TastudioLuaLibrary : LuaLibraryBase
{
public TastudioLuaLibrary(Lua lua)
: base(lua) { }

public TastudioLuaLibrary(Lua lua, Action<string> logOutputCallback)
: base(lua, logOutputCallback) { }

public override string Name { get { return "tastudio"; } }

private TAStudio Tastudio
{
get
{
return GlobalWin.Tools.Get<TAStudio>() as TAStudio;
}
}


[LuaMethodAttributes(
"engaged",
"returns whether or not tastudio is currently engaged (active)"
)]
public bool Engaged()
{
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
}

[LuaMethodAttributes(
"getmarker",
"returns the marker text at the given frame, or an empty string if there is no marker for the given frame"
)]
public string GetMarker(int frame)
{
if (Engaged())
{
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
if (marker != null)
{
return marker.Message;
}
}

return string.Empty;
}

[LuaMethodAttributes(
"removemarker",
"if there is a marker for the given frame, it will be removed"
)]
public void RemoveMarker(int frame)
{
if (Engaged())
{
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
if (marker != null)
{
Tastudio.CurrentMovie.Markers.Remove(marker);
Tastudio.UpdateValues();
}
}
}

[LuaMethodAttributes(
"setmarker",
"Adds or sets a marker at the given frame with the given message"
)]
public void SetMarker(int frame, string message)
{
if (Engaged())
{
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
if (marker != null)
{
marker.Message = message;
}
else
{
Tastudio.CurrentMovie.Markers.Add(frame, message);
Tastudio.UpdateValues();
}
}
}
}
}
23 changes: 20 additions & 3 deletions BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public EmuLuaLibrary(LuaConsole passed)
Docs.Clear();
_caller = passed.Get();


var tt = typeof(TastudioLuaLibrary);
var mm = typeof(MainMemoryLuaLibrary);

var tatt = tt.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
var matt = mm.GetCustomAttributes(typeof(LuaLibraryAttributes), false);

// Register lua libraries
var libs = Assembly
.Load("BizHawk.Client.Common")
Expand All @@ -67,9 +74,19 @@ public EmuLuaLibrary(LuaConsole passed)

foreach (var lib in libs)
{
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
instance.LuaRegister(lib, Docs);
Libraries.Add(lib, instance);
bool addLibrary = true;
var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
if (attributes.Any())
{
addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttributes).Released;
}

if (addLibrary)
{
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
instance.LuaRegister(lib, Docs);
Libraries.Add(lib, instance);
}
}

_lua.RegisterFunction("print", this, GetType().GetMethod("Print"));
Expand Down
Loading

0 comments on commit 4e94f48

Please sign in to comment.