Add project files.

This commit is contained in:
erikn 2025-03-28 22:11:17 +01:00
parent 7e4909f545
commit b533681978
23 changed files with 7246 additions and 0 deletions

View file

@ -0,0 +1,54 @@
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;
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"];
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.");
}
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}";
}
}
}

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C97E839-4D05-4A5F-B0C8-E8E778654322}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MosswartMassacre</RootNamespace>
<AssemblyName>MosswartMassacre</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;VVS_REFERENCED;DECAL_INTEROP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Decal.Adapter">
<HintPath>lib\Decal.Adapter.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Decal.Interop.Core, Version=2.9.8.3, Culture=neutral, PublicKeyToken=481f17d392f1fb65, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>lib\Decal.Interop.Core.DLL</HintPath>
</Reference>
<Reference Include="Decal.Interop.Inject, Version=2.9.8.3, Culture=neutral, PublicKeyToken=481f17d392f1fb65, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>lib\Decal.Interop.Inject.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="VirindiViewService">
<HintPath>lib\VirindiViewService.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainView.cs" />
<Compile Include="PluginCore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ViewSystemSelector.cs" />
<Compile Include="Wrapper.cs" />
<Compile Include="Wrapper_Decal.cs" />
<Compile Include="Wrapper_MyHuds.cs" />
<Compile Include="Wrapper_WireupHelper.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ViewXML\mainView.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,141 @@
using System;
using System.Text.RegularExpressions;
using Decal.Adapter;
using Decal.Adapter.Wrappers;
namespace MosswartMassacre
{
[FriendlyName("Mosswart Massacre")]
public class PluginCore : PluginBase
{
internal static PluginHost MyHost;
internal static int totalKills = 0;
internal static DateTime lastKillTime = DateTime.Now;
internal static double killsPer5Min = 0;
internal static double killsPerHour = 0;
internal static DateTime statsStartTime = DateTime.Now;
protected override void Startup()
{
try
{
MyHost = Host;
WriteToChat("Mosswart Massacre has started!");
// Subscribe to chat message event
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
// Initialize the view (UI)
MainView.ViewInit();
}
catch (Exception ex)
{
WriteToChat("Error during startup: " + ex.Message);
}
}
protected override void Shutdown()
{
try
{
WriteToChat("Mosswart Massacre is shutting down...");
// Unsubscribe from chat message event
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
// Clean up the view
MainView.ViewDestroy();
MyHost = null;
}
catch (Exception ex)
{
WriteToChat("Error during shutdown: " + ex.Message);
}
}
private void OnChatText(object sender, ChatTextInterceptEventArgs e)
{
try
{
if (IsKilledByMeMessage(e.Text))
{
totalKills++;
CalculateKillsPerInterval();
MainView.UpdateKillStats(totalKills, killsPer5Min, killsPerHour);
}
}
catch (Exception ex)
{
WriteToChat("Error processing chat message: " + ex.Message);
}
}
private void CalculateKillsPerInterval()
{
// Calculate kills per 5 minutes
var timeSinceLastKill = DateTime.Now - lastKillTime;
if (timeSinceLastKill.TotalMinutes > 0)
{
killsPer5Min = (totalKills / (DateTime.Now - statsStartTime).TotalMinutes) * 5;
killsPerHour = (totalKills / (DateTime.Now - statsStartTime).TotalMinutes) * 60;
}
lastKillTime = DateTime.Now;
}
private bool IsKilledByMeMessage(string text)
{
string[] killPatterns = new string[]
{
@"^You flatten (?<targetname>.+)'s body with the force of your assault!$",
@"^You bring (?<targetname>.+) to a fiery end!$",
@"^You beat (?<targetname>.+) to a lifeless pulp!$",
@"^You smite (?<targetname>.+) mightily!$",
@"^You obliterate (?<targetname>.+)!$",
@"^You run (?<targetname>.+) through!$",
@"^You reduce (?<targetname>.+) to a sizzling, oozing mass!$",
@"^You knock (?<targetname>.+) into next Morningthaw!$",
@"^You split (?<targetname>.+) apart!$",
@"^You cleave (?<targetname>.+) in twain!$",
@"^You slay (?<targetname>.+) viciously enough to impart death several times over!$",
@"^You reduce (?<targetname>.+) to a drained, twisted corpse!$",
@"^Your killing blow nearly turns (?<targetname>.+) inside-out!$",
@"^Your attack stops (?<targetname>.+) cold!$",
@"^Your lightning coruscates over (?<targetname>.+)'s mortal remains!$",
@"^Your assault sends (?<targetname>.+) to an icy death!$",
@"^You killed (?<targetname>.+)!$",
@"^The thunder of crushing (?<targetname>.+) is followed by the deafening silence of death!$",
@"^The deadly force of your attack is so strong that (?<targetname>.+)'s ancestors feel it!$",
@"^(?<targetname>.+)'s seared corpse smolders before you!$",
@"^(?<targetname>.+) is reduced to cinders!$",
@"^(?<targetname>.+) is shattered by your assault!$",
@"^(?<targetname>.+) catches your attack, with dire consequences!$",
@"^(?<targetname>.+) is utterly destroyed by your attack!$",
@"^(?<targetname>.+) suffers a frozen fate!$",
@"^(?<targetname>.+)'s perforated corpse falls before you!$",
@"^(?<targetname>.+) is fatally punctured!$",
@"^(?<targetname>.+)'s death is preceded by a sharp, stabbing pain!$",
@"^(?<targetname>.+) is torn to ribbons by your assault!$",
@"^(?<targetname>.+) is liquified by your attack!$",
@"^(?<targetname>.+)'s last strength dissolves before you!$",
@"^Electricity tears (?<targetname>.+) apart!$",
@"^Blistered by lightning, (?<targetname>.+) falls!$",
@"^(?<targetname>.+)'s last strength withers before you!$",
@"^(?<targetname>.+) is dessicated by your attack!$",
@"^(?<targetname>.+) is incinerated by your assault!$"
};
foreach (string pattern in killPatterns)
{
if (Regex.IsMatch(text, pattern))
return true;
}
return false;
}
public static void WriteToChat(string message)
{
MyHost.Actions.AddChatText("[Mosswart Massacre] " + message, 0, 1);
}
}
}

View file

@ -0,0 +1,30 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Mosswart Massacre")]
[assembly: AssemblyDescription("Track and report monster kills in Asheron's Call")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mosswart Massacre Dev Team")]
[assembly: AssemblyProduct("Mosswart Massacre Plugin")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9b6a07e1-ae78-47f4-b09c-174f6a27d7a3")]
// Version information for an assembly consists of the following four values:
// Major Version
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MosswartMassacre.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MosswartMassacre.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,262 @@
///////////////////////////////////////////////////////////////////////////////
//File: ViewSystemSelector.cs
//
//Description: Contains the MyClasses.MetaViewWrappers.ViewSystemSelector class,
// which is used to determine whether the Virindi View Service is enabled.
// As with all the VVS wrappers, the VVS_REFERENCED compilation symbol must be
// defined for the VVS code to be compiled. Otherwise, only Decal views are used.
//
//References required:
// VirindiViewService (if VVS_REFERENCED is defined)
// Decal.Adapter
// Decal.Interop.Core
//
//This file is Copyright (c) 2009 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
{
internal static class ViewSystemSelector
{
public enum eViewSystem
{
DecalInject,
VirindiViewService,
}
///////////////////////////////System presence detection///////////////////////////////
public static bool IsPresent(Decal.Adapter.Wrappers.PluginHost pHost, eViewSystem VSystem)
{
switch (VSystem)
{
case eViewSystem.DecalInject:
return true;
case eViewSystem.VirindiViewService:
return VirindiViewsPresent(pHost);
default:
return false;
}
}
static bool VirindiViewsPresent(Decal.Adapter.Wrappers.PluginHost pHost)
{
#if VVS_REFERENCED
System.Reflection.Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (System.Reflection.Assembly a in asms)
{
AssemblyName nmm = a.GetName();
if ((nmm.Name == "VirindiViewService") && (nmm.Version >= new System.Version("1.0.0.37")))
{
try
{
return Curtain_VVS_Running();
}
catch
{
return false;
}
}
}
return false;
#else
return false;
#endif
}
public static bool VirindiViewsPresent(Decal.Adapter.Wrappers.PluginHost pHost, Version minver)
{
#if VVS_REFERENCED
System.Reflection.Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (System.Reflection.Assembly a in asms)
{
AssemblyName nm = a.GetName();
if ((nm.Name == "VirindiViewService") && (nm.Version >= minver))
{
try
{
return Curtain_VVS_Running();
}
catch
{
return false;
}
}
}
return false;
#else
return false;
#endif
}
#if VVS_REFERENCED
static bool Curtain_VVS_Running()
{
return VirindiViewService.Service.Running;
}
#endif
///////////////////////////////CreateViewResource///////////////////////////////
public static IView CreateViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
#if VVS_REFERENCED
if (IsPresent(pHost, eViewSystem.VirindiViewService))
return CreateViewResource(pHost, pXMLResource, eViewSystem.VirindiViewService);
else
#endif
return CreateViewResource(pHost, pXMLResource, eViewSystem.DecalInject);
}
public static IView CreateViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource, eViewSystem VSystem)
{
if (!IsPresent(pHost, VSystem)) return null;
switch (VSystem)
{
case eViewSystem.DecalInject:
return CreateDecalViewResource(pHost, pXMLResource);
case eViewSystem.VirindiViewService:
#if VVS_REFERENCED
return CreateMyHudViewResource(pHost, pXMLResource);
#else
break;
#endif
}
return null;
}
static IView CreateDecalViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
IView ret = new DecalControls.View();
ret.Initialize(pHost, pXMLResource);
return ret;
}
#if VVS_REFERENCED
static IView CreateMyHudViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
IView ret = new VirindiViewServiceHudControls.View();
ret.Initialize(pHost, pXMLResource);
return ret;
}
#endif
///////////////////////////////CreateViewXML///////////////////////////////
public static IView CreateViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
#if VVS_REFERENCED
if (IsPresent(pHost, eViewSystem.VirindiViewService))
return CreateViewXML(pHost, pXML, eViewSystem.VirindiViewService);
else
#endif
return CreateViewXML(pHost, pXML, eViewSystem.DecalInject);
}
public static IView CreateViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML, eViewSystem VSystem)
{
if (!IsPresent(pHost, VSystem)) return null;
switch (VSystem)
{
case eViewSystem.DecalInject:
return CreateDecalViewXML(pHost, pXML);
case eViewSystem.VirindiViewService:
#if VVS_REFERENCED
return CreateMyHudViewXML(pHost, pXML);
#else
break;
#endif
}
return null;
}
static IView CreateDecalViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
IView ret = new DecalControls.View();
ret.InitializeRawXML(pHost, pXML);
return ret;
}
#if VVS_REFERENCED
static IView CreateMyHudViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
IView ret = new VirindiViewServiceHudControls.View();
ret.InitializeRawXML(pHost, pXML);
return ret;
}
#endif
///////////////////////////////HasChatOpen///////////////////////////////
public static bool AnySystemHasChatOpen(Decal.Adapter.Wrappers.PluginHost pHost)
{
if (IsPresent(pHost, eViewSystem.VirindiViewService))
if (HasChatOpen_VirindiViews()) return true;
if (pHost.Actions.ChatState) return true;
return false;
}
static bool HasChatOpen_VirindiViews()
{
#if VVS_REFERENCED
if (VirindiViewService.HudView.FocusControl != null)
{
if (VirindiViewService.HudView.FocusControl.GetType() == typeof(VirindiViewService.Controls.HudTextBox))
return true;
}
return false;
#else
return false;
#endif
}
public delegate void delConditionalSplit(object data);
public static void ViewConditionalSplit(IView v, delConditionalSplit onDecal, delConditionalSplit onVVS, object data)
{
Type vtype = v.GetType();
#if VVS_REFERENCED
if (vtype == typeof(VirindiViewServiceHudControls.View))
{
if (onVVS != null)
onVVS(data);
}
#endif
if (vtype == typeof(DecalControls.View))
{
if (onDecal != null)
onDecal(data);
}
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<view icon="7735" title="Mosswart Massacre" width="300" height="270">
<control progid="DecalControls.FixedLayout" clipped="">
<control progid="DecalControls.StaticText" name="lblTotalKills" left="10" top="10" width="280" height="18" text="Total Kills: 0"/>
<control progid="DecalControls.StaticText" name="lblKillsPer5Min" left="10" top="30" width="280" height="18" text="Kills per 5 Min: 0"/>
<control progid="DecalControls.StaticText" name="lblKillsPerHour" left="10" top="50" width="280" height="18" text="Kills per Hour: 0"/>
</control>
</view>

View file

@ -0,0 +1,262 @@
///////////////////////////////////////////////////////////////////////////////
//File: ViewSystemSelector.cs
//
//Description: Contains the MyClasses.MetaViewWrappers.ViewSystemSelector class,
// which is used to determine whether the Virindi View Service is enabled.
// As with all the VVS wrappers, the VVS_REFERENCED compilation symbol must be
// defined for the VVS code to be compiled. Otherwise, only Decal views are used.
//
//References required:
// VirindiViewService (if VVS_REFERENCED is defined)
// Decal.Adapter
// Decal.Interop.Core
//
//This file is Copyright (c) 2009 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
{
internal static class ViewSystemSelector
{
public enum eViewSystem
{
DecalInject,
VirindiViewService,
}
///////////////////////////////System presence detection///////////////////////////////
public static bool IsPresent(Decal.Adapter.Wrappers.PluginHost pHost, eViewSystem VSystem)
{
switch (VSystem)
{
case eViewSystem.DecalInject:
return true;
case eViewSystem.VirindiViewService:
return VirindiViewsPresent(pHost);
default:
return false;
}
}
static bool VirindiViewsPresent(Decal.Adapter.Wrappers.PluginHost pHost)
{
#if VVS_REFERENCED
System.Reflection.Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (System.Reflection.Assembly a in asms)
{
AssemblyName nmm = a.GetName();
if ((nmm.Name == "VirindiViewService") && (nmm.Version >= new System.Version("1.0.0.37")))
{
try
{
return Curtain_VVS_Running();
}
catch
{
return false;
}
}
}
return false;
#else
return false;
#endif
}
public static bool VirindiViewsPresent(Decal.Adapter.Wrappers.PluginHost pHost, Version minver)
{
#if VVS_REFERENCED
System.Reflection.Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (System.Reflection.Assembly a in asms)
{
AssemblyName nm = a.GetName();
if ((nm.Name == "VirindiViewService") && (nm.Version >= minver))
{
try
{
return Curtain_VVS_Running();
}
catch
{
return false;
}
}
}
return false;
#else
return false;
#endif
}
#if VVS_REFERENCED
static bool Curtain_VVS_Running()
{
return VirindiViewService.Service.Running;
}
#endif
///////////////////////////////CreateViewResource///////////////////////////////
public static IView CreateViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
#if VVS_REFERENCED
if (IsPresent(pHost, eViewSystem.VirindiViewService))
return CreateViewResource(pHost, pXMLResource, eViewSystem.VirindiViewService);
else
#endif
return CreateViewResource(pHost, pXMLResource, eViewSystem.DecalInject);
}
public static IView CreateViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource, eViewSystem VSystem)
{
if (!IsPresent(pHost, VSystem)) return null;
switch (VSystem)
{
case eViewSystem.DecalInject:
return CreateDecalViewResource(pHost, pXMLResource);
case eViewSystem.VirindiViewService:
#if VVS_REFERENCED
return CreateMyHudViewResource(pHost, pXMLResource);
#else
break;
#endif
}
return null;
}
static IView CreateDecalViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
IView ret = new DecalControls.View();
ret.Initialize(pHost, pXMLResource);
return ret;
}
#if VVS_REFERENCED
static IView CreateMyHudViewResource(Decal.Adapter.Wrappers.PluginHost pHost, string pXMLResource)
{
IView ret = new VirindiViewServiceHudControls.View();
ret.Initialize(pHost, pXMLResource);
return ret;
}
#endif
///////////////////////////////CreateViewXML///////////////////////////////
public static IView CreateViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
#if VVS_REFERENCED
if (IsPresent(pHost, eViewSystem.VirindiViewService))
return CreateViewXML(pHost, pXML, eViewSystem.VirindiViewService);
else
#endif
return CreateViewXML(pHost, pXML, eViewSystem.DecalInject);
}
public static IView CreateViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML, eViewSystem VSystem)
{
if (!IsPresent(pHost, VSystem)) return null;
switch (VSystem)
{
case eViewSystem.DecalInject:
return CreateDecalViewXML(pHost, pXML);
case eViewSystem.VirindiViewService:
#if VVS_REFERENCED
return CreateMyHudViewXML(pHost, pXML);
#else
break;
#endif
}
return null;
}
static IView CreateDecalViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
IView ret = new DecalControls.View();
ret.InitializeRawXML(pHost, pXML);
return ret;
}
#if VVS_REFERENCED
static IView CreateMyHudViewXML(Decal.Adapter.Wrappers.PluginHost pHost, string pXML)
{
IView ret = new VirindiViewServiceHudControls.View();
ret.InitializeRawXML(pHost, pXML);
return ret;
}
#endif
///////////////////////////////HasChatOpen///////////////////////////////
public static bool AnySystemHasChatOpen(Decal.Adapter.Wrappers.PluginHost pHost)
{
if (IsPresent(pHost, eViewSystem.VirindiViewService))
if (HasChatOpen_VirindiViews()) return true;
if (pHost.Actions.ChatState) return true;
return false;
}
static bool HasChatOpen_VirindiViews()
{
#if VVS_REFERENCED
if (VirindiViewService.HudView.FocusControl != null)
{
if (VirindiViewService.HudView.FocusControl.GetType() == typeof(VirindiViewService.Controls.HudTextBox))
return true;
}
return false;
#else
return false;
#endif
}
public delegate void delConditionalSplit(object data);
public static void ViewConditionalSplit(IView v, delConditionalSplit onDecal, delConditionalSplit onVVS, object data)
{
Type vtype = v.GetType();
#if VVS_REFERENCED
if (vtype == typeof(VirindiViewServiceHudControls.View))
{
if (onVVS != null)
onVVS(data);
}
#endif
if (vtype == typeof(DecalControls.View))
{
if (onDecal != null)
onDecal(data);
}
}
}
}

View file

@ -0,0 +1,427 @@
///////////////////////////////////////////////////////////////////////////////
//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

@ -0,0 +1,329 @@
///////////////////////////////////////////////////////////////////////////////
//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);
}
}
}

427
MosswartMassacre/Wrapper.cs Normal file
View file

@ -0,0 +1,427 @@
///////////////////////////////////////////////////////////////////////////////
//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

@ -0,0 +1,329 @@
///////////////////////////////////////////////////////////////////////////////
//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);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<view icon="26075" title="Mosswart Massacre" width="300" height="200">
<control progid="DecalControls.FixedLayout" clipped="">
<control progid="DecalControls.PushButton" name="btnActivate" left="10" top="20" width="100" height="30" text="Activate"/>
<control progid="DecalControls.PushButton" name="btnReport" left="10" top="60" width="100" height="30" text="Report"/>
<control progid="DecalControls.PushButton" name="btnReset" left="10" top="100" width="100" height="30" text="Reset"/>
<control progid="DecalControls.StaticText" name="lblStatus" left="10" top="150" width="280" height="30" text="Mosswart Massacre is ready!"/>
</control>
</view>

27
mossy.sln Normal file
View file

@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35919.96 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MosswartMassacre", "MosswartMassacre\MosswartMassacre.csproj", "{8C97E839-4D05-4A5F-B0C8-E8E778654322}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C97E839-4D05-4A5F-B0C8-E8E778654322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C97E839-4D05-4A5F-B0C8-E8E778654322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C97E839-4D05-4A5F-B0C8-E8E778654322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C97E839-4D05-4A5F-B0C8-E8E778654322}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {54AC4980-B7EF-45B3-904B-B794558CFE53}
EndGlobalSection
EndGlobal