This commit is contained in:
erik 2025-05-29 17:56:44 +02:00
parent 1f85d9c6f0
commit 1ddfc9fbdf
6 changed files with 2 additions and 3199 deletions

View file

@ -1,96 +0,0 @@
using System;
using MyClasses.MetaViewWrappers;
namespace MosswartMassacre
{
internal static class MainView
{
private static IView View;
private static IStaticText lblTotalKills;
private static IStaticText lblKillsPer5Min;
private static IStaticText lblKillsPerHour;
private static IStaticText lblElapsedTime;
private static IStaticText lblRareCount;
private static IButton btnRestart;
private static IButton btnToggleRareMeta;
public static void ViewInit()
{
try
{
// Load the view from the embedded XML resource
View = MyClasses.MetaViewWrappers.ViewSystemSelector.CreateViewResource(
PluginCore.MyHost, "MosswartMassacre.ViewXML.mainView.xml");
// Get references to controls
lblTotalKills = (IStaticText)View["lblTotalKills"];
lblKillsPer5Min = (IStaticText)View["lblKillsPer5Min"];
lblKillsPerHour = (IStaticText)View["lblKillsPerHour"];
lblElapsedTime = (IStaticText)View["lblElapsedTime"];
lblRareCount = (IStaticText)View["lblRareCount"];
btnRestart = (IButton)View["btnRestart"];
btnRestart.Hit += OnRestartClick;
btnToggleRareMeta = (IButton)View["btnToggleRareMeta"];
btnToggleRareMeta.Hit += OnToggleRareMetaClick;
btnToggleRareMeta.Text = "Meta: ON";
PluginCore.WriteToChat("View initialized.");
}
catch (Exception ex)
{
PluginCore.WriteToChat("Error initializing view: " + ex.Message);
}
}
public static void ViewDestroy()
{
try
{
View.Dispose();
PluginCore.WriteToChat("View destroyed.");
btnRestart.Hit -= OnRestartClick;
btnToggleRareMeta.Hit -= OnToggleRareMetaClick;
}
catch (Exception ex)
{
PluginCore.WriteToChat("Error destroying view: " + ex.Message);
}
}
public static void UpdateKillStats(int totalKills, double killsPer5Min, double killsPerHour)
{
lblTotalKills.Text = $"Total Kills: {totalKills}";
lblKillsPer5Min.Text = $"Kills per 5 Min: {killsPer5Min:F2}";
lblKillsPerHour.Text = $"Kills per Hour: {killsPerHour:F2}";
}
public static void UpdateElapsedTime(TimeSpan elapsed)
{
int days = elapsed.Days;
int hours = elapsed.Hours;
int minutes = elapsed.Minutes;
int seconds = elapsed.Seconds;
if (days > 0)
lblElapsedTime.Text = $"Time: {days}d {hours:D2}:{minutes:D2}:{seconds:D2}";
else
lblElapsedTime.Text = $"Time: {hours:D2}:{minutes:D2}:{seconds:D2}";
}
public static void UpdateRareCount(int rareCount)
{
lblRareCount.Text = $"Rare Count: {rareCount}";
}
private static void OnRestartClick(object sender, EventArgs e)
{
PluginCore.RestartStats();
}
private static void OnToggleRareMetaClick(object sender, EventArgs e)
{
PluginCore.ToggleRareMeta();
}
public static void SetRareMetaToggleState(bool enabled)
{
btnToggleRareMeta.Text = enabled ? "Meta: ON" : "Meta: OFF";
}
}
}

View file

@ -26,5 +26,5 @@ using System.Runtime.InteropServices;
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
[assembly: AssemblyVersion("3.0.0.5")] [assembly: AssemblyVersion("3.0.0.6")]
[assembly: AssemblyFileVersion("3.0.0.5")] [assembly: AssemblyFileVersion("3.0.0.6")]

View file

@ -1,427 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//File: Wrapper.cs
//
//Description: Contains the interface definitions for the MetaViewWrappers classes.
//
//References required:
// System.Drawing
//
//This file is Copyright (c) 2010 VirindiPlugins
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
#if METAVIEW_PUBLIC_NS
namespace MetaViewWrappers
#else
namespace MyClasses.MetaViewWrappers
#endif
{
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
delegate void dClickedList(object sender, int row, int col);
#region EventArgs Classes
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVControlEventArgs : EventArgs
{
private int id;
internal MVControlEventArgs(int ID)
{
this.id = ID;
}
public int Id
{
get { return this.id; }
}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVIndexChangeEventArgs : MVControlEventArgs
{
private int index;
internal MVIndexChangeEventArgs(int ID, int Index)
: base(ID)
{
this.index = Index;
}
public int Index
{
get { return this.index; }
}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVListSelectEventArgs : MVControlEventArgs
{
private int row;
private int col;
internal MVListSelectEventArgs(int ID, int Row, int Column)
: base(ID)
{
this.row = Row;
this.col = Column;
}
public int Row
{
get { return this.row; }
}
public int Column
{
get { return this.col; }
}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVCheckBoxChangeEventArgs : MVControlEventArgs
{
private bool check;
internal MVCheckBoxChangeEventArgs(int ID, bool Check)
: base(ID)
{
this.check = Check;
}
public bool Checked
{
get { return this.check; }
}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVTextBoxChangeEventArgs : MVControlEventArgs
{
private string text;
internal MVTextBoxChangeEventArgs(int ID, string text)
: base(ID)
{
this.text = text;
}
public string Text
{
get { return this.text; }
}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
class MVTextBoxEndEventArgs : MVControlEventArgs
{
private bool success;
internal MVTextBoxEndEventArgs(int ID, bool success)
: base(ID)
{
this.success = success;
}
public bool Success
{
get { return this.success; }
}
}
#endregion EventArgs Classes
#region View
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IView: IDisposable
{
void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML);
void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML);
void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey);
void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey);
void SetIcon(int icon, int iconlibrary);
void SetIcon(int portalicon);
string Title { get; set; }
bool Visible { get; set; }
#if !VVS_WRAPPERS_PUBLIC
ViewSystemSelector.eViewSystem ViewType { get; }
#endif
System.Drawing.Point Location { get; set; }
System.Drawing.Rectangle Position { get; set; }
System.Drawing.Size Size { get; }
IControl this[string id] { get; }
void Activate();
void Deactivate();
bool Activated { get; set; }
}
#endregion View
#region Controls
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IControl : IDisposable
{
string Name { get; }
bool Visible { get; set; }
string TooltipText { get; set;}
int Id { get; }
System.Drawing.Rectangle LayoutPosition { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IButton : IControl
{
string Text { get; set; }
event EventHandler Hit;
event EventHandler<MVControlEventArgs> Click;
System.Drawing.Color TextColor { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface ICheckBox : IControl
{
string Text { get; set; }
bool Checked { get; set; }
event EventHandler<MVCheckBoxChangeEventArgs> Change;
event EventHandler Change_Old;
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface ITextBox : IControl
{
string Text { get; set; }
event EventHandler<MVTextBoxChangeEventArgs> Change;
event EventHandler Change_Old;
event EventHandler<MVTextBoxEndEventArgs> End;
int Caret { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface ICombo : IControl
{
IComboIndexer Text { get; }
IComboDataIndexer Data { get; }
int Count { get; }
int Selected { get; set; }
event EventHandler<MVIndexChangeEventArgs> Change;
event EventHandler Change_Old;
void Add(string text);
void Add(string text, object obj);
void Insert(int index, string text);
void RemoveAt(int index);
void Remove(int index);
void Clear();
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IComboIndexer
{
string this[int index] { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IComboDataIndexer
{
object this[int index] { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface ISlider : IControl
{
int Position { get; set; }
event EventHandler<MVIndexChangeEventArgs> Change;
event EventHandler Change_Old;
int Maximum { get; set; }
int Minimum { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IList : IControl
{
event EventHandler<MVListSelectEventArgs> Selected;
event dClickedList Click;
void Clear();
IListRow this[int row] { get; }
IListRow AddRow();
IListRow Add();
IListRow InsertRow(int pos);
IListRow Insert(int pos);
int RowCount { get; }
void RemoveRow(int index);
void Delete(int index);
int ColCount { get; }
int ScrollPosition { get; set;}
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IListRow
{
IListCell this[int col] { get; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IListCell
{
System.Drawing.Color Color { get; set; }
int Width { get; set; }
object this[int subval] { get; set; }
void ResetColor();
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IStaticText : IControl
{
string Text { get; set; }
event EventHandler<MVControlEventArgs> Click;
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface INotebook : IControl
{
event EventHandler<MVIndexChangeEventArgs> Change;
int ActiveTab { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IProgressBar : IControl
{
int Position { get; set; }
int Value { get; set; }
string PreText { get; set; }
int MaxValue { get; set; }
}
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
interface IImageButton : IControl
{
event EventHandler<MVControlEventArgs> Click;
void SetImages(int unpressed, int pressed);
void SetImages(int hmodule, int unpressed, int pressed);
int Background { set; }
System.Drawing.Color Matte { set; }
}
#endregion Controls
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,329 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//File: Wrapper_WireupHelper.cs
//
//Description: A helper utility that emulates Decal.Adapter's automagic view
// creation and control/event wireup with the MetaViewWrappers. A separate set
// of attributes is used.
//
//References required:
// Wrapper.cs
//
//This file is Copyright (c) 2010 VirindiPlugins
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
#if METAVIEW_PUBLIC_NS
namespace MetaViewWrappers
#else
namespace MyClasses.MetaViewWrappers
#endif
{
#region Attribute Definitions
[AttributeUsage(AttributeTargets.Class)]
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
sealed class MVWireUpControlEventsAttribute : Attribute
{
public MVWireUpControlEventsAttribute() { }
}
[AttributeUsage(AttributeTargets.Field)]
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
sealed class MVControlReferenceAttribute : Attribute
{
string ctrl;
// Summary:
// Construct a new ControlReference
//
// Parameters:
// control:
// Control to reference
public MVControlReferenceAttribute(string control)
{
ctrl = control;
}
// Summary:
// The Control Name
public string Control
{
get
{
return ctrl;
}
}
}
[AttributeUsage(AttributeTargets.Field)]
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
sealed class MVControlReferenceArrayAttribute : Attribute
{
private System.Collections.ObjectModel.Collection<string> myControls;
/// <summary>
/// Constructs a new ControlReference array
/// </summary>
/// <param name="controls">Names of the controls to put in the array</param>
public MVControlReferenceArrayAttribute(params string[] controls)
: base()
{
this.myControls = new System.Collections.ObjectModel.Collection<string>(controls);
}
/// <summary>
/// Control collection
/// </summary>
public System.Collections.ObjectModel.Collection<string> Controls
{
get
{
return this.myControls;
}
}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
sealed class MVViewAttribute : Attribute
{
string res;
// Summary:
// Constructs a new view from the specified resource
//
// Parameters:
// Resource:
// Embedded resource path
public MVViewAttribute(string resource)
{
res = resource;
}
// Summary:
// The resource to load
public string Resource
{
get
{
return res;
}
}
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
sealed class MVControlEventAttribute : Attribute
{
string c;
string e;
// Summary:
// Constructs the ControlEvent
//
// Parameters:
// control:
// Control Name
//
// controlEvent:
// Event to Wire
public MVControlEventAttribute(string control, string eventName)
{
c = control;
e = eventName;
}
// Summary:
// Control Name
public string Control
{
get
{
return c;
}
}
//
// Summary:
// Event to Wire
public string EventName
{
get
{
return e;
}
}
}
#endregion Attribute Definitions
#if VVS_WRAPPERS_PUBLIC
public
#else
internal
#endif
static class MVWireupHelper
{
private class ViewObjectInfo
{
public List<MyClasses.MetaViewWrappers.IView> Views = new List<IView>();
}
static Dictionary<object, ViewObjectInfo> VInfo = new Dictionary<object, ViewObjectInfo>();
public static MyClasses.MetaViewWrappers.IView GetDefaultView(object ViewObj)
{
if (!VInfo.ContainsKey(ViewObj))
return null;
if (VInfo[ViewObj].Views.Count == 0)
return null;
return VInfo[ViewObj].Views[0];
}
public static void WireupStart(object ViewObj, Decal.Adapter.Wrappers.PluginHost Host)
{
if (VInfo.ContainsKey(ViewObj))
WireupEnd(ViewObj);
ViewObjectInfo info = new ViewObjectInfo();
VInfo[ViewObj] = info;
Type ObjType = ViewObj.GetType();
//Start views
object[] viewattrs = ObjType.GetCustomAttributes(typeof(MVViewAttribute), true);
foreach (MVViewAttribute a in viewattrs)
{
info.Views.Add(MyClasses.MetaViewWrappers.ViewSystemSelector.CreateViewResource(Host, a.Resource));
}
//Wire up control references
foreach (FieldInfo fi in ObjType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy))
{
if (Attribute.IsDefined(fi, typeof(MVControlReferenceAttribute)))
{
MVControlReferenceAttribute attr = (MVControlReferenceAttribute)Attribute.GetCustomAttribute(fi, typeof(MVControlReferenceAttribute));
MetaViewWrappers.IControl mycontrol = null;
//Try each view
foreach (MyClasses.MetaViewWrappers.IView v in info.Views)
{
try
{
mycontrol = v[attr.Control];
}
catch { }
if (mycontrol != null)
break;
}
if (mycontrol == null)
throw new Exception("Invalid control reference \"" + attr.Control + "\"");
if (!fi.FieldType.IsAssignableFrom(mycontrol.GetType()))
throw new Exception("Control reference \"" + attr.Control + "\" is of wrong type");
fi.SetValue(ViewObj, mycontrol);
}
else if (Attribute.IsDefined(fi, typeof(MVControlReferenceArrayAttribute)))
{
MVControlReferenceArrayAttribute attr = (MVControlReferenceArrayAttribute)Attribute.GetCustomAttribute(fi, typeof(MVControlReferenceArrayAttribute));
//Only do the first view
if (info.Views.Count == 0)
throw new Exception("No views to which a control reference can attach");
Array controls = Array.CreateInstance(fi.FieldType.GetElementType(), attr.Controls.Count);
IView view = info.Views[0];
for (int i = 0; i < attr.Controls.Count; ++i)
{
controls.SetValue(view[attr.Controls[i]], i);
}
fi.SetValue(ViewObj, controls);
}
}
//Wire up events
foreach (MethodInfo mi in ObjType.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy))
{
if (!Attribute.IsDefined(mi, typeof(MVControlEventAttribute)))
continue;
Attribute[] attrs = Attribute.GetCustomAttributes(mi, typeof(MVControlEventAttribute));
foreach (MVControlEventAttribute attr in attrs)
{
MetaViewWrappers.IControl mycontrol = null;
//Try each view
foreach (MyClasses.MetaViewWrappers.IView v in info.Views)
{
try
{
mycontrol = v[attr.Control];
}
catch { }
if (mycontrol != null)
break;
}
if (mycontrol == null)
throw new Exception("Invalid control reference \"" + attr.Control + "\"");
EventInfo ei = mycontrol.GetType().GetEvent(attr.EventName);
ei.AddEventHandler(mycontrol, Delegate.CreateDelegate(ei.EventHandlerType, ViewObj, mi.Name));
}
}
}
public static void WireupEnd(object ViewObj)
{
if (!VInfo.ContainsKey(ViewObj))
return;
foreach (MyClasses.MetaViewWrappers.IView v in VInfo[ViewObj].Views)
v.Dispose();
VInfo.Remove(ViewObj);
}
}
}