Skip to content

Commit

Permalink
Initial push
Browse files Browse the repository at this point in the history
  • Loading branch information
Sui committed Jun 4, 2017
1 parent 13a9823 commit 36f6d0e
Show file tree
Hide file tree
Showing 36 changed files with 2,879 additions and 47 deletions.
55 changes: 8 additions & 47 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,47 +1,8 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
releases/
obj/
bin/
*.suo
*.user
*.vspx
*.psess
*.rar
98 changes: 98 additions & 0 deletions ElMatadorComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using LiveSplit.Model;
using LiveSplit.TimeFormatters;
using LiveSplit.UI.Components;
using LiveSplit.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml;
using System.Windows.Forms;
using System.Diagnostics;

namespace LiveSplit.ElMatador
{
class ElMatadorComponent : LogicComponent
{
public override string ComponentName
{
get { return "El Matador"; }
}

public ElMatadorSettings Settings { get; set; }

public bool Disposed { get; private set; }
public bool IsLayoutComponent { get; private set; }

private TimerModel _timer;
private GameMemory _gameMemory;
private LiveSplitState _state;

public ElMatadorComponent(LiveSplitState state, bool isLayoutComponent)
{
_state = state;
this.IsLayoutComponent = isLayoutComponent;

this.Settings = new ElMatadorSettings();

_timer = new TimerModel { CurrentState = state };
_timer.CurrentState.OnStart += timer_OnStart;

_gameMemory = new GameMemory(this.Settings);
_gameMemory.OnLoadStarted += gameMemory_OnLoadStarted;
_gameMemory.OnLoadFinished += gameMemory_OnLoadFinished;
state.OnStart += State_OnStart;
_gameMemory.StartMonitoring();
}

public override void Dispose()
{
this.Disposed = true;

_state.OnStart -= State_OnStart;
_timer.CurrentState.OnStart -= timer_OnStart;

if (_gameMemory != null)
{
_gameMemory.Stop();
}

}

void State_OnStart(object sender, EventArgs e)
{
}

void timer_OnStart(object sender, EventArgs e)
{
_timer.InitializeGameTime();
}

void gameMemory_OnLoadStarted(object sender, EventArgs e)
{
_state.IsGameTimePaused = true;
}

void gameMemory_OnLoadFinished(object sender, EventArgs e)
{
_state.IsGameTimePaused = false;
}

public override XmlNode GetSettings(XmlDocument document)
{
return this.Settings.GetSettings(document);
}

public override Control GetSettingsControl(LayoutMode mode)
{
return this.Settings;
}

public override void SetSettings(XmlNode settings)
{
this.Settings.SetSettings(settings);
}

public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { }
//public override void RenameComparison(string oldName, string newName) { }
}
}
92 changes: 92 additions & 0 deletions ElMatadorFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
using LiveSplit.UI;
using LiveSplit.UI.Components;
using System;
using LiveSplit.Model;

namespace LiveSplit.ElMatador
{
public class ElMatadorFactory : IComponentFactory
{
private ElMatadorComponent _instance;

public string ComponentName
{
get { return "El Matador"; }
}

public string Description
{
get { return "Automates load removal for El Matador."; }
}

public ComponentCategory Category
{
get { return ComponentCategory.Control; }
}

public IComponent Create(LiveSplitState state)
{
// workaround for livesplit 1.4 oversight where components can be loaded from two places at once
// remove all this junk when they fix it
string caller = new StackFrame(1).GetMethod().Name;
string callercaller = new StackFrame(2).GetMethod().Name;
bool createAsLayoutComponent = (caller == "LoadLayoutComponent" || caller == "AddComponent");

// if component is already loaded somewhere else
if (_instance != null && !_instance.Disposed)
{
// "autosplit components" can't throw exceptions for some reason, so return a dummy component
if (callercaller == "CreateAutoSplitter")
{
return new DummyComponent();
}

MessageBox.Show(
"LiveSplit.DXIW is already loaded in the " +
(_instance.IsLayoutComponent ? "Layout Editor" : "Splits Editor") + "!",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);

throw new Exception("Component already loaded.");
}

return (_instance = new ElMatadorComponent(state, createAsLayoutComponent));
}

public string UpdateName
{
get { return this.ComponentName; }
}

public string UpdateURL
{
get { return "https://raw.githubusercontent.com/SuiMachine/LiveSplit.ElMatador/master/"; }
}

public Version Version
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
}

public string XMLURL
{
get { return this.UpdateURL + "Components/update.LiveSplit.ElMatador.xml"; }
}
}

class DummyComponent : LogicComponent
{
public override string ComponentName { get { return "Dummy Component"; } }
public override void Dispose() { }
public override XmlNode GetSettings(XmlDocument document) { return document.CreateElement("Settings"); }
public override Control GetSettingsControl(LayoutMode mode) { return null; }
//public override void RenameComparison(string oldName, string newName) { }
public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { }
public override void SetSettings(XmlNode settings) { }
}
}
114 changes: 114 additions & 0 deletions ElMatadorSettings.Designer.cs

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

Loading

0 comments on commit 36f6d0e

Please sign in to comment.