Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ChangeLogs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING.
# CHANGE LOG

[2.0.5.23]
[Next version (7d1120cd91b24b1e58a6d66a3100bfd47ebf9587)]
- Added: New update channel system
- Updated: Minor fix


[2.0.5.21]
- Added: Plugin Lifecycle event system
- Added: OmniMemo Plugin submodule
- Added: Compatibility with SM 18.041hp
- Added: Native access to TQueue and TFileSpace
- Added: WIP fix for collection corruption bug when a collection has non-empty file slots
- Added: nuget.config
- Added: releases directory to the repo
- Updated: Minor fix
- Updated: Packages
- Updated: Bumped version to 2.0.5
- Updated: SM Interop Package version
Expand Down
363 changes: 361 additions & 2 deletions SuperMemoAssistant.sln

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/Core/SuperMemoAssistant.Core/NativeDataCfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@
"Control_HeightOffset": "0x005C", // TControl::FHeight:Integer
"Queue_SizeOffset": "0x05", // TQueue::Size:Integer
"Application_InstancePtr": "0x00BB11E8", // Application:TApplication
"Application_OnMessageOffset": "0x120" // TApplication::FOnMessage:TMessageEvent
"Application_OnMessageOffset": "0x120", // TApplication::FOnMessage:TMessageEvent
"TContents_InstancePtr": "0x00CA3804" // gvar_00CA3804:TContents
},
"NativeCallPatterns": {
"ElWdw_GoToElement": { // TElWind::NewElement
Expand Down Expand Up @@ -419,6 +420,10 @@
"Pattern": "E8 ? ? ? ? 80 BD ? ? ? ? ? 75 45 8D 45 8E",
"Offset": 1
},
"TContents_MoveElementToConcept": {
"Pattern": "E8 ? ? ? ? A1 ? ? ? ? 8B 00 3B 45 EC",
"Offset": 1
},
"ElWdw_ExecuteUncommittedRepetition": { // TElWind::ExecuteUncommittedRepetition
"Pattern": "E8 ? ? ? ? 8D 45 EB 50",
"Offset": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ private ElemCreationResultCodes AddElement(ElementBuilder builder,
// Has a concept been specified for the new element ?

if (builder.Concept != null)
if (Core.SM.UI.ElementWdw.SetCurrentConcept(builder.Concept.Id) == false)
if (Core.SM.UI.ContentWdw.MoveElementToConcept(this[elemId].Id , builder.Concept.Id) == false)
successFlag |= ElemCreationResultCodes.WarningConceptNotSet;

//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Anotar.Serilog;
using SuperMemoAssistant.SMA;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperMemoAssistant.SuperMemo.Natives
{
public partial class SMNatives
{
public class TContents
{
#region Constructor
public TContents(NativeData nativeData)
{
InstancePtr = new IntPtr(nativeData.Pointers[NativePointer.TContents_InstancePtr]);
}
#endregion


#region Methods
public bool MoveElementToConcept(IntPtr TContentPtr, int elementId, int conceptId)
{
try
{
NativeMethod.TContents_MoveElementToConcept
.ExecuteOnMainThread(TContentPtr,
elementId,
conceptId);

return true;
}
catch (Exception ex)
{
LogTo.Error(ex, "Native method call threw an exception.");
return false;
}
}
#endregion

#region Properties & Fields - Public
public IntPtr InstancePtr { get; }
#endregion

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public SMNatives(NativeData nativeData)
Registry = new TRegistry(Database, nativeData);
FileSpace = new TFileSpace(Database, nativeData);
Queue = new TQueue(nativeData);
Contents = new TContents(nativeData);
}

#endregion
Expand All @@ -63,6 +64,7 @@ public SMNatives(NativeData nativeData)
public TRegistry Registry { get; }
public TFileSpace FileSpace { get; }
public TQueue Queue { get; }
public TContents Contents { get; }

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#region License & Metadata

// The MIT License (MIT)
//
// 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.

#endregion





namespace SuperMemoAssistant.SuperMemo.SuperMemo17.UI
{
using System;
using Anotar.Serilog;
using Common.UI;
using Process.NET.Memory;
using SuperMemoAssistant.Interop;
using SuperMemoAssistant.Interop.SuperMemo.Core;
using SuperMemoAssistant.Interop.SuperMemo.UI.Content;
using SuperMemoAssistant.SMA;
using System.Threading.Tasks;
using System.ComponentModel;

public sealed class ContentWdw : WdwBase, IDisposable, IContentWdw
{
#region Properties & Fields - Non-Public
private IPointer TContentWdwPtr { get; set; }
#endregion




#region Constructors

public ContentWdw()
{
Core.SMA.OnSMStartingInternalEvent += OnSMStartingAsync;
Core.SMA.OnSMStoppedInternalEvent += OnSMStoppedEvent;
}

/// <inheritdoc />
public void Dispose()
{
LogTo.Debug("Cleaning up {Name}", GetType().Name);

TContentWdwPtr?.Dispose();


TContentWdwPtr = null;

LogTo.Debug("Cleaning up {Name}... Done", GetType().Name);
}

#endregion




#region Methods Impl
public bool MoveElementToConcept(int elementId, int conceptId)
{
try
{
return Core.Natives.Contents.MoveElementToConcept(
TContentWdwPtr.Read<IntPtr>(),
elementId,
conceptId);
}
catch (Win32Exception ex)
{
LogTo.Warning(ex, "Failed to read TContentWdw");
return false;
}
catch (Exception ex)
{
LogTo.Error(ex, "SM internal method call threw an exception.");
return false;
}
}
#endregion




#region Methods
private async Task OnSMStartingAsync(object sender,
SMEventArgs e)
{
LogTo.Debug("Initializing {Name}", GetType().Name);

await Task.Run(() =>
{
TContentWdwPtr = SMProcess[Core.Natives.Contents.InstancePtr];
}).ConfigureAwait(false);
}

private void OnSMStoppedEvent(object sender,
SMProcessEventArgs e)
{
Dispose();
}

#endregion




#region Events
public override event Action OnAvailable;
#endregion




#region Properties Impl

//
// IWdwBase Impl

/// <inheritdoc/>
public override string WindowClass => SMConst.UI.ContentsWindowClassName;

/// <inheritdoc/>
protected override IntPtr WindowHandle => SMProcess.Memory.Read<IntPtr>(new IntPtr(TContentWdwPtr.Read<int>() + Core.Natives.Control.HandleOffset));

#endregion
}
}
4 changes: 4 additions & 0 deletions src/Core/SuperMemoAssistant.Core/SuperMemo/SuperMemoUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using PluginManager.Interop.Sys;
using SuperMemoAssistant.Interop.SuperMemo;
using SuperMemoAssistant.Interop.SuperMemo.UI.Element;
using SuperMemoAssistant.Interop.SuperMemo.UI.Content;
using SuperMemoAssistant.SuperMemo.SuperMemo17.UI;

namespace SuperMemoAssistant.SuperMemo
Expand All @@ -44,6 +45,7 @@ public class SuperMemoUICore : SuperMemoUI
public SuperMemoUICore()
{
base.ElementWdw = ElementWdw = new ElementWdw();
base.ContentWdw = ContentWdw = new ContentWdw();
}

#endregion
Expand All @@ -54,6 +56,7 @@ public SuperMemoUICore()
#region Properties & Fields - Public

public new ElementWdw ElementWdw { get; }
public new ContentWdw ContentWdw { get; }

#endregion
}
Expand All @@ -72,6 +75,7 @@ protected SuperMemoUI() { }
#region Properties Impl - Public

public IElementWdw ElementWdw { get; protected set; }
public IContentWdw ContentWdw { get; protected set; }

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ public enum NativeMethod
AppendAndAddElementFromText,
PostponeRepetition,
ForceRepetitionAndResume,
TContents_MoveElementToConcept,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ public enum NativePointer
Queue_SizeOffset,
Application_InstancePtr,
Application_OnMessageOffset,
TContents_InstancePtr,
}
}
15 changes: 15 additions & 0 deletions src/Core/SuperMemoAssistant/Installer/SuperMemoAssistant.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
<dependencies />
<!-- releaseNotes will be replaced by MSBuild.Tools (see SuperMemoAssistant.csproj and https://github.com/alexis-/MSBuild.Tools) -->
<releaseNotes>- Added: New update channel system
- Added: Plugin Lifecycle event system
- Added: OmniMemo Plugin submodule
- Added: Compatibility with SM 18.041hp
- Added: Native access to TQueue and TFileSpace
- Added: WIP fix for collection corruption bug when a collection has non-empty file slots
- Added: nuget.config
- Added: releases directory to the repo
- Updated: Minor fix
- Updated: Packages
- Updated: Bumped version to 2.0.5
- Updated: SM Interop Package version
- Updated: Interop version
- Updated: Submodules
- Fixed: SMA Packaging
- Fixed: Crash when removing a collection in the collection selection window
- Misc: Minor improvements
</releaseNotes>
</metadata>
<files>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/SuperMemoAssistant/SuperMemoAssistant.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PluginManager.Core">
<Version>0.2.1.141</Version>
<Version>0.2.1.143</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.8</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.0.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.0.5"
}
}